I built a density function, and now I want to calculate the probability that a new data point will “fall” into the selected interval (say, a = 3, b = 7). So I'm looking for:
P(a<x<=b)
Some sample data:
df<- data.frame(x=c(sample(6:9, 50, replace=TRUE), sample(18:23, 25, replace=TRUE)))
dens<- density(df$x)
I will be glad to hear about any solution, but preferably in the r base
Thank you in advance
source
share