Difference between revisions of "Array Abstraction"
(scalar abstractior) |
|||
Line 13: | Line 13: | ||
* Representational Power: Any simple scalar function becomes a powerful array function when abstracted. | * Representational Power: Any simple scalar function becomes a powerful array function when abstracted. | ||
* Synergy with probabilistic inference: [[Monte Carlo method|Monte Carlo]] and [[Latin hypercube sampling|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. | * Synergy with probabilistic inference: [[Monte Carlo method|Monte Carlo]] and [[Latin hypercube sampling|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 <code>[[Sqrt]](x)</code> computes the square root of <code>x</code>. 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. | ||
+ | |||
+ | <code> | ||
+ | {| border="0" | ||
+ | |A := | ||
+ | | | ||
+ | {| border="1" | ||
+ | ! !! colspan="3" | I → | ||
+ | |- | ||
+ | ! J ↓ !! 1 !! 2 !! 3 | ||
+ | |- | ||
+ | ! 1 || 9 || 16 || 4 | ||
+ | |- | ||
+ | ! 2 || 49 || 36 || 25 | ||
+ | |} | ||
+ | | width="30px" | | ||
+ | | [[Sqrt]](A) → | ||
+ | | | ||
+ | {| border="1" | ||
+ | ! !! colspan="3" | I → | ||
+ | |- | ||
+ | ! J ↓ !! 1 !! 2 !! 3 | ||
+ | |- | ||
+ | ! 1 || 3 || 4 || 2 | ||
+ | |- | ||
+ | ! 2 || 7 || 6 || 5 | ||
+ | |} | ||
+ | |} | ||
+ | </code> | ||
+ | |||
= See Also = | = See Also = |
Revision as of 00:38, 23 August 2015
(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
See Also
Comments
Enable comment auto-refresher