function [breakpoint,smallest_summed_deviance,confidence]=change_point_analysis_deviance_method(input_data,bootstrap_runs,do_plotting) %this is modeled on o'connor, wittenberg and wang, 2005 %possible future additions include the consideration of a second candidate change point, to be identified at the same time as the first one, and bootstrap to obtain confidence intervals smallest_summed_deviance=sum((input_data-mean(input_data)).^2); breakpoint=0; for candidate_breakpoint=1:length(input_data)-1 summed_deviance=sum((input_data(1:candidate_breakpoint)-mean(input_data(1:candidate_breakpoint))).^2)... +sum((input_data((candidate_breakpoint+1):end)-mean(input_data((candidate_breakpoint+1):end))).^2); if summed_deviancesmallest_summed_deviance))/bootstrap_runs); else confidence=nan; end