1. bug in raw_frequency()?
- Posted by Davy Jan 22, 2012
- 1180 views
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.
2. Re: bug in raw_frequency()?
- Posted by DerekParnell (admin) Jan 22, 2012
- 1133 views
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))
3. Re: bug in raw_frequency()?
- Posted by Davy Jan 23, 2012
- 1074 views
Thanks Derek. I notice the function doesn't tell you which value(s) have a frequency of zero, which would be useful in some circumstances. Of course you can find out easily enough, but it means writing additional code.