2%> This is the base
class for generating objects that contain the contents of a chain
3%> file generated by the ParaMonte MCMC samplers such as [pm.sampling.Paradram](@ref
Paradram).<br>
6%> This
class is meant to be primarily internally used by the ParaMonte MATLAB library samplers.<br>
7%> This
class merely adds a number of visualizations to its superclass
which are
8%> specific to the [pm.sampling.Paradram](@ref
Paradram) sampler.<br>
11%> See also the documentation of the
class constructor
15%> See also the documentation of the superclass [pm.sampling.FileContentsChain](@ref
FileContentsChain).<br>
18%> See below
for information on the attributes (properties).<br>
21%> See below
for information on the
class methods.<br>
26%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
27%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 properties(Access =
public)
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 methods(Access = public)
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %> \param[in] file : The input scalar MATLAB
string containing the path or web address to an external file.<br>
57 %> \param[in] format : The input scalar MATLAB
string containing the reading format of the Markov chain:
59 %> <li> If ``format`` is set to ``"compact"``,
60 %> the Markov chain will be read in compact (weighted) format.<br>
61 %> This format is fast and potentially highly memory-efficient.<br>
62 %> Beware that this format does not necessarily generate a compact chain
63 %> when the specified chain file is already written in
verbose format.<br>
64 %> <li> If ``format`` is set to ``"
verbose"``,
65 %> the Markov chain will be read in
verbose (unweighted or unrolled) format.<br>
66 %> While the chain in this format is the **actual Markov chain**,
67 %> reading the chain in this format can be highly inefficient as it
68 %> can use too much memory for high-dimensional density functions.<br>
70 %> (**optional**, default = ``"compact"``.)
79 %> contents = pm.sampling.FileContentsChainMCMC(file, [])
80 %> contents = pm.sampling.FileContentsChainMCMC(file, silent)
81 %> contents = pm.sampling.FileContentsChainMCMC(file, [], sep)
82 %> contents = pm.sampling.FileContentsChainMCMC(file, silent, sep)
87 %> See also the documentation of the subclasses
for example usage.<br>
92 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
93 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
108 self = self@pm.sampling.FileContentsChain(file, silent, sep);
111 %%%% Unroll the chain
if necessary and add the Markov-specific stats information.
114 if pm.introspection.istype(format,
"string") && strcmpi(format,
"verbose")
116 %%%% Unpack the chain data frames.
118 self.df = pm.array.verbose(self.df, 1, self.df.sampleWeight);
119 self.df.sampleWeight(:) = 1;
121 elseif ~isempty(format) && ~(pm.introspection.istype(format,
"string") && strcmpi(format,
"compact"))
123 help(
"pm.sampling.Paradram.readChain");
127 +
"Unrecognized input value for ``format``." + newline ...
128 +
"See the documnetation displayed above for more information." + newline ...
129 +
"Here is the error message:" + newline ...
131 +
string(me.identifier) + newline +
string(me.message) + newline ...
139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 methods(Access =
public, Hidden)
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 %> and store the results in the respective fields of the ``stats`` attribute of the parent
object.<br>
154 %> This is a dynamic ``Hidden`` method of
class [pm.sampling.FileContentsChainMCMC](@ref
FileContentsChainMCMC).<br>
155 %> It is **inaccessible** to the end users of the library.<br>
157 %> \param[in] self : The input parent
object of
class [pm.sampling.FileContentsChainMCMC](@ref
FileContentsChainMCMC)
158 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
160 %> \interface{setstats}
163 %> contents = pm.sampling.FileContentsChainMCMC();
165 %> contents.setstats();
172 %> \AmirShahmoradi, 2:11 PM Friday, November 8, 2024, Dallas, TX<br>
173 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
174 function setstats(self)
176 setstats@pm.sampling.FileContentsChain(self);
179 %%%% Add chain cormat.
182 self.checkpoint(
"computing the sample correlation matrix...",
false);
183 self.stats.cor = pm.stats.Cor(@()self.df(:, self.slfc + 1 : end));
187 %%%% Add chain covmat.
190 self.checkpoint(
"computing the sample covariance matrix...",
false);
191 self.stats.cov = pm.stats.Cov(@()self.df(:, self.slfc + 1 : end));
198 self.checkpoint(
"computing the sample autocorrelation...",
false);
199 self.stats.acf = pm.stats.AutoCorr(@()self.df(:, self.slfc : end));
202 self.stats.max =
struct(
"val", [],
"loc", []);
203 self.stats.min =
struct(
"val", [],
"loc", []);
206 %%%% The `{:,:}` slice is essential in MATLAB ~2020a.
209 [self.stats.max.val, self.stats.max.loc] = max(self.df{:,:});
210 [self.stats.min.val, self.stats.min.loc] = min(self.df{:,:});
211 self.stats.avg = mean(self.df{:,:});
212 self.stats.std = std(self.df{:,:});
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 %> and store the results in the respective fields of the ``stats`` attribute of the parent
object.<br>
223 %> This is a dynamic ``Hidden`` method of
class [pm.sampling.FileContentsChainMCMC](@ref
FileContentsChainMCMC).<br>
224 %> It is **inaccessible** to the end users of the library.<br>
226 %> \param[in] self : The input parent
object of
class [pm.sampling.FileContentsChainMCMC](@ref
FileContentsChainMCMC)
227 %>
which is **implicitly** passed to
this dynamic method (not by the user).<br>
229 %> \interface{setvis}
232 %> contents = pm.sampling.FileContentsChainMCMC();
234 %> contents.setvis();
241 %> \AmirShahmoradi, 2:12 PM Friday, November 8, 2024, Dallas, TX<br>
242 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
243 function setvis(self)
245 setvis@pm.sampling.FileContentsChain(self);
247 self.checkpoint(
"adding the ParaDRAM-specific visualization components...",
false);
249 silent_kws = {
"silent", self.silent};
250 self.checkpoint(
"adding DRAM-specific visualizations to the chain object...",
false);
253 %%%% Add the visualizations
for ``meanAcceptanceRate``.
258 %%%% Find the keywords in the column names.
259 %%%% This avoids exact matching,
which is problematic between ParaMonte 1 and 2).
260 for colname =
string(self.df.Properties.VariableNames)
261 if contains(lower(colname),
"mean")
266 self.vis.(colname) = struct();
267 self.vis.(colname).line = pm.vis.
PlotLine ( @()self.df, "coly", colname, "colc", self.slfc ...
268 , "ylabel", {
"txt",
"Mean Acceptance Rate"} ...
269 ,
"xlabel", {
"txt",
"Sampling Step"} ...
270 ,
"axes", {
"xscale",
"log"} ...
271 ,
"plot", {
"linewidth", 3} ...
277 warning ( newline ...
278 +
"Failed to create the visualizations for the " + colname +
" data column of the chain file." + newline ...
279 +
"Here is the error message:" + newline ...
281 +
string(me.identifier) + newline +
string(me.message) + newline ...
288 %%%% Add the visualizations
for ``burninLocation``.
293 %%%% Find the keywords in the column names.
294 %%%% This avoids exact matching,
which is problematic between ParaMonte 1 and 2).
295 for colname = [
string(self.df.Properties.VariableNames)]
296 if contains(lower(colname),
"burnin")
301 self.vis.(colname) = struct();
302 self.vis.(colname).line = pm.vis.
PlotLine ( @()self.df, "coly", colname, "colc", self.slfc ...
303 , "ylabel", {
"txt",
"MCMC Burnin Location"} ...
304 ,
"xlabel", {
"txt",
"Sampling Step"} ...
305 ,
"axes", {
"xscale",
"log"} ...
306 ,
"plot", {
"linewidth", 3} ...
312 warning ( newline ...
313 +
"Failed to create the visualizations for the " + colname +
" data column of the chain file." + newline ...
314 +
"Here is the error message:" + newline ...
316 +
string(me.identifier) + newline +
string(me.message) + newline ...
323 %%%% Add the visualizations
for ``proposalAdaptation``.
328 %%%% Find the keywords in the column names.
329 %%%% This avoids exact matching,
which is problematic between ParaMonte 1 and 2).
330 for colname = [
string(self.df.Properties.VariableNames)]
331 if contains(lower(colname),
"adaptation")
336 self.vis.(colname) = struct();
337 self.vis.(colname).line = pm.vis.
PlotLine ( @()self.df, "coly", colname, "colc", self.slfc ...
338 , "ylabel", {
"txt",
"Proposal Adaptation"} ...
339 ,
"xlabel", {
"txt",
"Sampling Step"} ...
340 ,
"axes", {
"yscale",
"log"} ...
341 ,
"plot", {
"linewidth", 2} ...
344 self.vis.(colname).scatter = pm.vis.PlotScatter ( @()self.df,
"coly", colname,
"colc", self.slfc ...
345 ,
"ylabel", {
"txt",
"Proposal Adaptation"} ...
346 ,
"xlabel", {
"txt",
"Sampling Step"} ...
347 ,
"axes", {
"yscale",
"log"} ...
353 warning ( newline ...
354 +
"Failed to create the visualizations for the " + colname +
" data column of the chain file." + newline ...
355 +
"Here is the error message:" + newline ...
357 +
string(me.identifier) + newline +
string(me.message) + newline ...
364 %%%% Report the timing.
371 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This is the base class for generating objects that contain the contents of a chain file generated by ...
function FileContentsChainMCMC(in file, in silent, in sep, in format)
Return a scalar object of class pm.sampling.FileContentsChainMCMC.
function setstats(in self)
Compute the statistics of the parent object of class pm.sampling.FileContentsChainMCMC and store the ...
function setvis(in self)
Compute the statistics of the parent object of class pm.sampling.FileContentsChainMCMC and store the ...
This is the base class for generating objects that contain the contents of a chain file generated by ...
This is the ParaDRAM class for generating instances of serial and parallel Delayed-Rejection Adaptive...
This is the PlotLine class for generating instances of 2-dimensional Line Plot visualizations based o...
function statistics()
Return a scalar MATLAB logical that is true if and only if the current installation of MATLAB contain...
function verbose(in cmat, in dim, in weight)
Return a MATLAB double, cell, or table matrix whose rows or columns are unrolled according to a presp...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...