Defining Chance Events (DPL Code)

The following statement defines a chance event in DPL.

chance Research_Time.{Short,Medium,Long} = {0.3,0.5};

The first word, chance, is a keyword that identifies this definition as a chance event. The name of this chance event is Research_Time, and the names of its outcomes (states) are Short, Medium, and Long. In a DPL program you refer to these outcomes as Research_Time.Short, Research_Time.Medium, and Research_Time.Long. The probabilities associated with these outcomes appear between braces to the right of the = sign. In DPL, you may omit the probability of the last outcome. DPL calculates the last probability by adding the others and subtracting the sum from 1.0. Of course, if you prefer, you can enter probabilities for all outcomes. (This is allowed only if all probabilities are specified as constant expressions.) If any of the probabilities (including the last one) do not lie in the range from 0.0 to 1.0, or if the sum of the probabilities is not 1.0, the DPL compiler generates an error message.

If you wish to associate value expressions with the states of a chance event, enter them after the probability distributions. A chance event with both probabilities and values assigned to its states is sometimes called a random variable.

chance Research_Time.{Short,Medium,Long} =
   {0.3,0.5} =
   1, 5, 10; //in months

(Defining these value expressions does not imply that they are automatically received or paid when the event is resolved. You must specify this in the sequence section.)

You can use expressions instead of numeric constants to specify the probabilities associated with the outcomes of a chance event. For example, if P is a value defined earlier in the program, you could change the definition of the chance event called Research_Time as follows.

chance Research_Time.{Short,Medium,Long} = {(1-P)/2,P};

When DPL needs to calculate the probabilities associated with Research_Time, it determines the value P and substitutes it in the expressions above. You must make sure that all of the probabilities produced by these expressions lie in the interval from 0.0 to 1.0. Otherwise, DPL will generate an error message.

The expressions that define probabilities cannot include the state function, which returns an ordinal number corresponding to the state of an event.

Chance events may be drawn from named distributions. To do so, do not enter probabilities and value expressions. Instead, use the distribution name and enter value expressions for the parameters.

chance A.{High, Medium, Low} = beta(1,2);

If the probabilities or values associated with a chance event depend on the states of other events, you include this information in the chance event's definition. The events upon which the probabilities depend are called conditioning events. You must define the conditioning events before you define a chance event that depends on them. You must provide probability distributions and value expressions for each combination of conditioning event states.

For example, the following statement defines a chance event that depends on a decision called Research_Funding and a chance event called Research_Time, both defined earlier. Both Research_Funding and Research_Time are conditioning events.

chance Research_Cost.{Low,Moderate,Outrageous}
   given Research_Funding,Research_Time =
                //Research_Funding   Research_Time
{0.6,0.2},      //Low                Short
{0.4,0.3},      //Low                Medium
{0.2,0.4},      //Low                Long
{0.4,0.3},      //Medium             Short
{0.4,0.3},      //Medium             Medium
{0.2,0.4},      //Medium             Long
{0.2,0.4},      //High               Short
{0.2,0.4},      //High               Medium
{0.1,0.4};      //High               Long
=
40,  50,  80,   //Low                Short
45,  60,  85,   //Low                Medium
40,  60,  80,   //Low                Long
50,  95, 110,   //Medium             Short
80, 100, 125,   //Medium             Medium
85, 105, 130,   //Medium             Long
90, 105, 130,   //High               Short
95, 120, 140,   //High               Medium
95, 140, 160;   //High               Long

This statement defines nine sets of probabilities, one for each combination of the conditioning events' states (Research_Funding, and Research_Time). The order in which you specify the probabilities depends on the order in which you list the conditioning events after the keyword given. (You can substitute a vertical bar | for the keyword given.) DPL uses the first set of probabilities when all conditioning events are their first state. The next set of probabilities applies when the last conditioning event in the list changes to its second state. After associating sets of probabilities with all the states of the last conditioning event DPL varies the states of the next-to-last conditioning event and so on. This continues until probabilities are associated with all combinations of states. This method for determining the order of the various combinations of states is sometimes called row major order or the odometer principle. This means that the states of the last event vary most rapidly. The same applies for the values.

The comments in the earlier statement show the states of the conditioning events. These comments are ignored by DPL, and they do not determine the order in which you specify the probabilities.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also

The Definition Section