x=rchisq(100,1) density(x) the density plot will give density for negative part also. of course I can truncate the plot to only view the non-negative part. I wonder if there is a program to compute density for a user-specified range, in this case, only [0, infinity). [[alternative HTML version deleted]]
Prof Brian Ripley
2013-Aug-20 05:22 UTC
[R] can I calculate density for only non-negative value?
On 20/08/2013 03:35, Gallon Li wrote:> x=rchisq(100,1) > density(x) > > the density plot will give density for negative part also. of course I can > truncate the plot to only view the non-negative part. > > I wonder if there is a program to compute density for a user-specified > range, in this case, only [0, infinity).Yes, but it will not be using the same method as density. One place to look is logspline() in package polspline, but please learn about the methodology of density estimation before you use any of these.> > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
David Winsemius
2013-Aug-20 05:24 UTC
[R] can I calculate density for only non-negative value?
On Aug 19, 2013, at 7:35 PM, Gallon Li wrote:> x=rchisq(100,1) > density(x) > > the density plot will give density for negative part also. of course I can > truncate the plot to only view the non-negative part. > > I wonder if there is a program to compute density for a user-specified > range, in this case, only [0, infinity).This has been asked and answered several times on this list. -- David Winsemius Alameda, CA, USA