Difference between revisions of "Area"

(Some 4.2 changes)
Line 2: Line 2:
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[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 =
 
  Area( R : Numeric[J] ; I : ascending Numeric[J] ; X1,X2 : opt numeric atomic ; J : opt hidden IndexType = I )
 
  
 
= Simplest Usage =
 
= Simplest Usage =
  
In the simple usage, the second parameter, I, is an index with increasing numeric values, and R is indexed by I.  You 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.
+
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 I =
+
= Using an array for «x» =
  
 
(new to 4.0).
 
(new to 4.0).
When your X-axis values are in an array, e.g., X and Y are both arrays indexed by In1, you can use:
+
When your X-axis values are in an array, e.g., ''x_val'' and ''y_val'' are both arrays indexed by ''In1'', and you want the area from <code>lb&le;x_val&le;ub</code>, you can use:
  Area( Y,X,X1,X2,In1 )
+
  Area( y_val,x_val,lb,ub,In1 )
  
Here the x-axis values are taken from the X-array rather than from the index.  If X1 and X2 are omitted, you can write
+
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( R:Y,I:X,J:In1 )
+
  Area( y,x,i:In1 )
 
or equivalently
 
or equivalently
  Area( Y,X, J:In1 )
+
  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. 
  
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.
+
See the wiki page for [[Integrate]] for more details on both these points.
  
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.
+
= Changes with Releases =
  
= Details =
+
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.
  
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 useful. The second parameter is named I for legacy reasons, but it would be better named X with the J parameter named I.  Consider this change when updating manuals.
+
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.:
+
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);
+
  [[Var]] dens := [[Pdf]](Ch1);
  Area( dens, dens.Step, X2:x )
+
  [[Area]]( dens, dens.Step, X2:x )
  
 
= See Also =  
 
= See Also =  

Revision as of 20:30, 13 September 2009


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.

Simplest Usage

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»

(new to 4.0). When your X-axis values are in an array, e.g., x_val and y_val are both arrays indexed by In1, 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.

Changes with Releases

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.