Skip to contents

Integrates the peak model over a given range to calculate the area.

Usage

peak_model_area(model, params, x_range = NULL)

Arguments

model

A peak_model object.

params

Named list of model parameters.

x_range

Numeric vector of length 2 giving the integration range. If NULL, integrates over the full domain (may require analytical solution).

Value

Numeric scalar giving the peak area.

Details

A finite x_range is treated as the integration interval for every model. With x_range = NULL, built-in models return their whole-domain area when it is defined. Other models use adaptive numerical integration when a finite interval is supplied.

Examples

model <- create_peak_model("gaussian")
params <- list(height = 1, center = 5, width = 1)
area <- peak_model_area(model, params, c(0, 10))
area
#> [1] 2.506627