% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; clc; clear; addpath('~/Matlab'); % Lets plot the exact profit value function: % npts_delta = 200; deltas = linspace( 0, 2.0, npts_delta ); pf = deltas .* ( 1 - normcdf(deltas) ); figure; plot( deltas, pf, '-o' ); hold on; [dum,ind_max] = max( pf ); vline( deltas(ind_max) ) ; title('White Noise Threshold Design'); xlabel('Amount of Sigma away from the Mean'); ylabel('Profit Value'); if( 1 ) saveas( gcf, '../../WriteUp/Graphics/Chapter7/pure_white_noise_band_design', 'eps' ); end % Next lets perform the white noise simulation from the book: % npts = 5000; npts = 75; % much smaller sample size spread_t = randn(npts,1); prob_as_function_of_delta = []; for di=1:npts_delta, d = deltas(di); inds_above = find(spread_t >= d); inds_below = find(spread_t <= -d); count = 0.5*(length(inds_above)+length(inds_below)); % a count of the number of times we exceed the threshold in either direction prob_est = count / npts; prob_as_function_of_delta = [prob_as_function_of_delta,prob_est]; end figure; plot( deltas, prob_as_function_of_delta, '-o' ); title(['Probability Estimates from Counts: ',num2str(npts),' samples']); xlabel('Amount of Sigma away from the Mean'); ylabel('Probability'); if( 1 ) saveas( gcf, '../../WriteUp/Graphics/Chapter7/prob_estimates_from_counts', 'eps' ); end figure; pf = deltas .* prob_as_function_of_delta; plot( deltas, pf, '-o' ); hold on; [dum,ind_max] = max(pf); vline( deltas(ind_max) ); title(['Profitability of Thresholds: ',num2str(npts),' samples']); xlabel('Amount of Sigma away from the Mean'); ylabel('Profit Value'); if( 1 ) saveas( gcf, '../../WriteUp/Graphics/Chapter7/profitabilty_thresholds', 'eps' ); end