Description Usage Arguments Value Acknowledgements Note Author(s) See Also Examples
Calculates the value for the ith point in a binned distribution
1 |
den |
vector of frequency or density values |
vals |
vector of values corresponding to the centres of the bins in |
point |
percentage point of the distribution ie: 0.50 is median |
na.rm |
behaviour for NA's in the vector of density values: |
neg.rm |
per() will also fail if any member of the density vector is negative (which can happen occasionally from density functions based on FFT), set this to |
returns a value:
x |
value of |
Written in collaboration with A.M.Pollard <mark.pollard@rlaha.ox.ac.uk> with the financial support of the Natural Environment Research Council (NERC) grant GR3/11395
Not restricted to uniform bin widths but due to linear interpolation gets less accurate as bin widths deviate from uniformity. The vectors must be in ascending order of bin centres bin break points. The density can be a frequency in that it doesn't have to sum to unity.
Out of character for the rest of the GenKern package this function does assume proper bins rather than ordinates, although if a density estimate has been generated using KernSec
then the ordinate vector can be used as a first order approximation to bin centres.
David Lucy <d.lucy@lancaster.ac.uk> http://www.maths.lancs.ac.uk/~lucy/
Robert Aykroyd <r.g.aykroyd@leeds.ac.uk>http://www.amsta.leeds.ac.uk/~robert/
KernSur
per
density
hist
bkde
bkde2D
dpik
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # make up some x-y data
x <- seq(1,100)
y <- dnorm(x, mean=40, sd=10)
plot(x,y)
# mark the median, 0.1 and 0.9 positions with vertical lines
abline(v=per(y,x,0.5))
abline(v=per(y,x,0.9))
abline(v=per(y,x,0.1))
# for a bimodal distribution which doesn't sum to one
x <- c(1:5)
y <- c(2,3,4,3,4)
per(y,x,0.5) # should return 3.25
# change the previous example to bin extremes
x <- c(1:6)
per(y,x,0.5) # should return 3.75
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.