intprb_muvstepstart — Returns the starting values for the step-by-step (mean,variance) computation.
[ n , mu , v ] = intprb_muvstepstart ( )
a 1 x 1 matrix of floating point integersthe starting value of the number of values
a 1 x 1 matrix of doubles, the starting value of the mean
a 1 x 1 matrix of doubles, the starting value of the sample variance, as the sum of squares divided by with n-1
This routine is used in an algorithm which uses the step-by-step variance computation. It is designed to be used with intprb_muvstepupdate and intprb_muvstepstop. This function is useful in Monte-Carlo algorithms which do not keep track of all the function values, but only keep the last function value and update the mean and the variance dynamically.
// Compare our algorithm with the functions (mean,variance) x = 1 : 10 [ n , mu , v ] = intprb_muvstepstart ( ); for i = 1 : 10 [ n , mu , v ] = intprb_muvstepupdate ( n , mu , v , x(i) ); end [ n , mu , v ] = intprb_muvstepstop ( n , mu , v ); disp( [mean(x) mu ] ) disp( [variance(x) v ] )