Chien-Pang Chin
2015-Sep-15 10:58 UTC
[R] Beta distribution approximate to Normal distribution
Hi, I need to generate 1000 numbers from N(u, a^2), however I don't want to include 0 and negative values. How can I use beta distribution approximate to N(u, a^2) in R. Thx for help
JLucke at ria.buffalo.edu
2015-Sep-15 13:26 UTC
[R] Beta distribution approximate to Normal distribution
Your question makes no sense as stated. However, guessing at what you want, you should perhaps consider the non-central chi-square density with 1 df and ncp = u/a, i.e, rchisq(100, df=1, ncp=u/a) Joe Joseph F. Lucke, PhD Senior Statistician Research Institute on Addictions University at Buffalo State University of New York 1021 Main Street Buffalo, NY 14203-1016 Chien-Pang Chin <chienpang.c at gmail.com> Sent by: "R-help" <r-help-bounces at r-project.org> 09/15/2015 06:58 AM To "r-help at r-project.org" <r-help at r-project.org>, cc Subject [R] Beta distribution approximate to Normal distribution Hi, I need to generate 1000 numbers from N(u, a^2), however I don't want to include 0 and negative values. How can I use beta distribution approximate to N(u, a^2) in R. Thx for help ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]]
peter dalgaard
2015-Sep-15 13:50 UTC
[R] Beta distribution approximate to Normal distribution
On 15 Sep 2015, at 15:26 , JLucke at ria.buffalo.edu wrote:> Your question makes no sense as stated. However, guessing at what you > want, you should perhaps consider the non-central chi-square density with > 1 df and ncp = u/a, i.e, > > rchisq(100, df=1, ncp=u/a)Something's not right with that. Noncentral chisquare has mean df+ncp and variance 2*df + 4*ncp, which doesn't work out as anything like u and a^2. Other possibilities include gamma and lognormal distributions. -pd> > Joe > > > > Joseph F. Lucke, PhD > Senior Statistician > Research Institute on Addictions > University at Buffalo > State University of New York > 1021 Main Street > Buffalo, NY 14203-1016 > > > > > > > Chien-Pang Chin <chienpang.c at gmail.com> > Sent by: "R-help" <r-help-bounces at r-project.org> > 09/15/2015 06:58 AM > > To > "r-help at r-project.org" <r-help at r-project.org>, > cc > > Subject > [R] Beta distribution approximate to Normal distribution > > > > > > > Hi, > > I need to generate 1000 numbers from N(u, a^2), however I don't want to > include 0 and negative values. How can I use beta distribution approximate > to N(u, a^2) in R. > > Thx for help > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
(Ted Harding)
2015-Sep-15 15:12 UTC
[R] Beta distribution approximate to Normal distribution
Using non-central chi-squared (especially with df=1) is unlikely
to generate random numbers anywhere near a Normal distribution
(see below).
And "rchisq(100, df=1, ncp=u/a)" won't work anyway with u<0,
since ncp must be >= 0 (if < 0 then all are NA).
Better to shoot straight for the target (truncated Normal), though
several shots are likely to be required! For example (code which
spells it out), taking u=3 and a=2:
n <- 100
u <- 3 ; a <- 2
x <- NULL
N <- length(x)
while(N < n){
x <- c(x,rnorm(n,mean=u,sd=a))
x <- x[x>0]
N <- length(x)
}
x <- x[1:n]
Comparison with non-central chi-squared:
y <- rchisq(100, df=1, ncp=u/a)
hist(x)
hist(y)
On 15-Sep-2015 13:26:44 JLucke at ria.buffalo.edu wrote:> Your question makes no sense as stated. However, guessing at what you
> want, you should perhaps consider the non-central chi-square density with
> 1 df and ncp = u/a, i.e,
>
> rchisq(100, df=1, ncp=u/a)
>
> Joe
> Joseph F. Lucke, PhD
> Senior Statistician
> Research Institute on Addictions
> University at Buffalo
> State University of New York
> 1021 Main Street
> Buffalo, NY 14203-1016
>
> Chien-Pang Chin <chienpang.c at gmail.com>
> Sent by: "R-help" <r-help-bounces at r-project.org>
> 09/15/2015 06:58 AM
>
> To
> "r-help at r-project.org" <r-help at r-project.org>,
>
> Subject
> [R] Beta distribution approximate to Normal distribution
>
> Hi,
> I need to generate 1000 numbers from N(u, a^2), however I don't
> want to include 0 and negative values. How can I use beta distribution
> approximate to N(u, a^2) in R.
>
> Thx for help
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 15-Sep-2015 Time: 16:12:35
This message was sent by XFMail