Difference between revisions of "INF, NAN, and Null"

Line 4: Line 4:
 
These are special values that Analytica returns in special conditions:
 
These are special values that Analytica returns in special conditions:
  
:'''Inf''' means infinity or a real number larger than can be
+
:'''Inf''' means infinity -- e.g., 1/0 -- or a real number larger than can be represented -- e.g. 1E307 * 100, because the maximum number it can handle is 1.796E308.
represented -- e.g., 1/0 or 1.797E307 * 10  (because it can't represent numbers larger than 1.796E308)
+
:'''-Inf''' rmeans negative infinity -- e.g., -1/0 -- or a number smaller than can be represented
:'''-Inf''' rmeans negative infinity or a number smaller than can be
 
represented, e.g., -1/0
 
 
:'''NAN''' means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g., [[Sqrt]](-1) or 0/0
 
:'''NAN''' means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g., [[Sqrt]](-1) or 0/0
:'''Null''' means that there is no such item. [[Slice]], [[Subscript]], [[SubIndex]], or [[MdTable]] return Null, for example, when trying to Slice out the nth slice over an Index with less than n values.
+
:'''Null''' means that there is no such value. [[Slice]], [[Subscript]], [[SubIndex]], or [[MdTable]] return Null, for example, when trying to Slice out the nth slice over an Index with less than n values.
:'''Undefined''' means that a value has never been defined or is uncomputed -- for example, the value of an optional parameter not provided to a function.
 
  
 
=== Computations with special values ===
 
=== Computations with special values ===

Revision as of 14:49, 16 June 2010


These are special values that Analytica returns in special conditions:

Inf means infinity -- e.g., 1/0 -- or a real number larger than can be represented -- e.g. 1E307 * 100, because the maximum number it can handle is 1.796E308.
-Inf rmeans negative infinity -- e.g., -1/0 -- or a number smaller than can be represented
NAN means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g., Sqrt(-1) or 0/0
Null means that there is no such value. Slice, Subscript, SubIndex, or MdTable return Null, for example, when trying to Slice out the nth slice over an Index with less than n values.

Computations with special values

Analytica follows ANSI (Association of National Standards Institutes) standards for computing with these special values, where applicable.

1/Inf → 0
1/(-Inf) → 0
Inf + Inf → Inf
Inf - Inf → NAN

When NULL appears in scalar operations, it generally produces a warning and evaluates to NULL, for example:

10 + NULL → NULL
NULL - 10 → NULL
1 AND NULL → NULL

When NULL appears in an array operation, the result should be ignored. The common array reduction functions in Analytica 4.1 tend to support this as of release 4.1, but not prior to that, and not all array function support this. These examples demonstrate (assume A is indexed by I as indicated).

I: 1 2 3 4 5
A: 8 NULL 4 NULL 0
Sum(A,I) → 12
Average(A,I) → 4
Join(A,I,',') → "8,4,0"

In Analytica 4.1, these array functions ignore Null: Sum, Min, Max, ArgMin, ArgMax, Product, Average, JoinText, Irr, Npv. Also Regression ignores data points which have Y=Null.

Array functions Sum, Min and Max also accept an optional parameter IgnoreNaN to ignore NaN values (otherwise they tend to be propagated).

Comments


You are not allowed to post comments.