% % Written by: % -- % John L. Weatherwax 2006-12-31 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clc; close all; clear; qj = [ 5 6 1 1 2 2 2 2 ]; pj = [ 0.2 0.2 0.1 0.1 0.1 0.1 0.1 0.1 ]; N = length(qj); % Note: see the codes "max_adj_return*.m" for perhaps a better way to do use MATLAB's unbounded optimization routine wj = fminsearch( @(x) min_std_dev_fn(x,pj,qj), (1/N)*ones(1,N-1) ); % "create" the probabilty we must assign to the last horse: wj = [ wj(:); 1-sum(wj) ]; wj = wj(:)'; wj % compute the mean and standard deviation: % m = sum( pj .* wj .* ( qj + 1 ) ) - 1 uncer = sqrt( sum( pj .* ( wj .* ( qj + 1 ) - 1 - m ).^2 ) )