Here is one way to solve the equation: require(BB)
f <- function(x) (2*gamma(1+1/x))^x + log (0.10) ans <- dfsane(par=1, fn=f) ans Ravi. ---------------------------------------------------------------------------- ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml ---------------------------------------------------------------------------- -------- -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Arnold Sent: Wednesday, June 10, 2009 11:25 AM To: Etienne B. Racine Cc: r-help@r-project.org Subject: Re: [R] Creating a specific skewed distribution Etienne et al, This is exactly what I need. So I gave it an algebraic try and set: Mean=30=b*gamma(1+1/a), solve for b and substitute into F(60)=0.10. After a little algebra, this left me with [ 2*gamma(1+1/a) ]^a = -ln(0.10) Now, I don't think this has a closed form solution, at least not one I have the skill to find. So, how would I solve this using R? David. On Jun 10, 2009, at 7:09 AM, Etienne B. Racine wrote: > > You could also make some algebra. e.g. : > > ?rweibull > > gives the formula of the mean and of the cumulative distribution > function in the Details section. So using your known parameters (i.e. > mean=30 and p(10)=.10, i.e. cumulative function(10) =.90), I think it > is sufficient to determine the exact values you want shape and scale > to be. > > And you can do that with any probability function (some easier the > calculate) as most (if not all) have these equations. Of course, it > might be more pleasing to play with the parameters. > > Etienne > > > Mike Lawrence wrote: >> >> With skewed unimodal distributions, the mode can't equal the mean, so >> assuming you want the mean to be around 30, I find that a weibull >> function can get close to what you want: >> >>> mean(rweibull(1e5,1.5,33)) >> [1] 29.77781 >>> pweibull(60,1.5,33) >> [1] 0.9138475 >> >> I'm sure you can play with the parameters to try to get even closer >> to what you want. >> >> On Wed, Jun 10, 2009 at 2:48 AM, David >> Arnold<dwarnol...@suddenlink.net >> > >> wrote: >>> All, >>> Can someone help me create a skewed distribution, mean = 30, with >>> probability of selecting a random number from the distribution >>> greater than or equal 60 equal to 10%? >>> >>> I need the probability density function to equal zero at zero, and >>> have a maximum height at or near 30. >>> >>> Is this possible? >>> >>> And if it is possible, how can I adjust the distribution so that the >>> probability of selecting a random number greater than or equal to 60 >>> is p. >>> >>> Thanks. No idea how to start. >>> >>> David >>> >>> >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@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. >>> >> >> >> >> -- >> Mike Lawrence >> Graduate Student >> Department of Psychology >> Dalhousie University >> >> Looking to arrange a meeting? Check my public calendar: >> http://tr.im/mikes_public_calendar >> >> ~ Certainty is folly... I think. ~ >> >> ______________________________________________ >> R-help@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. >> >> > > -- > View this message in context: > http://www.nabble.com/Creating-a-specific-skewed-distribution-tp239561 > 14p23963140.html Sent from the R help mailing list archive at > Nabble.com. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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. ______________________________________________ R-help@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.