INF, NAN, and Null

(Redirected from «null»)

Inf, NAN, and Null are special values, which can be very useful. Analytica returns them under conditions when it can't return a number. You can also type them directly into an expression or Edit table.

Inf means infinity, and is the result of dividing a positive number by zero -- e.g.,

1/0 → Inf

or computing a number larger than 1.796E308 (the largest number that your computer can represent in 64 bits) -- e.g.

1E307 * 100 → Inf

-Inf means negative infinity, the result of dividing a negative number by zero (or a number less than -1.796E308) -- e.g.

-1/0 → -Inf

NAN means "Not A Number". It is the result of a calculation that is not a well-defined number nor infinity -- e.g.

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

(If you enable Complex Numbers, Sqrt(-1) returns the valid imaginary number, 1j.)

Null means that there is no such value. For example, Subscript returns Null if the indexing value doesn't match a value of the Index:

Index Year := [2015, 2016, 2017]
Slice(Year, 4) → NULL
Variable X := Array(Year, [20, 23, 28])
X[Year = 2018] → NULL

You can also specify a different default result for an index value that doesn't match the index:

X[Year = 2018, defValue: 0] → 0

More on INF and NAN

Calculations using INF and NAN follow ANSI (Association of National Standards Institutes) recommendations, which follow the laws of mathematics as far as possible:

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

Expressions taking NAN as an operand or parameter give NAN as their result unless the expression has a well-defined logical or numerical value for any value of NAN:

True OR NAN → True
NaN AND False → False

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

Sum, Min, Max, ArgMax, JoinText, Npv, and other Array-reducing functions ignore Null. For example:

Variable A :=
I ▶
1 2 3 4 5
Sum(A, I) → 12
Average(A, I) → 4
JoinText(A, I, ', ') → "8, 4, 0"

Graphs also ignore (do not show) any point whose value is Null.

Some Array-reducing functions, notably 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.

See Also


You are not allowed to post comments.