Benford's law: Difference between revisions

Content added Content deleted
(→‎{{header|J}}: Table of expected vs actual freqs)
Line 1,641: Line 1,641:
=={{header|J}}==
=={{header|J}}==
'''Solution'''
'''Solution'''
<syntaxhighlight lang="j">benford=: 10&^.@(1 + %) NB. expected frequency of 1-9 as first digit
<syntaxhighlight lang="j">benford=: 10&^.@(1 + %) NB. expected frequency of first digit y
Digits=: '123456789'
Digits=: '123456789'
firstSigDigits=: {.@(-. -.&Digits)@":"0 NB. extract first significant digit from numbers
firstSigDigits=: {.@(-. -.&Digits)@":"0 NB. extract first significant digit from numbers