Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
23
Task/Statistics-Basic/J/statistics-basic-3.j
Normal file
23
Task/Statistics-Basic/J/statistics-basic-3.j
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
histogram=: <: @ (#/.~) @ (i.@#@[ , I.)
|
||||
|
||||
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. 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
|
||||
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
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue