Area
Area(y, x, x1, x2, i)
Returns the area (sum of trapezoids) under the continuous curve described by the points (x_i, y_i), on the interval x1 ≤ x ≤ x2. «x1» and «x2» are optional. When «x» or «y» is an index, then it is safe to omit «i». «x» and «y» should always have an index in common.
In the simple usage, the second parameter, «x», is an index with increasing numeric values, and «y» is indexed by «x». You can visualize «y» as a function of «x», and Area returns the area under the curve obtained when «x» is plotted on the X-axis and «y» on the Y-axis.
Using an array for «x»
When your X-axis values are in an array, e.g., x_val
and y_val
are both arrays indexed by In
, and you want the area from lb ≤ x_val ≤ ub
, you can use:
Area(y_val, x_val, lb, ub, In1)
Here the x-axis values are taken from the X-array rather than from the index i. If «x1» and «x2» are omitted, you can write
Area(y, x, i: In1)
or equivalently
Area(y, x,,, In1)
When using an array of values for the X-axis, the index, «i», may contain arbitrary values, but X must always contain numeric (or Null) values.
Discontinuities and treatment of null values
When the same value of «x» occurs twice, this encodes a discontinuity in the function at that value. The first occurrence provides the «y» value to the left, while the last occurrence provides the «y» value to the right.
When «x» contains a Null value, that point is ignored and does not impact the final result.
When «y» contains a Null value, this is interpreted as a gap in the function, and the trapezoid extending form the previous «x» value to the next next «x» value is not included in the area.
See the wiki page for Integrate for more details on both these points.
History
To improve consistency with Integrate and Normalize, and improve clarity, the names of the parameters to Area were changed in Analytica 4.2. Previously the parameters were: Area(r, i, x1, x2, j). Models that utilized named parameters will thus encounter a syntax error when loaded into 4.2. We believe this will occur extremely rarely.
Analytica 4.2 allows the points to be in any order, while earlier releases require points to increasing in «x». Analytica 4.2 also allows Null values in the data.
Another difference relative to 3.1 is that «x2» (upper bound) can be specified while not specifying «x1» (lower bound). So, for example, you could find the area up to a given point, e.g.:
Var dens := Pdf(Ch1);
Area(dens, dens.Step, X2: x)
See Also
- Integrate
- Normalize
- Gauss_Quadrature_Pts (for Gauss-Legendre Quadrature)
- Array-reducing functions
- Category:Integration (Quadrature) functions
Enable comment auto-refresher