September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,10 @@
|
|||
fcn run_test(p,len,runs){
|
||||
cnt:=0; do(runs){
|
||||
pv:=0; do(len){
|
||||
v:=0 + ((0.0).random(1.0)<p); // 0 or 1, value of V[n]
|
||||
cnt += (pv<v); // if v is 1 & prev v was zero, inc cnt
|
||||
pv = v;
|
||||
}
|
||||
}
|
||||
return(cnt.toFloat() / runs / len);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
println("Running 1000 tests each:\n"
|
||||
" p\t n\tK\tp(1-p)\t diff\n"
|
||||
"-----------------------------------------------");
|
||||
foreach p in ([0.1..0.9,0.2]) {
|
||||
p1p:=p*(1.0 - p);
|
||||
n:=100; while(n <= 100000) {
|
||||
K:=run_test(p, n, 1000);
|
||||
"%.1f\t%6d\t%.4f\t%.4f\t%+.4f (%+.2f%%)".fmt(
|
||||
p, n, K, p1p, K - p1p, (K - p1p) / p1p * 100).println();
|
||||
n *= 10;
|
||||
}
|
||||
println();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue