expectation(var_prob)

import linguistics.probability-1

Calculate the expectation (weighted average of random variables).

import linguistics.probability-1;
expectation([ 2, 0.5; // first variable-probability pair 1, 0.4 // second variable-probability pair ])
var_probA list of variable-probability pairs.
return valueThe expectation of the given variable-probability pairs.

The function takes a list of variable-probability pairs, and returns the expectation.

The var_prob argument of the function should have the form [variable, probability; variable, probability], where variable-probability pairs are separated by semicolons, and the variable is separated from the probability of its occurrence by a comma.