bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: [Bug-gnubg] (OT) Position ID documentation

 From: Massimiliano Maini Subject: Re: [Bug-gnubg] (OT) Position ID documentation Date: Fri, 28 May 2010 13:18:45 +0200

```Strange, we don't get the same number as Trice ...

you & I : 18,528,584,051,601,166,000
Trice    : 18,528,584,051,601,162,496

There's something strange in googledocs: look at the value of the product
for the line with m=3 ... it ends in 808 ...

MaX.

2010/5/28 Øystein Johansen <address@hidden>:
> ??? Strange. I copied and pasted from a web site.
>
> function productRange(a,b) {
>   var product=a,i=a;
>
>   while (i++<b) {
>     product*=i;
>   }
>   return product;
> }
>
> function combinations(n,k) {
>   if (n==k) {
>     return 1;
>   } else {
>     k=Math.max(k,n-k);
>     return productRange(k+1,n)/productRange(1,n-k);
>   }
> }
>
> function distributions(N, M) {
>   return  combinations( N+M-1,M);
> }
>
> Maybe I should not trust everything I read. However, I can't immediately see
> any bugs in the above code....
> Aha! Now I see! It's wrong when k = 0, I'll fix it. Hang on.
>
> May be a bad fix, but I think it works better now.
>
> -Øystein
>
>
> 2010/5/28 Massimiliano Maini <address@hidden>
>>
>> Now it works.
>>
>> Your combinations function seems to be wrong for m=0:
>>
>> combin(24,0) = 1
>> combinations(24,0) = 25
>>
>> Guess you just have to define distribution as a function of COMBIN ...
>>
>> MaX.
>>
>> 2010/5/28 Øystein Johansen <address@hidden>:
>> > 2010/5/28 Massimiliano Maini <address@hidden>
>> >>
>> >> Google docs, right .. excel is so has been :)
>> >>
>> >> BTW, your link does not work.
>> >
>> > I see .... I'll try to publish it as a web page:
>> >
>> >
>> > http://spreadsheets.google.com/pub?key=tqUcK-zFdgQC_byUJvbgqvQ&output=html
>> >
>> > -Øystein
>> >
>> >
>
>

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]