It did take me a good night's sleep to understand it. I was stuck with
the exact same question but I see now how the remaining balls are
shared among all 8 urns (therefore cases with 11, 12, 13, ... 17 balls
are also dealt with).
Thanks again,
baptiste
2010/1/12 Rolf Turner :
>
> On 13/01/2010,
guie [mailto:baptiste.aug...@googlemail.com]
Sent: Tuesday, January 12, 2010 12:20 PM
To: Greg Snow
Cc: r-help
Subject: Re: [R] expand.grid game
Nice --- am I missing something or was this closed form solution not
entirely trivial to find?
I ought to compile the various clever solutions given in
On 13/01/2010, at 9:19 AM, Greg Snow wrote:
How trivial is probably subjective, I don't think it is much above
trivial. I would not have been surprised to see this question on
an exam in my undergraduate (300 or junior level) probability
course (the hard part was remembering the details f
08.8111
> -Original Message-
> From: baptiste auguie [mailto:baptiste.aug...@googlemail.com]
> Sent: Tuesday, January 12, 2010 12:20 PM
> To: Greg Snow
> Cc: r-help
> Subject: Re: [R] expand.grid game
>
> Nice --- am I missing something or was this closed form solu
...@r-project.org [mailto:r-help-boun...@r-
>> project.org] On Behalf Of Brian Diggs
>> Sent: Thursday, December 31, 2009 3:08 PM
>> To: baptiste auguie; David Winsemius
>> Cc: r-help
>> Subject: Re: [R] expand.grid game
>>
>> baptiste auguie wrote:
>> &
oject.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Brian Diggs
> Sent: Thursday, December 31, 2009 3:08 PM
> To: baptiste auguie; David Winsemius
> Cc: r-help
> Subject: Re: [R] expand.grid game
>
> baptiste auguie wrote:
> > 2009/12/19 David Winsemius :
> &
baptiste auguie wrote:
> 2009/12/19 David Winsemius :
>> On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote:
>>
>>> Dear list,
>>>
>>> In a little numbers game, I've hit a performance snag and I'm not sure
>>> how to code this in C.
>>>
>>> The game is the following: how many 8-digit numbers have t
Hi Ted.
you've found a bug in the documentation for blockparts().
It should read "0 <= ai <= yi". I'll fix it before the next
major release (which will include sampling without replacement from
a multiset, Insha'Allah).
Best wishes
rksh
(Ted Harding) wrote:
I wonder whether this answers Bap
OOPS!! See correction below!
On 21-Dec-09 08:45:13, Ted Harding wrote:
> I wonder whether this answers Baptiste's question as asked.
>
> 1: An 8-digit number can have some digits equal to 0;
>see Baptiste's comment "maxi <- 9 # digits from 0 to 9"
>
> 2: According to the man-page fror blockp
I wonder whether this answers Baptiste's question as asked.
1: An 8-digit number can have some digits equal to 0;
see Baptiste's comment "maxi <- 9 # digits from 0 to 9"
2: According to the man-page fror blockparts in partitions,
"all sets of a=(a1,...,an) satisfying Sum[ai] = n subject
Hello again everybody.
I fired off my reply before reading the correspondence about
the leading zeros.
You can also assume that there is at least one block
at the leading position, [so that position can take 0,1,2,...,8 additional
blocks] and distribute the remaining 16 blocks amongst all 8
pla
Wow!
system.time({
all = blockparts(rep(9,8),17)
print( dim(all[,all[1,]!=0])[2] ) # remove leading 0s
})
## 229713
user system elapsed
0.160 0.068 0.228
In some ways I think this is close to Hadley's suggestion, though I
didn't know how to implement it.
Thanks a lot to everybody who
Hi
library(partitions)
jj <- blockparts(rep(9,8),17)
dim(jj)
gives 318648
HTH
rksh
baptiste auguie wrote:
Dear list,
In a little numbers game, I've hit a performance snag and I'm not sure
how to code this in C.
The game is the following: how many 8-digit numbers have the sum of
their di
On Dec 19, 2009, at 2:28 PM, baptiste auguie wrote:
Hi,
Thanks for the link, I guess it's some kind of a classic game. I'm a
bit surprised by your timing, my ugly eval(parse()) "solution"
definitely took less than one hour with a machine not so different
from yours,
system.time( for (i in 100
This problem does yield some interesting and unexpected distributions.
Here is another, the number of positive cases as a function of number
of digits (8 in the original question) and of test value (17).
maxi <- 9
N <- 5
test <- 17
foo <- function(N=2, test=1){
sum(rowSums(do.call(expand.grid, c(
Hi,
Thanks for the link, I guess it's some kind of a classic game. I'm a
bit surprised by your timing, my ugly eval(parse()) "solution"
definitely took less than one hour with a machine not so different
from yours,
system.time( for (i in 1079:1179) if (sumdigits(i)==17) {idx<-c(idx,i)})
On Dec 19, 2009, at 1:36 PM, baptiste auguie wrote:
2009/12/19 David Winsemius :
On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote:
Dear list,
In a little numbers game, I've hit a performance snag and I'm not
sure
how to code this in C.
The game is the following: how many 8-digit numb
> I hope I have missed a better way to do this in R. Otherwise, I
> believe what I'm after is some kind of C or C++ macro expansion,
> because the number of loops should not be hard coded.
Why not generate the list of integers that sum to 17, and then mix
with 0s as appropriate?
Hadley
--
http:
2009/12/19 David Winsemius :
>
> On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote:
>
>> Dear list,
>>
>> In a little numbers game, I've hit a performance snag and I'm not sure
>> how to code this in C.
>>
>> The game is the following: how many 8-digit numbers have the sum of
>> their digits equal
On Dec 19, 2009, at 9:06 AM, baptiste auguie wrote:
Dear list,
In a little numbers game, I've hit a performance snag and I'm not sure
how to code this in C.
The game is the following: how many 8-digit numbers have the sum of
their digits equal to 17?
The brute-force answer could be:
maxi <-
Dear list,
In a little numbers game, I've hit a performance snag and I'm not sure
how to code this in C.
The game is the following: how many 8-digit numbers have the sum of
their digits equal to 17?
The brute-force answer could be:
maxi <- 9 # digits from 0 to 9
N <- 5 # 8 is too large
test <- 1
21 matches
Mail list logo