MannWhitneyUTest.mannWhitneyU

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

MannWhitneyUTest.mannWhitneyU

Dave Brosius-2
I would think that in

public double mannWhitneyU(final double[] x, final double[] y)



final double U1 = sumRankX - (x.length * (x.length + 1)) / 2;


should be


final double U1 = sumRankX - (x.length * (x.length + 1)) / 2*.0*;


right?
Reply | Threaded
Open this post in threaded view
|

[math] .mannWhitneyU

Phil Steitz


On Aug 26, 2013, at 8:57 AM, Dave Brosius <[hidden email]> wrote:

> I would think that in
>
> public double mannWhitneyU(final double[] x, final double[] y)
>
>
>
> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2;

Hey thanks for looking at the code!  I agree forcing double arithmetic is better, but I bet the reason we don't get bad results from this is that the numerator above is always going to be even (either x.len or its successor is guaranteed to be even) so int division is OK.

Phil
>
>
> should be
>
>
> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2*.0*;
>
>
> right?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: MannWhitneyUTest.mannWhitneyU

Ted Dunning
In reply to this post by Dave Brosius-2
I think that it will be somewhat slower, but next to imperceptibly so.

It will not be any more accurate.

It should be noted, however, that this code will fail for input longer than
2^16 because of integer overflow.



On Sun, Aug 25, 2013 at 8:27 PM, Dave Brosius <[hidden email]> wrote:

> I would think that in
>
> public double mannWhitneyU(final double[] x, final double[] y)
>
>
>
> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2;
>
>
> should be
>
>
> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2*.0*;
>
>
> right?
>
Reply | Threaded
Open this post in threaded view
|

Re: MannWhitneyUTest.mannWhitneyU

Phil Steitz
On 8/25/13 11:15 PM, Ted Dunning wrote:
> I think that it will be somewhat slower, but next to imperceptibly so.
>
> It will not be any more accurate.
>
> It should be noted, however, that this code will fail for input longer than
> 2^16 because of integer overflow.

Good point.  We should either cast to double or long in the
numerator then.

Phil

>
>
>
> On Sun, Aug 25, 2013 at 8:27 PM, Dave Brosius <[hidden email]> wrote:
>
>> I would think that in
>>
>> public double mannWhitneyU(final double[] x, final double[] y)
>>
>>
>>
>> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2;
>>
>>
>> should be
>>
>>
>> final double U1 = sumRankX - (x.length * (x.length + 1)) / 2*.0*;
>>
>>
>> right?
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]