Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Statistics-Basic/Wren/statistics-basic.wren
Normal file
24
Task/Statistics-Basic/Wren/statistics-basic.wren
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import "random" for Random
|
||||
import "/math" for Nums
|
||||
|
||||
var r = Random.new()
|
||||
for (i in [100, 1000, 10000]) {
|
||||
var a = List.filled(i, 0)
|
||||
for (j in 0...i) a[j] = r.float()
|
||||
System.print("For %(i) random numbers:")
|
||||
System.print(" mean = %(Nums.mean(a))")
|
||||
System.print(" std/dev = %(Nums.popStdDev(a))")
|
||||
var scale = i / 100
|
||||
System.print(" scale = %(scale) per asterisk")
|
||||
var sums = List.filled(10, 0)
|
||||
for (e in a) {
|
||||
var f = (e*10).floor
|
||||
sums[f] = sums[f] + 1
|
||||
}
|
||||
for (j in 0..8) {
|
||||
sums[j] = (sums[j] / scale).round
|
||||
System.print(" 0.%(j) - 0.%(j+1): %("*" * sums[j])")
|
||||
}
|
||||
sums[9] = 100 - Nums.sum(sums[0..8])
|
||||
System.print(" 0.9 - 1.0: %("*" * sums[9])\n")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue