After sending this, I realized my mistake.  But I was nowhere near a
computer.  In a few minutes, I'll be near computers but have no time
to post here.

For now, I'll note that I would rephrase the first definition like this:

  (+/@:(* ^.) (^.@] - %) +/) 2 3 5 7
1.28317
  ((* ^.) (^.@] - %)&(+/) ]) 2 3 5 7
1.28317
  ((^.@] - %)&(+/)~ (* ^.)) 2 3 5 7
1.28317
  ((^.@[ - %~)&(+/) (* ^.)) 2 3 5 7
1.28317

entropy=: (^.@[ - %~)&(+/) (* ^.)

But I've still not investigated numeric stability.

Thanks,

-- 
Raul

On Fri, Mar 22, 2013 at 7:39 AM, Raul Miller <[email protected]> wrote:
> If this is the first one:
> entropy =: +/@:(* ^.) (^.@] - %) +/
>
> and this is the second one:
> entropy =: -@(+/)@:(* ^.)@(% +/)
>
> it looks to me like the first one does more work.
>
> That said, I've not tried benchmarking it. Nor have I thought enough
> about numeric stability.
>
> --
> Raul
>
> On Thu, Mar 21, 2013 at 9:15 PM, Henry Rich <[email protected]> wrote:
>> The second one follows the classical definition: normalize frequencies to
>> add to 1, do the p ln p thing, add em up, and change the sign.
>>
>> The first one looks like it does a little less work, by some algebraic
>> manipulation, and might be a little faster.
>>
>> Henry Rich
>>
>>
>>
>>
>> On 3/21/2013 8:29 PM, Scott Locklin wrote:
>>
>>> <quote author="Henry Rich">
>>> entropy =: +/@:(* ^.) (^.@] - %) +/
>>> or
>>> entropy =: -@(+/)@:(* ^.)@(% +/)
>>> </quote>
>>>
>>> Hot dog! Thank you!
>>> Puzzing this out a bit, the second one makes more sense to me. I can stick
>>> parens and y's in and see what makes it tick. Somehow the fork and the @: in
>>> the first one confuses me on initial inspection (@ seems to work OK too). As
>>> I learn more about forks, perhaps I will feel better about things like this.
>>>
>>> mmdow was easy:
>>> mmdow=: entropy + (_1 + #) % 2 * +/
>>>
>>> Thanks again fellows! I'll drop another note in this thread when the
>>> script is done enough to share.
>>>
>>> -Scott
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>> ----------------------------------------------------------------------
>> 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