WebCab Probability and Statistics Web Services for .NET v3.3 Demo

RandomVariables.GetProbabilityOfRandomVariable Method 

Retrieves the values of the probability distribution associated with a (discrete) random variable within a given position within the table of random variables which have been set.

public double[] GetProbabilityOfRandomVariable(
   int index
);

Parameters

index
The position of the random variable within the table (or collection) of random variables for which return the values of the probabilities of the different events.

Remarks

In particular, this method returns an array where the first term corresponds to the probability of the 1st possible outcome of the random variable, the 2nd term to the probability of the 2nd possible outcome and so on. For further details, concerning how the table of random variables is set please see the notes within the XML Web service overview or the notes given below.

Example and Further Explanation

Recall that a (discrete) random variable describes the number of times a given outcome (or event) occurs from a given experiment. In particular, in can be viewed as a function f, which maps the possible outcomes to the number of occurrences of that outcome during the experiment considered. Say for example we are considering an experiment of counting the ages of children within a nursery. All the children's ages (in years) take one of five values: namely 1, 2, 3, 4, 5, and for the entire nursery the number of children of each age was found to be: 28, 30, 26, 32, 30; respectively.

The random variable of this experiment which we denote by f, mapping the ages of the children to the number of children in the nursery of that age, is given by:

  1. f(1) = 28
  2. f(2) = 30
  3. f(3) = 26
  4. f(4) = 32
  5. f(5) = 30

Now the associated (discrete) probability distribution p, for these results which gives the probability of a child randomly selected from the nursery take a given age is:

  1. p(1) = 28 / (28+30+26+32+30)
  2. p(2) = 30 / (28+30+26+32+30)
  3. p(3) = 26 / (28+30+26+32+30)
  4. p(4) = 32 / (28+30+26+32+30)
  5. p(5) = 30 / (28+30+26+32+30)

These values corresponding to the probability distribution associated with the random variable describing the experiment being considered are evaluated and returned by this method as an array where the k-th term of the array corresponds to probability of the k-th outcome of the experiment occurring. In the example given above we have the following correspondence:

  1. The Child is 1 years old: Number of occurrences = 28 (i.e. f(1), which corresponds to a probability, that is the value of the probability distribution p(1), equal to 28 / (28+30+26+32+30), which is also the first term of the array returned.
  2. The Child is 2 years old: Number of occurrences = 30 (i.e. f(2), which a corresponding probability distribution value p(2), equal to 30 / (28+30+26+32+30) and so on...

Hence, the array returned (in the notion used above) in the examples of the nursery is {p(1), p(2), p(3), p(4), p(5)}.

Setting the Random Variables Table

In order to apply this method to the study of random variables you will first need to set the random variables within the internal table (i.e. an ordered collection of random variables) by using one or more of the following:

  1. AddRandomVariable - Adjoins a random variables to the internal table (or collection) of random variables.
  2. (int, double[], double[]) - Inserts a random variable into the ith position within the random variable table.

Note: If one of the random variables is either incorrectly set or is no longer in use then it can be removed from the table using (int).

See Also

RandomVariables Class | DiscreteProbability Namespace