Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions 3rdParty/mcmcstat/%runDram.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function [problemDef,problem,result,bayesResults] = runDram(problemDef,problemDefCells,problemDefLimits,priors,controls)
function [problemStruct,problem,result,bayesResults] = runDram(problemStruct,problemCells,problemLimits,priors,controls)
debug = 0;

checks = controls.checks;
[problemDef,fitNames] = packParams(problemDef,problemDefCells,problemDefLimits,checks);
[problemStruct,fitNames] = packParams(problemStruct,problemCells,problemLimits,checks);
%fitPriors = packPriors(priors,checks);

% Seed the Random Number Generator
Expand All @@ -15,12 +15,12 @@
%Make uniform priors from the
%min/max limits for now.
prior = {};
lims = problemDef.fitLimits;
lims = problemStruct.fitLimits;
% Get the li

for i = 1:length(fitNames)
name = fitNames{i};
value = problemDef.fitParams(i);
value = problemStruct.fitParams(i);
min = lims(i,1);
max = lims(i,2);
mu = 0;
Expand Down Expand Up @@ -51,7 +51,7 @@
burnin = controls.burnin;
adaptint = 100;%controls.adaptint;

problem = {problemDef ; controls ; problemDefLimits ; problemDefCells};
problem = {problemStruct ; controls ; problemLimits ; problemCells};

res = [];
output = runBayes(loop,nsimu,burnin,adaptint,params,problem);
Expand All @@ -65,9 +65,9 @@
bayesResults.bestFits = output.bestFits;
bayesResults.predlims = output.predlims;

problemDef.fitParams = output.bestPars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = output.bestPars;
problemStruct = unpackParams(problemStruct,controls);
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);

% Pre-processor directives for Matlab Coder.
coder.varsize('problem.ssubs',[Inf 1],[1 0]);
Expand Down
12 changes: 6 additions & 6 deletions 3rdParty/mcmcstat/refModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

pars = theta;

problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};

problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct,controls);
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);

ySim = result{1}{contrast};

Expand Down
14 changes: 7 additions & 7 deletions 3rdParty/mcmcstat/refModel_scaled.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@



problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};

pars = theta;
constr = problemDef.fitLimits;
constr = problemStruct.fitLimits;
pars = unscalePars(pars,constr);

problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct,controls);
[problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);

ySim = result{1}{contrast};

Expand Down
18 changes: 7 additions & 11 deletions 3rdParty/mcmcstat/reflectivity_fitModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@
pars = theta; % Current parameter values from mcmcstat
problem = data.problem; % Struct needed for the calculation
%allProblem = data{1}.problem;
problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};


problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
%setappdata(0,'problem',problem);
%problem = reflectivityCalculation(problem);
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct,controls);
[contrastParams,~] = reflectivityCalculation(problemStruct,problemCells,controls);

%problem = getappdata(0,'problem');
ss = problemDef.calculations.sumChi;
ss = contrastParams.calculations.sumChi;

end

21 changes: 9 additions & 12 deletions 3rdParty/mcmcstat/reflectivity_fitModel_scaled.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@
% Calls reflectivity calculation and returns the value of chisquared.
% Scaled version so the parameters need to be unscaled before use.

problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};

pars = theta; % Current parameter values from mcmcstat
constr = problemDef.fitLimits;
constr = problemStruct.fitLimits;
pars = unscalePars(pars,constr);

problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
%setappdata(0,'problem',problem);
%problem = reflectivityCalculation(problem);
[problemDef,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct,controls);

%problem = getappdata(0,'problem');
ss = problemDef.calculations.sumChi;
[contrastParams,~] = reflectivityCalculation(problemStruct,problemCells,controls);

end
ss = contrastParams.calculations.sumChi;

end
22 changes: 11 additions & 11 deletions 3rdParty/mcmcstat/runBayes.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function output = runBayes(loop,nsimu,burnin,adaptint,params,problem,controls)

problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};

display = controls.display;

Expand All @@ -12,7 +12,7 @@
% We have the same number of 'batches' as contrasts.
% Also need to pass problem in order to access this
% from the subfunctions.
numberOfContrasts = problemDef.numberOfContrasts;
numberOfContrasts = problemStruct.numberOfContrasts;

% Pre-allocate data to keep the compiler happy
% data = cell(1,numberOfContrasts);
Expand All @@ -23,7 +23,7 @@
data.data = cell(1,numberOfContrasts);
data.problem = problem;
for i = 1:numberOfContrasts
thisData = problemDefCells{2}{i};
thisData = problemCells{2}{i};
if ~isempty(thisData)
data.data{i} = [thisData(:,:)];
end
Expand All @@ -32,8 +32,8 @@

% Make qcov based on the ranges of the parameters
qcov = [];
fitPars = problemDef.fitParams;
fitConstr = problemDef.fitLimits;
fitPars = problemStruct.fitParams;
fitConstr = problemStruct.fitLimits;
nPars = length(fitPars);

for i = 1:nPars
Expand Down Expand Up @@ -89,12 +89,12 @@
% out = mcmcpred_compile(results,chain,[],data,problem,500);
% outSld = mcmcpred_compile_sld(results,chain,[],data,problem,500);
%
% problemDef.fitParams = output.bestPars;
% problemDef = unpackParams(problemDef,controls);
% [problem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
% problemStruct.fitParams = output.bestPars;
% problemStruct = unpackParams(problemStruct,controls);
% [problem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
%
% output.bestFits = result{1};
% output.shiftedData = problemDefCells{2};
% output.shiftedData = problemCells{2};
% output.predlims = out;

end
Expand Down
28 changes: 14 additions & 14 deletions 3rdParty/mcmcstat/runDram.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function [problemDef,outProblem,result,bayesResults] = runDram(problemDef,problemDefCells,problemDefLimits,controls,allPriors)
function [problemStruct,outProblem,result,bayesResults] = runDram(problemStruct,problemCells,problemLimits,controls,allPriors)

%#codegen

%coder.varsize('problemDef.contrastBacks',[1 Inf],[0 1]);
%coder.varsize('problemStruct.contrastBacks',[1 Inf],[0 1]);

checks = controls.checks;
[problemDef,fitNames] = packParams(problemDef,problemDefCells,problemDefLimits,checks);
[problemStruct,fitNames] = packParams(problemStruct,problemCells,problemLimits,checks);
%fitPriors = packPriors(priors,checks);

% Seed the Random Number Generator
Expand All @@ -15,7 +15,7 @@

%First deal with priors.
prior = {};
lims = problemDef.fitLimits;
lims = problemStruct.fitLimits;

% Preallocate params array to keep the compiler happy
params = cell(length(fitNames),1);
Expand Down Expand Up @@ -117,7 +117,7 @@
for i = 1:length(fitNames)
coder.varsize('name',[1 Inf],[0 1]);
name = fitNames{i};
value = problemDef.fitParams(i);
value = problemStruct.fitParams(i);
min = lims(i,1);
max = lims(i,2);

Expand Down Expand Up @@ -149,13 +149,13 @@
burnin = controls.burnin;
adaptint = 100;%controls.adaptint;

problem = {problemDef ; controls ; problemDefLimits ; problemDefCells};
problem = {problemStruct ; controls ; problemLimits ; problemCells};

output = runBayes(loop,nsimu,burnin,adaptint,params,problem,controls);

[problemDef,outProblem,result,bayesResults] = processBayes(output,problem);
[problemStruct,outProblem,result,bayesResults] = processBayes(output,problem);

% problemDef.fitParams = bayesResults.bestPars_Mean;
% problemStruct.fitParams = bayesResults.bestPars_Mean;


% Post processing of Bayes
Expand All @@ -170,17 +170,17 @@
% bestPars_mean = output.results.mean;
%
% % Calulate Max best fit curves
% problemDef.fitParams = bestPars_max;
% problemDef = unpackParams(problemDef,controls);
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
% problemStruct.fitParams = bestPars_max;
% problemStruct = unpackParams(problemStruct,controls);
% [outProblem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
% bestFitMax_Ref = result(1);
% bestFitMax_Sld = result(5);
% bestFitMax_chi = outProblem.calculations.sumChi;
%
% % Calculate 'mean' best fit curves
% problemDef.fitParams = bestPars_mean;
% problemDef = unpackParams(problemDef,controls);
% [outProblem,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
% problemStruct.fitParams = bestPars_mean;
% problemStruct = unpackParams(problemStruct,controls);
% [outProblem,result] = reflectivityCalculation(problemStruct,problemCells,controls);
% bestFitMean_Ref = result(1);
% bestFitMean_Sld = result(5);
% bestFitMean_chi = outProblem.calculations.sumChi;
Expand Down
12 changes: 6 additions & 6 deletions 3rdParty/mcmcstat/sldModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

pars = theta;

problemDef = problem{1};
problemStruct = problem{1};
controls = problem{2};
problemDefLimits = problem{3};
problemDefCells = problem{4};
problemLimits = problem{3};
problemCells = problem{4};
controls.calcSldDuringFit = true;

problemDef.fitParams = pars;
problemDef = unpackParams(problemDef,controls);
[~,result] = reflectivityCalculation(problemDef,problemDefCells,controls);
problemStruct.fitParams = pars;
problemStruct = unpackParams(problemStruct,controls);
[~,result] = reflectivityCalculation(problemStruct,problemCells,controls);

sld = result{5}{contrast};

Expand Down
10 changes: 5 additions & 5 deletions 3rdParty/paramonte/pmLogFunction.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

properties

problemDef;
problemDefCells;
problemDefLimits;
problemStruct;
problemCells;
problemLimits;
priors;
controls;
scaled;
Expand All @@ -16,7 +16,7 @@

function logFuncVal = get(obj,pars)

problem = obj.problemDef;
problem = obj.problemStruct;
problem.fitParams = pars;

if obj.scaled
Expand All @@ -25,7 +25,7 @@

problem = unpackParams(problem,obj.controls);

[outProblem,~] = reflectivityCalculation_mex(problem,obj.problemDefCells,obj.controls);
[outProblem,~] = reflectivityCalculation_mex(problem,obj.problemCells,obj.controls);
chi = outProblem.calculations.sumChi;
logFuncVal = -chi/2;

Expand Down
Loading