Statistics/Basic: Difference between revisions

Added Julia language
(Added Julia language)
Line 1,870:
0.8: **************************************************
0.9: **************************************************</pre>
 
=={{header|Julia}}==
{{works with|Julia|0.6}}
 
<lang julia>function hist(numbers)
maxwidth = 50
h = fill(0, 10)
for n in numbers
h[ceil(Int, 10n)] += 1
end
mx = maximum(h)
for (n, i) in enumerate(h)
@printf("%3.1f: %s\n", n / 10, "+" ^ floor(Int, i / mx * maxwidth))
end
end
 
for i in 1:6
n = rand(10 ^ i)
println("\n##\n## $(10 ^ i) numbers")
@printf("μ: %8.6f; σ: %8.6f\n", mean(n), std(n))
hist(n)
end</lang>
 
{{out}}
<pre>
##
## 10 numbers
μ: 0.513345; σ: 0.261532
0.1:
0.2: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.3:
0.4: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.5: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.6:
0.7: +++++++++++++++++++++++++
0.8: +++++++++++++++++++++++++
0.9: ++++++++++++++++++++++++++++++++++++++++++++++++++
1.0:
 
##
## 100 numbers
μ: 0.483039; σ: 0.289858
0.1: ++++++++++++++++++++++++++++++++++++++++++
0.2: ++++++++++++++++++++++++++++++++++++++++++
0.3: ++++++++++++++++++++++++++++++++++++++++++
0.4: ++++++++++++++++++++++++++++++
0.5: ++++++++++++++++++++++++++++++++++++++++++++++
0.6: ++++++++++++++++++++++++++++++
0.7: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.8: +++++++++++++++++++
0.9: ++++++++++++++++++++++++++++++++++++++++++++++
1.0: ++++++++++++++++++++++++++++++++++
 
##
## 1000 numbers
μ: 0.482115; σ: 0.288932
0.1: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.2: ++++++++++++++++++++++++++++++++++++++++
0.3: ++++++++++++++++++++++++++++++++++++++++
0.4: ++++++++++++++++++++++++++++++++++++++++++
0.5: ++++++++++++++++++++++++++++++++++++
0.6: ++++++++++++++++++++++++++++++++++++++++++++++++
0.7: +++++++++++++++++++++++++++++++++++++++
0.8: ++++++++++++++++++++++++++++++++++++++
0.9: ++++++++++++++++++++++++++++++++++++++++
1.0: +++++++++++++++++++++++++++++++++++
 
##
## 10000 numbers
μ: 0.502500; σ: 0.288759
0.1: ++++++++++++++++++++++++++++++++++++++++++++++++
0.2: ++++++++++++++++++++++++++++++++++++++++++++++
0.3: ++++++++++++++++++++++++++++++++++++++++++++++
0.4: +++++++++++++++++++++++++++++++++++++++++++++++++
0.5: +++++++++++++++++++++++++++++++++++++++++++++++
0.6: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.7: +++++++++++++++++++++++++++++++++++++++++++++++
0.8: ++++++++++++++++++++++++++++++++++++++++++++++++
0.9: ++++++++++++++++++++++++++++++++++++++++++++++++
1.0: +++++++++++++++++++++++++++++++++++++++++++++++++
 
##
## 100000 numbers
μ: 0.499489; σ: 0.288911
0.1: +++++++++++++++++++++++++++++++++++++++++++++++++
0.2: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.3: ++++++++++++++++++++++++++++++++++++++++++++++++
0.4: ++++++++++++++++++++++++++++++++++++++++++++++++
0.5: ++++++++++++++++++++++++++++++++++++++++++++++++
0.6: +++++++++++++++++++++++++++++++++++++++++++++++++
0.7: ++++++++++++++++++++++++++++++++++++++++++++++++
0.8: +++++++++++++++++++++++++++++++++++++++++++++++++
0.9: +++++++++++++++++++++++++++++++++++++++++++++++++
1.0: ++++++++++++++++++++++++++++++++++++++++++++++++
 
##
## 1000000 numbers
μ: 0.500268; σ: 0.288622
0.1: +++++++++++++++++++++++++++++++++++++++++++++++++
0.2: +++++++++++++++++++++++++++++++++++++++++++++++++
0.3: +++++++++++++++++++++++++++++++++++++++++++++++++
0.4: +++++++++++++++++++++++++++++++++++++++++++++++++
0.5: +++++++++++++++++++++++++++++++++++++++++++++++++
0.6: +++++++++++++++++++++++++++++++++++++++++++++++++
0.7: +++++++++++++++++++++++++++++++++++++++++++++++++
0.8: ++++++++++++++++++++++++++++++++++++++++++++++++++
0.9: +++++++++++++++++++++++++++++++++++++++++++++++++
1.0: +++++++++++++++++++++++++++++++++++++++++++++++++</pre>
 
=={{header|Kotlin}}==
Anonymous user