2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,7 +1,7 @@
require'statfns'
(mean,stddev) ?1000#0
require 'stats'
(mean,stddev) 1000 ?@$ 0
0.484669 0.287482
(mean,stddev) ?10000#0
(mean,stddev) 10000 ?@$ 0
0.503642 0.290777
(mean,stddev) ?100000#0
(mean,stddev) 100000 ?@$ 0
0.499677 0.288726

View file

@ -1,3 +1,3 @@
histogram=: <: @ (#/.~) @ (i.@#@[ , I.)
require'plot'
plot ((%*1+i.)100) ([;histogram) ?10000#0
plot ((% * 1 + i.)100) ([;histogram) 10000 ?@$ 0

View file

@ -1,23 +1,24 @@
histogram=: <: @ (#/.~) @ (i.@#@[ , I.)
meanstddevP=:3 :0
meanstddevP=: 3 :0
NB. compute mean and std dev of y random numbers
NB. picked from even distribution between 0 and 1
NB. and display a normalized ascii histogram for this sample
NB. note: should use population mean, not sample mean, for stddev
NB. note: uses population mean (0.5), not sample mean, for stddev
NB. given the equation specified for this task.
h=.s=.t=. 0
buckets=. (%~1+i.)10
for_n.i.<.y%1e6 do.
data=. ?1e6#0
h=.h+ buckets histogram data
s=.s+ +/ data
t=.t+ +/(data-0.5)^2
chunk=. 1e6
bins=. (%~ 1 + i.) 10
for. i. <.y%chunk do.
data=. chunk ?@$ 0
h=. h+ bins histogram data
s=. s+ +/ data
t=. t+ +/ *: data-0.5
end.
data=. ?(1e6|y)#0
h=.h+ buckets histogram data
s=.s+ +/ data
t=.t++/(data-0.5)^2
smoutput (<.300*h%y)#"0'#'
(s%y),%:t%y
data=. (chunk|y) ?@$ 0
h=. h+ bins histogram data
s=. s+ +/ data
t=. t+ +/ *: data - 0.5
smoutput (<.300*h%y) #"0 '#'
(s%y) , %:t%y
)