Difference between revisions of "Evaluation modes"

m (Mhenrion moved page Evaluation Modes to Evaluation modes: only the first letter of a title shd be capitalized)
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[category:Concepts]]
+
[[Category:Evaluation]]
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
+
[[Category:Distribution_Functions|Distribution Function]]
 +
[[Category:Doc_Status_D]] <!-- For Lumina use, do not change -->
 
   
 
   
(in progress)
+
All variables have a '''Mid'''' or deterministic value, computed in "Mid mode".  Some also have a '"Prob"' or probabilistic value, computed in "Prob mode":
Every validly defined variable or expression, x, in Analytica has a '''Mid value''' , also known as its "deterministic" value. Analytica computes the Mid value by fixing any probability distribution in the definition of x, and in any of its predecessor variables, at its '''Mid''' values, usually the median of the distribution. The Mid value provides fast evaluation, ignoring any uncertaintiesAny probability distribution returns a single value, usually the median, when evaluated in Mid mode. (A multivariate distribution returns an array of Mid values.)
+
* The '''Mid''' value is a deterministic value that ignores any uncertainties, shown when computed in "Mid mode". It uses the [[median]] of any probability distribution in a Definition, and the "Mid value" of any variable or function on which it depends.   The [[Mid]] value is often close to the [[Median]], but it is not guaranteed, to be equal because <code>Median(F(x, y))</code> is not always the same as <code>F(Median(x), Median(y))</code>By default, when you first ask for a Result -- e.g. to view a Table or Graph -- it first computes and shows the Mid value. A Mid value is much faster to compute for a large model, since it uses only a single value for each distribution rather than a random sample of numbers.
  
Any variable or expression that contains a probability distribution, or that has one or more predecessor variables containing a probability distribution, also has a '''Prob value''', also known as a '''probabilistic''' or '''sample''' value. The Prob value is a random sample from the probability distribution for the variable. The sample is indexed by the system index Run -- numbered from 1 to Samplesize. Samplesize is the number of samples set in the '''Uncertainty''' dialog box (available from '''Result''' menu).   
+
* The '''Prob''' (probabilistic) value is a random sample of values from a probability distribution. Prob values are computed in '''Sample evaluation mode'''. Any probability distribution in a definition -- e.g. <code>Normal(10, 5)</code> -- is evaluated as a random sample using [[Monte Carlo]] or another [[sampling method]]. Each sample is an array indexed by the system index [[Run]] -- numbered from 1 to [[SampleSize]]. A Prob value for a variable or function uses the Prob value of any uncertain Variable or Function on which it depends.  When you select an [[Uncertainty view]] (other than "Mid") from the pulldown menu of a [[Result window]], it computes its "Prob value" and displays it as a Mean, Statistics, Probability Bands, PDF, or whichever option you select.   
  
You control the evaluation mode when viewing a Result -- Table or Graph -- by selecting the '''Uncertainty view''': If you select '''Mid''', it will evaluate the variable (and any of its predecessors if necessary) in Mid mode, and display the Mid value of the result. If you select another Uncertainty view (Mean, Stats, Bands, PDF or Prob Mass, CDF or Cum Prob, or Sample), it will try to evaluate the variable, and its predecessors, in Prob mode. If it can, it will display the resulting uncertain quantity using the uncertainty view you selected.  If neither the variable nor its predecessors contain any probability distribution, it will not have a Prob value. In this case, Analytica will give you a warning message, and show the Mid result.
+
If the variable has no "Prob value" because neither the variable nor any of its inputs contain a probability distribution, it gives a warning, and shows the Mid result. You can also select "Mid"  from the [[Uncertainty view of a result|Uncertainty view]]  to go back to see the [[Mid]] value (computing it if necessary). 
  
There are some subtleties to these two evalation modes, Mid and Prob: Any statistical Function -- such as [[Mean]], [[Sdeviation]], [[Correlation]] -- will usually evaluate its parameter(s), and any predecessors, in Prob mode, even if it appears in an expression being evaluated in Mid mode. A statistical function estimates its value from a Prob value (or two Prob values, in the case of Correlation, and related functions). If you define
+
The accuracy with which the "Prob value" represents the underlying probability distribution increases with [[SampleSize]]. It usually makes sense to start with a small number -- e.g. the default 1000. You can increase it later when you have verified the model is correct, in the [[Uncertainty Setup dialog]] (available from the [[Result menu]]).  
X := [[Mean]](Y)
 
Y := [[Normal]](2, 1)
 
If you evaluate x in Mid mode, the statistical function [[Mean]](y) will evaluate y in Prob mode. So, the Mid value of x will be an estimate of the mean of y, based on a Monte Carlo sample which is the Prob value of Y.  Thus, evaluating any variable containing a statistical function will cause a Prob mode evaluation of any variable appearing in its parameter(s), or predecessors of those variables.  The result of a statistical function is a Mid value, not a probability distribution. In the example above, X has a Mid value, equal to the mean of Y, but no Prob value.
 
  
Conversely, the function [[Mid]](X) always evaluates its parameter X in Mid mode, even when [[Mid]](X) is evaluated in Prob mode. For example
+
[[Statistical functions]] -- such as [[Mean]], [[Sdeviation]], [[Correlation]] -- expect their main parameter(s) to be uncertain and evaluate them, and their predecessors, in Prob mode, even if they appear in an expression being evaluated in Mid mode. A statistical function estimates its value from a Prob value (or two Prob values, in the case of [[Correlation]], and related functions). If you define
X := [[Mid]](Y)
 
Y := [[Uniform]](10, 20)
 
In this case, evaluating X, causes Y to be evaluated in Mid mode, returning the median of y (15).  
 
  
A [[category:Distribution Functions|Distribution Function]] is a function that returns a median value when evaluated in Mid-mode, and a sample array indexed by the [[Run]] Index when evaluated in Sample-mode.
+
:<code>X := Mean(Y)</code>
 +
:<code>Y := Normal(2, 1)</code>
 +
 
 +
If you evaluate «x» in Mid mode, the statistical function [[Mean]](y) will evaluate «y» in Prob mode. So, the Mid value of «x» will be an estimate of the mean of «y», based on a Monte Carlo sample which is the Prob value of <code>Y</code>. So, evaluating any variable containing a statistical function will cause a Prob mode evaluation of any variable appearing in its parameter(s), and any predecessors of those variables. The result of a statistical function is a Mid value, not a probability distribution. In the example above, <code>X</code> has a Mid value, equal to the mean of <code>Y</code>, but no Prob value.
 +
 
 +
Conversely, the function [[Mid]](X) always evaluates its parameter «X» in Mid mode, even when [[Mid]](X) is evaluated in Prob mode. For example
 +
 
 +
:<code>X := Mid(Y)</code>
 +
:<code>Y := Uniform(10, 20)</code>
 +
 
 +
In this case, evaluating <code>X</code>, causes <code>Y</code> to be evaluated in Mid mode, returning the median of <code>y</code> (15).  
 +
 
 +
==See Also==
 +
* [[Uncertainty views]]
 +
* [[Mid]]()
 +
* [[Sample]]
 +
* [[IsSampleEvalMode]]
 +
* [[Certain]]
 +
* [[Statistical Functions and Importance Weighting]]
 +
* [[Evaluate]]
 +
* [[Objects and Values]]

Latest revision as of 01:22, 26 November 2024


All variables have a Mid' or deterministic value, computed in "Mid mode". Some also have a '"Prob"' or probabilistic value, computed in "Prob mode":

  • The Mid value is a deterministic value that ignores any uncertainties, shown when computed in "Mid mode". It uses the median of any probability distribution in a Definition, and the "Mid value" of any variable or function on which it depends. The Mid value is often close to the Median, but it is not guaranteed, to be equal because Median(F(x, y)) is not always the same as F(Median(x), Median(y)). By default, when you first ask for a Result -- e.g. to view a Table or Graph -- it first computes and shows the Mid value. A Mid value is much faster to compute for a large model, since it uses only a single value for each distribution rather than a random sample of numbers.
  • The Prob (probabilistic) value is a random sample of values from a probability distribution. Prob values are computed in Sample evaluation mode. Any probability distribution in a definition -- e.g. Normal(10, 5) -- is evaluated as a random sample using Monte Carlo or another sampling method. Each sample is an array indexed by the system index Run -- numbered from 1 to SampleSize. A Prob value for a variable or function uses the Prob value of any uncertain Variable or Function on which it depends. When you select an Uncertainty view (other than "Mid") from the pulldown menu of a Result window, it computes its "Prob value" and displays it as a Mean, Statistics, Probability Bands, PDF, or whichever option you select.

If the variable has no "Prob value" because neither the variable nor any of its inputs contain a probability distribution, it gives a warning, and shows the Mid result. You can also select "Mid" from the Uncertainty view to go back to see the Mid value (computing it if necessary).

The accuracy with which the "Prob value" represents the underlying probability distribution increases with SampleSize. It usually makes sense to start with a small number -- e.g. the default 1000. You can increase it later when you have verified the model is correct, in the Uncertainty Setup dialog (available from the Result menu).

Statistical functions -- such as Mean, Sdeviation, Correlation -- expect their main parameter(s) to be uncertain and evaluate them, and their predecessors, in Prob mode, even if they appear in an expression being evaluated in Mid mode. A statistical function estimates its value from a Prob value (or two Prob values, in the case of Correlation, and related functions). If you define

X := Mean(Y)
Y := Normal(2, 1)

If you evaluate «x» in Mid mode, the statistical function Mean(y) will evaluate «y» in Prob mode. So, the Mid value of «x» will be an estimate of the mean of «y», based on a Monte Carlo sample which is the Prob value of Y. So, evaluating any variable containing a statistical function will cause a Prob mode evaluation of any variable appearing in its parameter(s), and any predecessors of those variables. The result of a statistical function is a Mid value, not a probability distribution. In the example above, X has a Mid value, equal to the mean of Y, but no Prob value.

Conversely, the function Mid(X) always evaluates its parameter «X» in Mid mode, even when Mid(X) is evaluated in Prob mode. For example

X := Mid(Y)
Y := Uniform(10, 20)

In this case, evaluating X, causes Y to be evaluated in Mid mode, returning the median of y (15).

See Also

Comments


You are not allowed to post comments.