function mcmcLogisticExample(varargin)

%;----EXAMPLE CODE----

%;A simple pseudo-inversion

 optargin = size(varargin,2);
 switch optargin
     case 0
         noise=200;
     case 1
         noise=varargin{1};
     otherwise
         error('Too many input arguments');
 end



%;Set up the y0 t0 and tEnd values and number of timesteps we desire

  x = [200; 0; 500; 50];
  
%;The "true" parameters and output
  truth = [0.01,1500];
  yOut = logisticModel(x,truth);


  	
  obs = yOut + (randn(1,length(yOut)).*noise);
  



param.name={'a';'K'};
param.value=[0.7; 1000];
param.max=[3; 4000];
param.min=[0.0;0.0];
param.knob=[1.0;1.0];
param.changeable=[1;1];



%;---OPTIONAL KEYWORDS---
% (1) validdata is % of datapoints in each interval that are valid (default is 100%)  This has the same dimension as data.
% (2) valid_frac is min % of datapoints to accept (default is 50%)

% (3) model is the name of the model function (string) - default is "mcmc_testmodel"  (be sure to ignore the .m extension)
% (4) likelihood is the name of the likelihood function - it should call the model and compute the likelihood - default is "mcmc_likelihood"

% (5) numatonce - how often to check for chain convergence (default is 10000)
% (6) random_start - start at init guess if 0, else randomly within prior (default is 0)
% (7) numchains - number of chains (default is 10)
% (8) numspinups - how much burn in on final iteration (default is 125000)
% (9) iter - max number of iterations both for chains and final (default is 375000)
% (10) ranacc - tuning parameter for % of "worse" likelihoods to accept (default is -1) 
% (11) 'fast', 'medium', and 'superfast' are keywords with different default settings for the above settings - all are faster than default (see below)
% (12) 'quiet' turns off all printing of messages


%%% Empty fields will be set to the defaults in mcmc.m
%inputOpts.model = 'logisticModel';
inputOpts.model = 'logisticEuler';  %%% A faster code that uses Euler's method to generate a solution
inputOpts.validdata=[];
inputOpts.valid_frac=[];
inputOpts.likelihood = [];
inputOpts.numatonce=1;
inputOpts.random_start=[];
inputOpts.numchains=[];
inputOpts.numspinups=5;
inputOpts.iter=10;
inputOpts.ranacc=[];
%inputOpts.mode='superfast';
inputOpts.mode=[];
inputOpts.quietMode=[];

%%% For logisticEuler we need to adjust it to y0, dt, nSteps
dt=(x(3)-x(2))/x(4);
 xIn = [x(1); dt; x(4)];

 %%% Otherwise solve with ode45 techniques
% xIn=x;
 
[outputll,outputvalue,outputy]=mcmc(xIn,obs,param,inputOpts);
%;Call MCMC
%;Plot outputs
  
   t=sprintf(['Parameter Name:  True Parameter Values / Estimated Parameter Values:']);
   disp(t) 
  for nC=1:length(truth)
      t=sprintf([char(param.name(nC)) ': ' num2str(truth(nC)) '   ' num2str(outputvalue(nC,1)) ]);
      disp(t)
  end
  
 corrMatrix=corrcoef(obs',outputy');
  t=sprintf(['r2: ' num2str(corrMatrix(1,2).^2) ]);
  disp(t)
