% % 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 ]; qj = qj(:); pj = [ 0.2 0.2 0.1 0.1 0.1 0.1 0.1 0.1 ]; pj = pj(:); N = length(qj); x0 = ones(1,N-1)/N; wj = fminsearch( @(x) max_adj_return_fn(x,pj,qj), x0 ); wj = wj(:); % compute the first N-1 logistic mapped log weights and then the Nth one from all the N-1 others: % lwj = exp( wj )/( 1 + sum(exp(wj)) ); lwj = [ lwj; 1-sum(lwj) ]; lwj % print them wj = lwj; % compute the mean and standard deviation: % m = sum( pj .* wj .* ( qj + 1 ) ) - 1 uncer = sqrt( sum( pj .* ( wj .* ( qj + 1 ) - 1 - m ).^2 ) )