[R] Generate data - function

Petr Savicky savicky at cs.cas.cz
Tue Jan 31 17:09:11 CET 2012


On Tue, Jan 31, 2012 at 10:03:39AM -0500, Val wrote:
> Hi All,
> 
> I want generate data using R that follows the shape of graphs (A and B) in
> the attached file.  Can anybody suggest me what function fits for each
> graph?

Hi.

The graphs leave open several questions. Are the distributions
restricted to the shown intervals? How exactly should the
densities be close to the presented curves? Is it important
that the distribution of A is skewed? In other words, is it
important that the flat part of the high densities of A is
slightly increasing? Is B bimodal?

Using mixtures of two gaussians, it is possible to achieve
the following densities.

  x <- seq(0, 3, length=1001)
  y1 <- dnorm(x, mean=0.5, sd=1)
  y2 <- dnorm(x, mean=2.5, sd=1)
  plot(x, (y1+1.05*y2)/2.05, type="l")

  x <- seq(0, 3, length=1001)
  y1 <- dnorm(x, mean=0.5, sd=0.95)
  y2 <- dnorm(x, mean=2.5, sd=0.95)
  plot(x, (y1+y2)/2, type="l")

Are these curves satisfactory?

The generation then should be done differently, using
rnorm().

Petr Savicky.



More information about the R-help mailing list