Array Abstraction


(in-progress)

Array abstraction is one of the most powerful features in Analytica. Although conceptually simple, Analytica modelers find that their mastery of array abstraction continues to improve over the course of years. Array abstraction provides many benefits:

  • Flexibility: Easy to alter an index, e.g., adding or deleting elements.
  • Hyper-flexibility: Easy to adjust the dimensionality of a model, even late in the modeling process.
  • Direct what-if analysis and parametric analysis.
  • Simplifies expressions, which increases transparency
  • Reduces the cognitive load of the modeler, with dramatic productivity gains during model creation.
  • Speed - Analytica is an array-based semi-interpreted language, but array operations, the bulk of the computation, occur in "native code".
  • Representational Power: Any simple scalar function becomes a powerful array function when abstracted.
  • Synergy with probabilistic inference: Monte Carlo and Latin hypercube simulation are accomplished in Analytica through array abstraction. The Run index (i.e., the simulation index), is just another dimension, and the propagation of uncertainties through the model is an instance of array abstraction at work.

Array abstraction of a scalar function

The function Sqrt(x) computes the square root of «x». When you supply an array as a parameter, array abstraction iterates the function over all elements of the array and returns an array with the same dimensionality as the original.

A :=
I →
J ↓ 1 2 3
1 9 16 4
2 49 36 25
  Sqrt(A) →
I →
J ↓ 1 2 3
1 3 4 2
2 7 6 5


Sqrt is an example of a scalar function with one parameter. We say that it treats its parameter as atomic, or it treats its parameter as an atom.

Parameters have same indexes

The plus operator treats both its parameters as atoms. If both values supplied to the parameters have the same dimensionality, then array abstraction iterates over each index combination, producing an array result with the same dimensionality as the parameters.

Variable B := Sqrt(A)

A + B →
I →
J ↓ 1 2 3
1 12 20 6
2 56 42 30


An array parameter with a scalar parameter

The Mod(x,y) function returns the remainder of dividing «x» by «y». It treats both parameters as atoms. When one parameter is an array and the other is scalar, array abstraction iterates over each cell of the array and applies the function using the same scalar value.

Mod(A,5) →
I →
J ↓ 1 2 3
1 4 1 4
2 4 1 0
=
I →
J ↓ 1 2 3
1 Mod(9,5) Mod(16,5) Mod(4,5)
2 Mod(49,5) Mod(36,5) Mod(25,5)

See Also

Comments


You are not allowed to post comments.