r - Plot probability with ggplot2 (not density) -


i'd plot data such on y axis there probability (in range [0,1]) , on x-axis have data values. data contiguous (also in range [0,1]), i'd use kernel density estimation function , normalize such y-value @ point x mean probability of seeing value x in input data.

so, i'd ask:

a) reasonable @ all? understand cannot have probability of seeing values not have in data, interpolate between points have using kernel density estimation function , normalize afterwards.

b) there built-in options in ggplot use, override default behavior of geom_density() example doing this?

thanks in advance,

timo

edit: when said "normalize" before, meant "scale". got answer, guys clearing mind this.

this isn't ggplot answer, if want bring ideas of kernel smoothing , histograms bootstrapping + smoothing approach. you'll beat head , shoulders stats folks doing ugly things this, use @ own risk ;)

start synthetic data:

set.seed(1) randomdata <- c(rnorm(100, 5, 3), rnorm(100, 20, 3) ) hist(randomdata, freq=false) lines(density(randomdata), col="red") 

enter image description here

the density function has reasonably smart bandwidth calculator can borrow from:

bw <- density(randomdata)$bw resample <- sample( randomdata, 10000, replace=true) 

then use bandwidth calc sd make random noise

noise <- rnorm(10000, 0, bw) hist(resample + noise, freq=false) lines(density(randomdata), col="red") 

enter image description here

hey look! kernel smoothed histogram!

i know long response not answer question, maybe provide creative ideas on how abuse data.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -