uCBQN/test/cases/fuzz/random.bqn

44 lines
1.8 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### WHOLE-FILE-TEST
# tests (•MakeRand x).Range itself
helpers •args
seed0 (helpers.GetRand@).Range 1e18
Range (•MakeRand seed0).Range
ExpectedRangeStep { nlen𝕊depthmax:
ls {𝕊:len Range max}¨n
maxGot ´´¨ls
! maxGot<max1
{𝕊: ! 0<´´¨ls} max=0
{(max=0) (max>n×len÷20) maxGot=max-1? @; •Out "Maximum ", •Repr max-1, " likely should have been encountered, but max was ", •Repr maxGot, "; n=", •Repr n," len=", •Repr len, " range=", •Repr max}
# some very very crappy statistics
sumExp n×len÷2
sumGot +´ +´¨ ls
{𝕊: sumGot max÷˜ (2÷˜n×len) + sumGot} max0
diff sumGot-sumExp
dev diff ÷ 12÷˜ n×len
{𝕊:
depth4? •Out "Unlikely sum (dev=", •Repr dev, ": expected ", •Repr sumExp, ", got ", •Repr sumGot, "; n=", •Repr n," len=", •Repr len, " range=", •Repr max;
nlen ExpectedRangeStep depth+1, max
} 2 < |dev
dev
}
ExpectedRange ExpectedRangeStep(0)
# for whatever reason, the following don't all evaluate to the same number; but they're close enough so ¯\_(ツ)_/¯
# •Show (+´÷≠) |{𝕊: 100‿1000 ExpectedRange 2 }¨↕10000
# •Show (+´÷≠) |{𝕊: 10‿1000 ExpectedRange 3 }¨↕10000
# •Show (+´÷≠) |{𝕊: 10‿1000 ExpectedRange 1e3}¨↕10000
# •Show (+´÷≠) |{𝕊: 10‿1000 ExpectedRange 1e6}¨↕10000
am 10000
# •Out "general"
((500+20)10) {((5×am)÷𝕨1)𝕨 ExpectedRange 𝕩} 3101001000100001000001e81e15 ¯101+2234
(10) {! ´0=𝕩 Range 1} 200
# •Out "bit boolean"
{5×am,𝕩 ExpectedRange 2}¨ 313233×100
# •Out "float"
{2×am,𝕩 ExpectedRange 0}¨ 100