Default ... Case Notation (DPL Code)

# Default ... Case Notation (DPL Code)

DPL provides another way to specify the probabilities for a chance event that depends on other events. This approach can simplify the task of specifying the probabilities when the conditioning events have many combinations of states.

Errors in associating probabilities with conditioning event states are easy to make and cannot be detected by the compiler. This method of specification can help reduce errors when there are many probability distributions because you are explicitly identifying the distribution being initialized.

For example, rather than specifying each probability distribution individually:

chance A.{S1, S2, S3, S4} = {.1, .2, .3};
chance B.{Lo, Nom, Hi} | A =
{.1, .8}, {.1, .8}, {.1, .8}, {.5, .2};

you can define a default distribution and then define only the exceptions.

chance A.{S1, S2, S3, S4} = {.1, .2, .3};
chance B.{Lo, Nom, Hi} | A =
default: {.1, .8},
case A.S4: {.5, .2};

The keyword default specifies a set of probabilities for all combinations of conditioning event states. The keyword case substitutes another set of probabilities for certain combinations of conditioning event states. You indicate which combinations are affected immediately following the keyword.

If there are multiple conditioning events, you can use logical OR (||) and logical AND (&&) to specify combinations of events for the cases. For example, the following definition for the chance event called Research_Cost is equivalent to the ones above.

chance Research_Cost.{Low,Moderate,Outrageous} given
Research_Funding,Research_Time =
default: {0.2,0.4},
case (Research_Funding.Low || Research_Funding.Medium)
&& (Research_Time.Short || Research_Time.Medium):
{0.4,0.3},
case Research_Funding.Low && Research_Time.Short:
{0.6,0.2},
case Research_Funding.High && Research_Time.Long:
{0.1,0.4};

In the example above, the default clause sets the outcome probabilities to 0.2, 0.4, and 0.4 for all conditioning event states. The first case clause changes the outcome probabilities to 0.4, 0.3, and 0.3 when the state of Research_Funding is Low or Medium and the state of Research_Time is Short or Medium. Each succeeding case clause overrides some of the previous assignments. Usually you should start with case clauses that reference many combinations of conditioning event states and end with case clauses that only refer to a few.

As with the probability distributions in chance event definitions, you can save time and effort in a value definition by defining one value as the default for the value and identifying particular cases for other definitions.

chance BaseYearGNP = {.3} = 1.1, 1.3;
value GNP given BaseYearGNP, TaxRate, MoneySupply =
default:
BaseYearGNP * Inflation_Factor,
case BaseYearGNP.S1:
case TaxRate.Increased:
BaseYearGNP * Inflation_Factor *
(1 - IdleCapacityRate),
case TaxRate.Increased && MoneySupply.Lower:
BaseYearGNP * Inflation_Factor *
(1 - 2 * IdleCapacityRate);

The default clause refers to the value BaseYearGNP, whereas the first case clause refers to the chance event. DPL can tell them apart by the context in which the name appears. The number represented by GNP depends on the events TaxRate and MoneySupply both directly and indirectly. The states of these events determine the expression used to evaluate GNP. They also determine the value called Inflation_Factor, which appears as a term in expressions for GNP.

You can use the default...case notation with a combined definition:

chance Research_Cost.{Low,Moderate,Outrageous}
given Research_Funding,Research_Time =
default: {0.2,0.4},
case (Research_Funding.Low || Research_Funding.Medium)
&& (Research_Time.Short || Research_Time.Medium):
{0.4,0.3},
case Research_Funding.Low && Research_Time.Short:
{0.6,0.2},
case Research_Funding.High && Research_Time.Long:
{0.1,0.4};
= case Research_Cost.Low: 80,
case Research_Cost.Moderate: 100,
case Research_Cost.Outrageous: 125;

Versions: DPL Professional, DPL Enterprise, DPL Portfolio