Difference between revisions of "Area"

m (adding doc status category stub page)
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Array-reducing functions]]
 
[[Category:Array-reducing functions]]
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
+
[[Category:Integration (Quadrature) functions]]
 +
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
  
Area(R,I,X1,X2)
+
== Area(y, x'', x1, x2, i'') ==
Returns the area (sum of trapezoids) under array R across index I between X1 and X2. X1 and X2 are optional.
+
Returns the area (sum of trapezoids) under the continuous curve described by the points (x_i, y_i), on the interval ''x1 &le; x &le; 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.
  
= Declaration =
+
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.
  Area( R : Numeric[J] ; I : ascending Numeric[J] ; X1,X2 : opt numeric atomic ; J : opt hidden IndexType = I )
 
  
= Simplest Usage =
+
== Using an array for «x» ==
 +
When your X-axis values are in an array, e.g., <code>x_val</code> and <code>y_val</code> are both arrays indexed by <code>In</code>, and you want the area from <code>lb &le; x_val &le; ub</code>, you can use:
 +
:<code>Area(y_val, x_val, lb, ub, In1)</code>
  
In the simple usage, the second parameter, I, is an index with increasing numeric values, and R is indexed by IYou can visualize R as a function of I, and Area returns the area under the curve obtained when I is plotted on the X-axis and R on the Y-axis.
+
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
 +
:<code>Area(y, x, i: In1)</code>
  
= Using an array for I =
+
or equivalently
 +
:<code>Area(y, x,,, In1)</code>
  
(new to 4.0).
+
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.
When your X-axis values are in an array, e.g., X and Y are both arrays indexed by In1, you can use:
 
Area( Y,X,X1,X2,In1 )
 
  
Here the x-axis values are taken from the X-array rather than from the indexIf X1 and X2 are omitted, you can write
+
== Discontinuities and treatment of null values ==
Area( R:Y,I:X,J:In1 )
+
When the same value of «x» occurs twice, this encodes a discontinuity in the function at that valueThe first occurrence provides the «y» value to the left, while the last occurrence provides the «y» value to the right.
or equivalently
 
Area( Y,X, J:In1 )
 
  
When using an array of values for the X-axis, the index, J, may contain arbitrary values, but X must contain values that are in ascending order.
+
When «x» contains a [[Null]] value, that point is ignored and does not impact the final result.
  
If X is a self-indexed array, and Y is indexed by X, and the J parameter is omitted, then the values of X are used and the self-index of X is used.
+
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.
  
= Details =
+
See the wiki page for [[Integrate]] for more details on both these points.
  
Some notes: J is hidden from the user, since the main concern was fixing several bugs with the function while maintaining backward compatibilityHowever, as the above example shows, it can be usefulThe second parameter is named I for legacy reasons, but it would be better named X with the J parameter named IConsider this change when updating manuals.
+
== History==
 +
To improve consistency with [[Integrate]] and [[Normalize]], and improve clarity, the names of the parameters to [[Area]] were changed in Analytica 4.2Previously the parameters were: [[Area]](r, i, x1, x2, j)Models that utilized named parameters will thus encounter a syntax error when loaded into 4.2We believe this will occur extremely rarely.
  
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.:
+
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.
var dens := Pdf(Ch1);
 
Area( dens, dens.Step, X2:x )
 
  
= See Also =
+
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.:
 +
:<code>Var dens := Pdf(Ch1);</code>
 +
:<code>Area(dens, dens.Step, X2: x)</code>
  
 +
== See Also ==
 
* [[Integrate]]
 
* [[Integrate]]
 +
* [[Normalize]]
 +
* [[Gauss_Quadrature_Pts]] (for Gauss-Legendre Quadrature)
 +
* [[Array-reducing functions]]
 +
* [[:Category:Integration (Quadrature) functions]]

Latest revision as of 22:15, 3 July 2024


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

Comments


You are not allowed to post comments.