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

m (Psanford moved page INF, NAN, Null, and Undefined to INF, NAN, and Null: Remove "Undefined" from the title)
m
Line 2: Line 2:
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
   
 
   
These are special values that Analytica returns in special conditions:
+
These are special values that Analytica returns in particular conditions. You can also use them in expressions:
  
:'''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''' means infinity -- e.g.,  
:'''-Inf''' rmeans negative infinity -- e.g., -1/0 -- or a number smaller than can be represented
+
:1/0 &rarr; Inf
:'''NAN''' means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g., [[Sqrt]](-1) or 0/0
+
or a number larger than 1.796E308 (due to computer limitations) -- e.g.  
:'''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.
+
:1E307 * 100 &rarr; Inf
 +
'''-Inf''' means negative infinity -- e.g.,  
 +
:-1/0 &rarr; -Inf
 +
or a number less than 1.796E308
 +
'''NAN''' means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g.
 +
:0/0 &rarr; NAN
 +
:Sqrt(-1) &rarr; NAN
 +
except if you enable [[Complex numbers]], in which case this will return a valid imaginary number, 1j.
  
=== Computations with special values ===
+
'''Null''' means that there is no such value. For example, [[Slice]], [[Subscript]], [[SubIndex]], or [[MdTable]] return if you try to Slice out the nth slice over an Index with less than n values.
 +
 
 +
=== More on INF and NAN ===
  
 
Analytica follows ANSI (Association of National Standards Institutes) standards for computing with these special values, where applicable.  
 
Analytica follows ANSI (Association of National Standards Institutes) standards for computing with these special values, where applicable.  
 
 
:1/Inf &rarr; 0
 
:1/Inf &rarr; 0
 
:1/(-Inf) &rarr; 0
 
:1/(-Inf) &rarr; 0
 
:Inf + Inf &rarr; Inf
 
:Inf + Inf &rarr; Inf
 
:Inf - Inf &rarr; NAN
 
:Inf - Inf &rarr; NAN
 +
 +
=== More on NULL ===
  
 
When NULL appears in scalar operations, it generally produces a warning and evaluates to NULL, for example:
 
When NULL appears in scalar operations, it generally produces a warning and evaluates to NULL, for example:
Line 23: Line 33:
 
:1 AND NULL &rarr; NULL
 
:1 AND NULL &rarr; 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).
+
Array-reducing functions ignore NULL.  These examples demonstrate (assume A is indexed by I as indicated).
 
:{|border="1"
 
:{|border="1"
 
! I: !! 1 !! 2 !! 3 !! 4 !! 5
 
! I: !! 1 !! 2 !! 3 !! 4 !! 5
Line 30: Line 40:
 
|}
 
|}
  
:[[Sum]](A,I) &rarr; 12
+
:[[Sum]](A, I) &rarr; 12
:[[Average]](A,I) &rarr; 4     
+
:[[Average]](A, I) &rarr; 4     
:[[Join]](A,I,',') &rarr; "8,4,0"
+
:[[JoinText]](A, I, ', ') &rarr; "8, 4, 0"
 +
 
 +
Graphs will simply ignore (not show) any point whose value is NULL.
  
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-reducing functions include [[Sum]], [[Min]], [[Max]], [[ArgMin]], [[ArgMax]], [[Product]], [[Average]], [[JoinText]], [[Irr]], [[Npv]].   
 +
Array functions [[Sum]], [[Min]] and [[Max]] also accept an optional parameter ''IgnoreNaN'' to ignore NaN values (which otherwise propagate, i.e. return NaN).
  
Array functions [[Sum]], [[Min]] and [[Max]] also accept an optional parameter ''IgnoreNaN'' to ignore NaN values (otherwise they tend to be propagated).
+
[[Regression]] also ignores any data points which have Y=Null, which is useful for missing data.

Revision as of 17:58, 28 January 2015


These are special values that Analytica returns in particular conditions. You can also use them in expressions:

Inf means infinity -- e.g.,

1/0 → Inf

or a number larger than 1.796E308 (due to computer limitations) -- e.g.

1E307 * 100 → Inf

-Inf means negative infinity -- e.g.,

-1/0 → -Inf

or a number less than 1.796E308 NAN means "Not A Number", where the result is numeric, but not a real number or infinity -- e.g.

0/0 → NAN
Sqrt(-1) → NAN

except if you enable Complex numbers, in which case this will return a valid imaginary number, 1j.

Null means that there is no such value. For example, Slice, Subscript, SubIndex, or MdTable return if you try to Slice out the nth slice over an Index with less than n values.

More on INF and NAN

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

More on NULL

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

Array-reducing functions ignore NULL. 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
JoinText(A, I, ', ') → "8, 4, 0"

Graphs will simply ignore (not show) any point whose value is NULL.

Array-reducing functions include Sum, Min, Max, ArgMin, ArgMax, Product, Average, JoinText, Irr, Npv. Array functions Sum, Min and Max also accept an optional parameter IgnoreNaN to ignore NaN values (which otherwise propagate, i.e. return NaN).

Regression also ignores any data points which have Y=Null, which is useful for missing data.

Comments


You are not allowed to post comments.