Description Usage Arguments Value Author(s) Examples
View source: R/statistical-functions.R
Calculates the standard deviation of a numerical probability density function, i.e. a vector of values and corresponding vector of densities. It is important that the range of x values cover a sufficient fraction of the total density. For continuous distributions it should extend well into the tails. The approximation will be better the finer the resolution of x.
1 | SDofNumDist(x, d)
|
x |
vector of values |
d |
vector of densities, do not need to sum to 1 |
numeric
Andrew Dolman <andrew.dolman@awi.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
if(interactive()){
# Example 1
x <- seq(1, 100, by = 0.01)
d <- dnorm(x, 60, 5)
plot(x, d, type = "l")
SDofNumDist(x, d)
# Example 2
a <- 45
b <- 55
d2 <- dunif(x, a, b)
plot(x, d2, type = "l")
SDofNumDist(x, d2)
# analytical solution for uniform distribution
sqrt(1/12 * (b-a)^2)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.