Here's how I might fix histogram based on Gile's suggestions:

histogram=: (}.~0-0={:)@:<:@(#/.~)@(i.@>:@#@[ , I.)

This is a brute force approach: add an extra tally bucket and discard
it if it's empty.

But I think that this is not the correct approach. It seems to me that
there ought to be a test case which illustrates why it is wrong.

Anyways, probably the right place to start is with a clear
specification of how histogram is supposed to work. And, I am inclined
to adopt this one:

https://condor.depaul.edu/sjost/it223/documents/histograms.htm

Thoughts?

Thanks,

-- 
Raul

On Sat, Apr 10, 2021 at 8:29 AM Brian Schott <[email protected]> wrote:
>
> Like Devon, "I have noticed some oddities," and have described my
> variations at the following link.
> https://code.jsoftware.com/wiki/User:Brian_Schott/Histogram
>
> Below using spacing to emphasize similarities and differences in 3
> definitions, I have tried to restate the definitions so that a
> non proportional font will clarify the distinctions.
>
>    histogram =: <: @ (#/.~) @ (i.   @#@[ , I.)
>    histogram1=: <: @ (#/.~) @ (i.@>:@#@[ , I.)
>    histogram2=: <: @ (#/.~) @ (i.@>:@#@[ , Idotr)
>    Idotr =: |.@[ (#@[-I.) ]
>
> It seems to me that *histogram1* adjusts for the issue mentioned
> by Gilles, and *histogram2* further adjusts for the way statisticians
> traditionally compute histograms with half closed intervals defined as
> *[,)* instead of *(,]* .
>
> Below the verbs are shown with Gilles' data. *histogram1* and
> *histogram2* place the 0 in different intervals, but at least
> *histogram1* counts all data.
>
>    _5 0 5 histogram _2 _7 0 3 9
> 1 2 1 0
>    _5 0 5 histogram1 _2 _7 0 3 9
> 1 2 1 1
>    _5 0 5 histogram2 _2 _7 0 3 9
> 1 1 2 1
>
>
> Btw, the text in the link mentioned above needed to be revised
> to handle subscripts. Can anyone fix it even further in this regard?
>
>
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to