Gamble Objects

Gamble objects are a special type of categorical distribution which contain a $n \times 1$ vector of possible outcomes and a corresponding $n \times 1$ vector of outcome probabilities. The fields are

  • v: a vector of outcome values
  • p: a vector of outcome probabilities

Example

In this section, we will illustrate how to create a gamble object and how to use various methods with the gamble objects, such as computing expected values.

Load Packages

The first step is to load the required packages.

using Random
using UtilityModels
Random.seed!(9854)
Random.TaskLocalRNG()

Create a Gamble Object

The code block below illustrates how to construct a gamble object for the gamble $\mathbf{G} = (58, .20; 56, .20; 2, .60)$.

gamble = Gamble(;
    p = [.20, .20, .60],
    v = [58, 56, 2]
)
             Gamble
┌───────────┬───────────────────┐
│ Parameter │ Value             │
├───────────┼───────────────────┤
│ p         │ [0.2, 0.2, 0.6]   │
│ v         │ [58.0, 56.0, 2.0] │
└───────────┴───────────────────┘

Note that the package can handle choices between an arbitrary number of options, each with an arbitrary number of outcomes.

Expected Value

The expected value can be computed as follows:

mean(gamble)
24.0

Standard Deviation

The standard deviation can be computed as follows:

std(gamble)
26.951808844676826

Sample Random Outcome

You can sample a random outcome from the gamble distribution with rand. Here is an example:

rand(gamble)
2.0