curve_area

curve_area(
    x,
    y,
    under='y',
    order_x='ascending',
    order_y='ascending',
    strict_x=True,
    strict_y=True,
)

Area under a paired x-y curve.

Mirrors the C# OrderedPairedData.TrapezoidalAreaUnderY/TrapezoidalAreaUnderX: the trapezoidal-rule area between the curve and the x-axis (under="y") or the y-axis (under="x"). Requires x (for under="y") or y (for under="x") to be sorted ascending or descending – order_x/order_y="none" raises the same error the C# method does.

Parameters

Name Type Description Default
x array_like Equal-length curve ordinates, at least two elements. required
y array_like Equal-length curve ordinates, at least two elements. required
under ('y', 'x') "y" (default) is the area against the x-axis; "x" is the area against the y-axis. "y"
order_x ('ascending', 'descending', 'none') "ascending"
order_y ('ascending', 'descending', 'none') "ascending"
strict_x bool True
strict_y bool True

Returns

Name Type Description
float

Examples

>>> from corehydropy import curve_area
>>> curve_area([1, 2, 3, 4], [1, 4, 9, 16])
21.5