Skip to content

Commit

Permalink
Removes "bestFitMean" from "BayesResults" (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPaulSharp authored Jun 10, 2024
1 parent 7e96acd commit f0cc59c
Show file tree
Hide file tree
Showing 25 changed files with 11 additions and 57 deletions.
3 changes: 1 addition & 2 deletions minimisers/DREAM/runDREAM.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

% This will change...
% Initial sampling and parameter range
paramInfo.prior = coderEnums.priorTypes.Uniform;
parInfo.prior = coderEnums.priorTypes.Uniform;
ParInfo.min = problemStruct.fitLimits(:,1)';
ParInfo.max = problemStruct.fitLimits(:,2)';
ParInfo.boundhandling = controls.boundHandling;
Expand Down Expand Up @@ -99,7 +99,6 @@
[outProblemStruct,result,dreamResults] = processBayes(output,problemStruct,problemCells,problemLimits,controls);

% Populate the output struct
bayesResults.bestFitMean = dreamResults.bestFitMean;
bayesResults.predictionIntervals = dreamResults.predictionIntervals;
bayesResults.confidenceIntervals = dreamResults.confidenceIntervals;
bayesResults.dreamParams = dreamOutput.DREAMPar;
Expand Down
1 change: 0 additions & 1 deletion minimisers/NS/runNestedSampler.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
[problemStruct,result,nestResults] = processBayes(bayesOutputs,problemStruct,problemCells,problemLimits,controls);

bayesResults.predictionIntervals = nestResults.predictionIntervals;
bayesResults.bestFitMean = nestResults.bestFitMean;
bayesResults.confidenceIntervals = nestResults.confidenceIntervals;
bayesResults.chain = chain;
bayesResults.nestedSamplerOutput.LogZ = logZ;
Expand Down
6 changes: 1 addition & 5 deletions minimisers/generalUtils/bayesStats/processBayes.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

% Calculate 'mean' best fit curves
result = reflectivityCalculation(problemStruct,problemCells,problemLimits,controls);
bestFitMean.reflectivity = result.reflectivity;
bestFitMean.sld = result.sldProfiles;
bestFitMean.chi = result.calculationResults.sumChi;
bestFitMean.data = result.shiftedData;

% 2. Reflectivity and SLD shading
predInts = refPercentileConfidenceIntervals(bayesOutputs,problemStruct,problemCells,problemLimits,controls);
Expand All @@ -22,7 +18,7 @@


% bayesResults.chain = bayesOutputs.chain;
bayesResults = struct('bestFitMean',bestFitMean,'predictionIntervals',predInts,...
bayesResults = struct('predictionIntervals',predInts,...
'confidenceIntervals',confidenceIntervals);

end
54 changes: 7 additions & 47 deletions minimisers/generalUtils/makeEmptyBayesResultsStruct.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
%
% struct with fields:
%
% bestFitMean: [1×1 struct]
% predictionIntervals: [1×1 struct]
% confidenceIntervals: [1×1 struct]
% allChains: [1×1 struct]
Expand All @@ -20,45 +19,7 @@

% -----------------------------------------------------------
% Make the individual structs....
% (1) bayesResults.bestFitMean

reflectivity = cell(nContrasts, 1);
reflectivityCell = [1 1 1];
coder.varsize('reflectivityCell',[1e7 4],[1 1]);
for i = 1:nContrasts
reflectivity{i} = reflectivityCell;
end

if isDomains
sld = cell(nContrasts,2);
sldCell = [1 1; 1 1];
coder.varsize('sldCell',[1e7 3],[1 1]);
for i = 1:nContrasts
sld{i,1} = sldCell;
sld{i,2} = sldCell;
end
else
sld = cell(nContrasts, 1);
sldCell = [1 1];
coder.varsize('sldCell',[1e7 3],[1 1]);
for i = 1:nContrasts
sld{i} = sldCell;
end
end

chi = 0;

data = cell(nContrasts, 1);
dataCell = [1 1 1];
coder.varsize('dataCell',[1e7 5],[1 1]);
for i = 1:nContrasts
data{i} = dataCell;
end

bestFitMean = struct('reflectivity',{reflectivity},'sld',{sld},'chi',chi,'data',{data});

% --------------------------------------------------------------------
% (2) bayesResults.predictionIntervals
% (1) bayesResults.predictionIntervals

reflectivityIntervals = cell(nContrasts,1);
reflectivityIntervalsCell = [1 1 1];
Expand Down Expand Up @@ -116,7 +77,7 @@
'sldXData',{sldXData},'sampleChi',sampleChi);

% ------------------------------------------------------------------
% (3) bayesResults.confidenceIntervals
% (2) bayesResults.confidenceIntervals

percentile95 = zeros(2,1);
coder.varsize('percentile95',[2 1e3],[0 1]);
Expand All @@ -131,7 +92,7 @@
'percentile65',percentile65,'mean',mean);

% -------------------------------------------------------------------
% (4) bayesResults.dreamParams
% (3) bayesResults.dreamParams

R = zeros(nChains,nChains);
coder.varsize('R',[1e4 1e4],[1 1]);
Expand All @@ -157,7 +118,7 @@
'R', R);

% -------------------------------------------------------------------
% (5) bayesResults.dreamOutput
% (4) bayesResults.dreamOutput

allChains = [1 1 1];
coder.varsize('allChains',[1e4 50 50],[1 1 1]);
Expand Down Expand Up @@ -186,7 +147,7 @@
'CR', CR);

% -------------------------------------------------------------------
% (6) bayesResults.nestedSamplerOutput
% (5) bayesResults.nestedSamplerOutput

% Nested Sampler
LogZ = 0;
Expand All @@ -201,15 +162,14 @@
nestSamples,'postSamples',postSamples);

% ------------------------------------------------------------------
% (7) chain
% (6) chain

chain = [0 0];
coder.varsize('chain',[1e6 1e3],[1 1]);

% -------------------------------------------------------------------
% Make the final structure...
bayesResults = struct('bestFitMean',bestFitMean,...
'predictionIntervals', predictionIntervals,...
bayesResults = struct('predictionIntervals', predictionIntervals,...
'confidenceIntervals', confidenceIntervals,...
'dreamParams', dreamParams,...
'dreamOutput', dreamOutput,...
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat
Binary file not shown.
Binary file modified tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat
Binary file not shown.
Binary file modified tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/testProjectConversion/DSPCBilayerProjectClass.mat
Binary file not shown.
Binary file modified tests/testProjectConversion/monolayerVolumeModelProjectClass.mat
Binary file not shown.
4 changes: 2 additions & 2 deletions utilities/plotting/bayesShadedPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function bayesShadedPlot(problem,result,varargin)
sldXdata = pLims.sldXData;

% Get the reflectivities for mean...
bestRefMean = result.bestFitMean.reflectivity;
bestSldMean = result.bestFitMean.sld;
bestRefMean = result.reflectivity;
bestSldMean = result.sldProfiles;

shiftedData = result.shiftedData;
numberOfContrasts = length(shiftedData);
Expand Down

0 comments on commit f0cc59c

Please sign in to comment.