diff --git a/docs/mkdocs.sh b/docs/mkdocs.sh index 63e339a..fb98630 100644 --- a/docs/mkdocs.sh +++ b/docs/mkdocs.sh @@ -1,6 +1,5 @@ #!/bin/bash set -e -set -x cd `dirname $0` if [[ "$OSTYPE" == "linux-gnu"* ]]; then @@ -16,19 +15,15 @@ templates="./pandoc_templates" options=$osoptions"--toc -N --toc-depth=5 --wrap=preserve --metadata=lang:en --include-in-header=$templates/icon.pandoc --include-before-body=$templates/before.pandoc --css=$templates/style.css -o" for f in *.md do - echo $f len=${#f} base=${f:0:($len-3)} if [ $f -nt $base.html ]; then - set -x katex="" mine="--include-after-body=$templates/after.pandoc " - for i in 1 2 3 4 + for i in 1 2 3 4 5 6 do - set -x read line - echo $line if [[ $line =~ katex$ ]]; then katex=" --katex=./" @@ -45,13 +40,11 @@ if [[ $line =~ notmine$ ]]; # echo " $base.html up to date" fi done -echo normal exit cd libraries templates="../pandoc_templates" options=$osoptions"--toc -N --toc-depth=5 --wrap=preserve --metadata=lang:en --include-in-header=$templates/icondotdot.pandoc --include-before-body=$templates/beforedotdot.pandoc --css=$templates/style.css --include-after-body=$templates/after.pandoc -o" for f in *.md do - echo $f len=${#f} base=${f:0:($len-3)} if [ $f -nt $base.html ]; @@ -75,7 +68,6 @@ cd ../.. templates=docs/pandoc_templates for f in *.md do - echo $f len=${#f} base=${f:0:($len-3)} if [ $f -nt $base.html ]; diff --git a/docs/running_average.md b/docs/running_average.md index e69de29..c8c0342 100644 --- a/docs/running_average.md +++ b/docs/running_average.md @@ -0,0 +1,32 @@ +--- +# katex +title: running average +--- + +The running average $a_n$ of a series $R_n$ + +$$a_n =\frac{a\_{n-1}\times u+R_n\times v}{u+v}$$ + +The larger $u$ and the smaller $v$, the longer the period over which the running average is taken. + +We don’t want to do floating point arithmetic, because different peers +might get different answers. + +It is probably harmless if they get different answers, provided that this +happens rarely, but easier to ensure that this never happens than to try to +think about all the possible circumstances where this could become a +problem, where malicious people could contrive inputs to make sure it +becomes a problem. + +Unsigned integer arithmetic is guaranteed to give the same answers on all +hardware under all compilers. So, when we can, use unsigned integers. + +$R_n$is a very small integer where we are worried about very small +differences, so we rescale to represent arithmetic with eight or so bits after +the binary point in integer arithmetic. + +$\widetilde {a_n}$represents the rescaled running average $a_n$ + +$$\widetilde {a_n}=\frac{u\widetilde{a_{n-1}} +v{R_n}\times 2^8}{u+v}$$ + +$$a_n = \bigg\lfloor\frac{{\widetilde {a_n}}+2^7}{2^8}\bigg\rfloor$$