Hello If i want to resampl from the tails of normal distribution , are these commans equivelant?? upper tail:qnorm(runif(n,pnorm(b),1)) if b is an upper tail boundary or upper tail:qnorm((1-p)+p(runif(n)) if p is the probability of each interval (the observatins are divided to intervals) Regards [[alternative HTML version deleted]]
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] > On Behalf Of solafah bh > Sent: Sunday, October 03, 2010 3:39 PM > To: R help mailing list > Subject: [R] sampling from normal distribution > > Hello > If i want to resampl from the tails of normal distribution , are these > commans equivelant?? > upper tail:qnorm(runif(n,pnorm(b),1)) if b is an upper tail boundary > or > upper tail:qnorm((1-p)+p(runif(n)) if p is the probability of each > interval (the observatins are divided to intervals) > > Regards > > >Yes, they are equivalent, although the second formula is missing a closing parenthesis and a multiplication operator. You could also simplify the second formula to> qnorm(1-p*runif(n))Hope this is helpful, Dan Daniel Nordlund Bothell
On 03/10/2010 6:38 PM, solafah bh wrote:> Hello > If i want to resampl from the tails of normal distribution , are these commans equivelant?? > upper tail:qnorm(runif(n,pnorm(b),1)) if b is an upper tail boundary > or > upper tail:qnorm((1-p)+p(runif(n)) if p is the probability of each interval (the observatins are divided to intervals)You don't say how far up in the tail you are going, but if b is very large, you have to watch out for rounding error. For example, with b=10, pnorm(b) will be exactly equal to 1, and both versions will fail. In general for b > 0 you'll get a bit more accuracy by sampling from the lower tail using -b. For really extreme cases you will probably need to switch to a log scale. For example, to get a random sample from a normal, conditional on being larger than 20, you'd want something like n <- 10 logp1 <- pnorm(-20, log=TRUE) logprobs <- log(runif(n)) + logp1 -qnorm(logprobs, log=TRUE) Duncan Murdoch