forked from cheng/wallet
somehow commited dud versions of mkdocs.sh and running_average.md
This commit is contained in:
parent
6235c20bb3
commit
b75fbbc80a
@ -1,6 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
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"
|
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
|
for f in *.md
|
||||||
do
|
do
|
||||||
echo $f
|
|
||||||
len=${#f}
|
len=${#f}
|
||||||
base=${f:0:($len-3)}
|
base=${f:0:($len-3)}
|
||||||
if [ $f -nt $base.html ];
|
if [ $f -nt $base.html ];
|
||||||
then
|
then
|
||||||
set -x
|
|
||||||
katex=""
|
katex=""
|
||||||
mine="--include-after-body=$templates/after.pandoc "
|
mine="--include-after-body=$templates/after.pandoc "
|
||||||
for i in 1 2 3 4
|
for i in 1 2 3 4 5 6
|
||||||
do
|
do
|
||||||
set -x
|
|
||||||
read line
|
read line
|
||||||
echo $line
|
|
||||||
if [[ $line =~ katex$ ]];
|
if [[ $line =~ katex$ ]];
|
||||||
then
|
then
|
||||||
katex=" --katex=./"
|
katex=" --katex=./"
|
||||||
@ -45,13 +40,11 @@ if [[ $line =~ notmine$ ]];
|
|||||||
# echo " $base.html up to date"
|
# echo " $base.html up to date"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo normal exit
|
|
||||||
cd libraries
|
cd libraries
|
||||||
templates="../pandoc_templates"
|
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"
|
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
|
for f in *.md
|
||||||
do
|
do
|
||||||
echo $f
|
|
||||||
len=${#f}
|
len=${#f}
|
||||||
base=${f:0:($len-3)}
|
base=${f:0:($len-3)}
|
||||||
if [ $f -nt $base.html ];
|
if [ $f -nt $base.html ];
|
||||||
@ -75,7 +68,6 @@ cd ../..
|
|||||||
templates=docs/pandoc_templates
|
templates=docs/pandoc_templates
|
||||||
for f in *.md
|
for f in *.md
|
||||||
do
|
do
|
||||||
echo $f
|
|
||||||
len=${#f}
|
len=${#f}
|
||||||
base=${f:0:($len-3)}
|
base=${f:0:($len-3)}
|
||||||
if [ $f -nt $base.html ];
|
if [ $f -nt $base.html ];
|
||||||
|
@ -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$$
|
Loading…
Reference in New Issue
Block a user