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

RandomVariables.InsertRandomVariable Method 

Inserts a new (discrete) random variable into the internal random variable table at the indexth position.

public void InsertRandomVariable(
   int index,
   double[] values,
   int[] occurrences
);

Parameters

index
The position (or index) within the internal table of random variables where you wish to insert the random variable.
values
This is an array of doubles where each double corresponds to a value of an outcome recorded of the experiment considered.
occurrences
The i-th term of this array is the number of occurrences in which the experiment takes the value of the i-th term of the values array during the cause of the experiment.

Remarks

The table containing the random variables contains ``rows'' which correspond to each of the random variables. Now a random variable can be inserted into an arbitrary location of this table using this method or can be adjoined using the method AddRandomVariable.

Example

Say for example we have already set an internal table of 5 random variables by calling the method AddRandomVariable, and we wish to add another random variable to the table within the 3-rd position. Moreover, we wish to set a random variable R, given by:

  1. R(1) = 5, i.e. the outcome of 1, occurs 5 times during the experiment.
  2. R(2) = 3, i.e. the outcome of 2, occurs 3 times during the experiment.

In order to set this random variable within the table of random variables you will need to pass the following parameters: 3 for the index to specify the position within the table in which the random variables should be added, {1,2} to specify the possible values of the outcomes of the experiments and {5,3}, to specify the number of occurrences in which these outcomes occur during the experiment considered.

Recording the Values of the Random Variable

Note that though there is always an integer number of possible outcomes of the experiment which the random variable describes, it is important that the absolute values associated with these events is recorded. Since otherwise the information allowing the evaluation, for example of the mean and variance of the random variable will be lost.

See Also

RandomVariables Class | DiscreteProbability Namespace