Displaying 3 results from an estimated 3 matches for "trunc_rnorm".
2010 Nov 30
1
Zooming in to a ggplot (a sort of ylim, but ylim won't do)
...here any way that I can save the results up to
geom_smooth call and then restrict the print region. See the example code
below.
Any help is much appreciated.
With kind regards,
A.
# not very important
set.seed(1234)
# I am only trying to chop-off anything below zero (this for the example
only)
trunc_rnorm <- function(n, mean = 0, sd = 1, lb = 0)
{
lb <- pnorm(lb, mean, sd)
qnorm(runif(n, lb, 1), mean, sd)
}
# generate my data, this is not important
rsp<-trunc_rnorm(160,mean=c(
rep(20,10),rep(25,10),rep(40,10),rep(45,10),
rep(20,10),rep(27,10),rep(42,10),rep(45,10),
rep(20,10),rep(...
2008 Apr 01
1
set the lower bound of normal distribution to 0 ?
...there any options to determine the lower bound of normal distribution to
> be 0 or can I simulate the samples in different ways to avoid the
> negative values?
Well, that would not be a normal distribution.
If you want a _truncated_ normal distribution it is very easy by
inversion. E.g.
trunc_rnorm <- function(n, mean = 0, sd = 1, lb = 0)
{
lb <- pnorm(lb, mean, sd)
qnorm(runif(n, lb, 1), mean, sd)
}
but I suggest you may rather want samples from a lognormal.
>
>
> > dat
> id x y
> 75 101 0.134 0.1911315
> 79 102 0.170 0.1610306
> 76 103 0.134 0.1911315
> 84...
2008 Mar 27
2
options in 'rnorm' to set the lower bound of normal distribution to 0 ?
Dear list,
I have a dataset containing values obtained from two different instruments (x and y).
I want to generate 5 samples from normal distribution for each instrument based on
their means and standard deviations. The problem is values from both instruments are
non-negative, so if using rnorm I would get some negative values. Is there any options
to determine the lower bound of normal