Verify distribution uniformity/Naive: Difference between revisions
Verify distribution uniformity/Naive (view source)
Revision as of 01:09, 25 September 2009
, 14 years ago→{{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
freqtable=. /:~ (~. sample) ,. #/.~
expected=. n % # freqtable
errmsg=. 'Distribution is potentially skewed'
errmsg assert
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
)
|