Verify distribution uniformity/Naive: Difference between revisions

→‎{{header|J}}: pure explicit vs explicit with embedded tacit expressions
(→‎{{header|J}}: simplify)
(→‎{{header|J}}: pure explicit vs explicit with embedded tacit expressions)
Line 179:
n=. */y
delta=. x
sample=. u n NB. the "u" refers to the verb given to the left of the adverb
freqtable=. /:~ (~. sample) ,. #/.~) sample
expected=. n % # freqtable
errmsg=. 'Distribution is potentially skewed'
errmsg assert expected (delta& *@[ expected) > |@: expected -) {:"1 freqtable
freqtable
)
</lang>
 
It is possible to use tacit expressions within an explicit definition enabling a more functional and concise style:
<lang j>
checkUniformT=: adverb define
0.05 u checkUniformT y
:
freqtable=. /:~ (~. ,. #/.~) u n=. */y
errmsg=. 'Distribution is potentially skewed'
errmsg assert ((n % #) (x&*@[ > |@:-) {:"1) freqtable
freqtable
)
892

edits