help.search('poisson') On Nov 30, 2007 12:46 PM, alfieim29 <alfieim21 at hotmail.co.uk> wrote:> > How do I generate a value in R from a poisson distribution with mean 20? > > Thanks! > -- > View this message in context: http://www.nabble.com/Generating-a-value-tf4922234.html#a14086120 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
How do I generate a value in R from a poisson distribution with mean 20? Thanks! -- View this message in context: http://www.nabble.com/Generating-a-value-tf4922234.html#a14086120 Sent from the R help mailing list archive at Nabble.com.
alfieim29 wrote:> How do I generate a value in R from a poisson distribution with mean 20?Just type ?Poisson ... Best, Uwe Ligges> Thanks!
Here's how to generate a million psample <- rpois(1000000, lambda = 20) so guess how you would generate one. The main point is that if you really want to generate more than one, do it all at once like the above, do not do it in a loop. Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:Bill.Venables at csiro.au http://www.cmis.csiro.au/bill.venables/ -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of alfieim29 Sent: Saturday, 1 December 2007 6:21 AM To: r-help at r-project.org Subject: [R] Generating a value How do I generate a value in R from a poisson distribution with mean 20? Thanks! -- View this message in context: http://www.nabble.com/Generating-a-value-tf4922234.html#a14086120 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org 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, reproducible code.
Each number in the below list resides in a quantile. When put in order, there are 10 numbers, so the first is in the 0.1 quantile, the second in the 0.2 etc. Lets say we have 10 examples of systolic blood pressure from 30 year olds: 104,95,106,105,110,150,101,98,85,104 This is a random sample. What I want to do is in R, calculate the corresponding quantiles from a normal distribution with the same mean and variance as the sample. So, using the same mean and variance as the above random sample, create a normal distribution. From this normal distribution, I want to calculate 10 corresponding quantiles. Then, I want to plot a qqplot of both data sets to see the distribution. One person told me to do this: qnorm(c(0.25,0.5,0.75),mean=mean(x),sd=sd(x)) Output: [1] 3.76997 5.50000 7.23003 ...But this does not give me 10 corresponding quantiles? Another person told me to do this:> > > x=c(104,95,106,105,110,150,101,98,85,104)> > > n=length(x)> > > p=(1:n-0.5)/n> > > z=qnorm(p, mean(x), sd(x),)[order(order(x))]But this seems to generate 10 new numbers. And not give corresponding quantiles from a normal distribution. Any ideas? Please help! Thanks. _________________________________________________________________ Celeb spotting – Play CelebMashup and win cool prizes [[alternative HTML version deleted]]
Each number in the list belowresides in a quantile. When put in order, there are 10 numbers, so the first is in the 0.1 quantile, the second in the 0.2 etc. Lets say we have 10 examples of systolic blood pressure from 30 year olds: 104,95,106,105,110,150,101,98,85,104 This is a random sample. What I want to do is in R, calculate the corresponding quantiles from a normal distribution with the same mean and variance as the sample. So, using the same mean and variance as the above random sample, create a normal distribution. From this normal distribution, I want to calculate 10 corresponding quantiles. Then, I want to plot a qqplot of both data sets to see the distribution. One idea was this: qnorm(c(0.25,0.5,0.75),mean=mean(x),sd=sd(x)) Output: [1] 3.76997 5.50000 7.23003 ...But this does not give me 10 corresponding quantiles? Another idea was this:> > > x=c(104,95,106,105,110,150,101,98,85,104)> > > n=length(x)> > > p=(1:n-0.5)/n> > > z=qnorm(p, mean(x), sd(x),)[order(order(x))]But this seems to generate 10 new numbers. And not give corresponding quantiles from a normal distribution. Any ideas? Thanks. _________________________________________________________________ Celeb spotting – Play CelebMashup and win cool prizes [[alternative HTML version deleted]]
jimbib webber <alfieim21 at hotmail.co.uk> wrote in news:BLU108-W44A9C8E34EC3B26B0D73C1F2730 at phx.gbl:> Each number in the below list resides in a quantile. When put in > order, there are 10 numbers, so the first is in the 0.1 quantile, the > second in the 0.2 etc. > > Lets say we have 10 examples of systolic blood pressure from 30 year > olds: > 104,95,106,105,110,150,101,98,85,104> What I want to do is in R, calculate the corresponding quantiles from > So, using the same mean and variance as the above random sample, > create a normal distribution. From this normal distribution, I want to > calculate 10 corresponding quantiles. > > Then, I want to plot a qqplot of both data sets to see the > distribution. > > One person told me to do this: > > qnorm(c(0.25,0.5,0.75),mean=mean(x),sd=sd(x)) > > Output: > [1] 3.76997 5.50000 7.23003 > > ...But this does not give me 10 corresponding quantiles? > > Another person told me to do this: > >> > > x=c(104,95,106,105,110,150,101,98,85,104) > >> > > n=length(x) > >> > > p=(1:n-0.5)/n > >> > > z=qnorm(p, mean(x), sd(x),)[order(order(x))] > > But this seems to generate 10 new numbers. And not give corresponding > quantiles from a normal distribution.Try: qqnorm(x); qqline(x, col = 2) ....as suggested in the examples in the help message from ?qqplot. If you want the quantiles, invoking str(qqnorm(x)) suggests that the "x- values" can be recovered by: qqnorm(x)$x ....and therefore the quantiles from: pnorm(qqnorm(x)$x) -- David Winsemius