MPGSA questions regarding plot visualizations and log-distributed sampling

2 views (last 30 days)
Hello,
I have two questions regarding MPGSA analyses:
  1. When analyzing many independent variables, I cannot visualize the subplots (see attached) when the plot() and histogram() methods are run. Is it possible to break these into individual figures?
  2. It appears the x axes are in linear scale, although I sampled the parameters using loguniform distributions. Is it possible to display the x axes in log scale when sampling is done on log scale?
  3. Also, along the lines of (2), can I confirm whether the logarithmic distribution of the sampling is taken into account when the K-S calculations are performed?
Thank you,
Abed

Answers (1)

Florian Augustin
Florian Augustin on 7 Jan 2022
Hello Abed,
You can use the name-value pair Parameters in the plot or histogram methods to selectively visualize GSA results. You can either specify the input parameters as a numeric index or via their names. Looking at the screenshot you attached, you could select kdA and kdB as follows:
plot(mpgsaResults, "Parameters", [3, 4]);
% or
plot(mpgsaResults, "Parameters", ["kdA", "kdB"]);
In the current version of Matlab (R2021b), there is no name-value pair in the GSA plot methods to change the axes scale. But here is a little script you could use/tweak to manually change the scale:
function figHandle = plotInXLogScale(mpgsaResults, varargin)
% Create plot
figHandle = plot(mpgsaResults, varargin{:});
% Get axes handles from figure
axes = findobj(figHandle, "Type", "Axes");
% Change x-scale of axes to log-scale
for i = 1:numel(axes)
axes(i).XScale = "log";
end
end
I am not sure I understand the third question, but you can inspect the parameter samples on the MPGSA results object, e.g. by plotting them in a histogram:
% Plot parameter samples for input parameter kdA:
histogram(results.ParameterSamples.("kdA"));
Let me know if this doesn't answer your question.
Hope this helps.
Best,
-Florian
  2 Comments
Abed Alnaif
Abed Alnaif on 7 Jan 2022
Hi Florian,
Regarding the first question, thanks, I missed this in the documentation but this is exactly what I'm looking for.
Regarding the second question, I think this is a good solution for the plot() method. I'm not sure if it will work with the histogram() method.
To clarify the third question: I'm not very familiar with the K-S Test, but I have a high-level understanding that it's designed to detect differences between CDFs. My concern is that a difference between two CDFs may be apparent when the x axis is in log scale, but not when it is in linear scale. I'm not sure if this makes sense?
Thank you,
Abed
Florian Augustin
Florian Augustin on 7 Jan 2022
Hi Abed,
The simple change of scale of the axes also works for the histogram plots. However, this does not change, the bin boundaries, which will remain equidistant on a linear scale. Changing the binning boundaries to be equidistant on a log-scale is not supported.
To get equidistant bins on a log-scale, you have to create custom histogram plots:
%% Setup
% -----
% Index of classifier in the order specified in sbiompgsa:
classIdx = 1; % choose 1 if you only have one classifier
% Index of parameter in the order specified in sbiompgsa:
paramIdx = 3; % this would select kdA
% Create bounds of bins in log scale:
binEdges = logspace(2, 4, 10); % example: 10 equidistant bounds on log-scale between 10^2 and 10^4.
%% Plot
% ----
% Parameter samples
samples = mpgsaResults.ParameterSamples{:, paramIdx};
% Index of samples that support classifier:
supportSamples = mpgsaResults.SupportHypothesis{:, classIdx};
% Index of valid samples (for which simulation did not fail):
validSamples = mpgsaResults.SimulationInfo.ValidSample;
% Plot:
figure(1); clf;
histogram(samples(supportSamples & validSamples), "BinEdges", binEdges, "Normalization", "probability");
hold("on");
histogram(samples(~supportSamples & validSamples), "BinEdges", binEdges, "Normalization", "probability");
To visualize the values of the K-S statistic, I would recommend using bar plots. There the numeric values are are more apparent than in the eCDF plot plots. You can also access the raw numeric values as a table:
mpgsaResults.KolmogorovSmirnovStatistics
Best,
Florian

Sign in to comment.

Communities

More Answers in the  SimBiology Community

Categories

Find more on Perform Sensitivity Analysis in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!