simpsons | R Documentation |
Calculates the area below a curve from
points a
to b
. This function is provided
for general use.
simpsons(f, a, b, n = 100)
f |
A function. |
a |
Numeric. The left x boundary. |
b |
Numeric. The right x boundary. |
n |
Numeric. The number of subdivisions along the function line. |
Note that if y-values are negative, this returns the area above the function line.
A numeric value representing the area under the curve with
x bounds a
and b
.
# import raster image
data(normforest)
normforest <- terra::unwrap(normforest)
# basic values
z <- terra::values(normforest)
# calculate cumulative probability density function of surface 'height' (= ndvi)
mod <- ecdf((1 - z))
# calculate integral
int_area <- simpsons(f = mod, b = 1, a = 0.8, n = 500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.