Re: [R] faster computation of cumulative multinomial distribution

2007-04-02 Thread theo borm
Alberto Vieira Ferreira Monteiro wrote: Theo Borm wrote: Think of a sort of power roulette, played with 58 balls simultaneously, with a wheel containing 36 red/black slots of unequal size, and 1 green slot. I need to calculate the probability that each of the 36 red/black slots contains

[R] faster computation of cumulative multinomial distribution

2007-03-30 Thread Theo Borm
) faster way? with kind regards, Theo Borm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained

Re: [R] faster computation of cumulative multinomial distribution

2007-03-30 Thread theo borm
Alberto Monteiro wrote: Theo Borm wrote: I have a series of /unequal/ probabilities [p1,p2,...,pk], describing mutually exclusive events, and a remainder class with a probability p0=1-p1-p2--pk, and need to calculate, for a given number of trials t=k, the combined probability

[R] using integrate in a function definition

2007-02-23 Thread theo borm
Dear list members, I'm quite new to R, and though I tried to find the answer to my probably very basic question through the available resources (website, mailing list archives, docs, google), I've not found it. If I try to use the integrate function from within my own functions, my functions

Re: [R] using integrate in a function definition

2007-02-23 Thread theo borm
Ravi Varadhan wrote: Your function jjj is not vectorized. Try this: jjj - function(www) sapply(www, function(x)2*integrate(dnorm,0,x)$value) plot(jjj, 0, 5) It should work. Yes it does. Thanks! Thinking of it, it now starts to make some sort of sense that integrate should return a

Re: [R] using integrate in a function definition

2007-02-23 Thread theo borm
Hi, Many thanks for the explanation. Alberto Monteiro wrote: PS: fff - function(x) 1 integrate(fff, 0, 1) # error. why? Guess: because integrate itself expects a vectorized function ? fff(1:5) [1] 1 ggg-function(x) { sapply(x, function(x)1) } ggg(1:5) [1] 1 1 1 1 1