Re: bug in raw_frequency()?
- Posted by DerekParnell (admin) Jan 22, 2012
- 1132 views
Davy said...
When running this code, the value of 0 in the data_set isn't counted -
include std/stats.e sequence t, s = {}, data_set = {0,1,2,3,4,5,6,7,8,9} for j = 1 to 1000 do s &= data_set[rand(10)] end for t = raw_frequency(s, ST_ALLNUM) ? t
t is -
{ {108,8}, {106,5}, {104,1}, {103,3}, {102,2}, {100,4}, {97,6}, {90,9}, {84,7} }
But if I change the 0 to 10 in data_set, the correct number of values (with their frequencies) are output.
Yes this is a bug. As a workaround, change one line in the function found in stats.e.
Change the line ...
lKeys = repeat(0, length(data_set))
to ...
lKeys = repeat({}, length(data_set))