5%> This is the <b>ParaMonte MATLAB</b> documentation website
for the MATLAB users and developers.
8%> <!--==============================-->
9%> \section ParaMonte What is ParaMonte?
10%> <!--==============================-->
12%> ParaMonte is a multi-language library of serial and
parallel Monte Carlo and Machine Learning routines
13%> scientific inference, e.g.,
for sampling mathematical density functions of arbitrary-dimensions,
14%> with the design goal of unifying
16%> + the **automation** of simulations and inference,
17%> + the **user-friendliness** of the library and routines,
18%> + the **accessibility** from multiple programming environments,
19%> + the **high-performance** at runtime, and,
20%> + the **scalability** across many
parallel processors.
22%> [⛓](#ParaMonteRepository)
23%> <!--==================================================-->
24%> \section ParaMonteRepository ParaMonte Project Repository
25%> <!--==================================================-->
27%> The ParaMonte library is open-source and is permanently located and maintained on **GitHub** at:
29%>  <a
href=
"https://github.com/cdslaborg/paramonte" target=
"_blank"><b>https:
31%> [⛓](#ParaMonteReleases)
32%> <!--===============================================-->
33%> \section ParaMonteReleases ParaMonte Prebuilt Releases
34%> <!--===============================================-->
36%> The pre-built releases of the ParaMonte library
for select configurations and compilers are available on **GitHub Release** page at:
38%>  <a
href=
"https://github.com/cdslaborg/paramonte/releases" target=
"_blank"><b>https:
40%> For instructions to build the ParaMonte library from source files, visit the ParaMonte library main documentation website [linked below](@ref ParaMonteDocumentation).
42%> [⛓](#ParaMonteDocumentation)
43%> <!--========================================================-->
44%> \section ParaMonteDocumentation ParaMonte Documentation Website
45%> <!--========================================================-->
47%> For information about the ParaMonte library in general and in other supported programming languages, visit:
49%>  <a
href=
"https://www.cdslab.org/paramonte" target=
"_blank"><b>https:
51%> [⛓](#ParaMonteLangDocumentation)
52%> \section ParaMonteLangDocumentation ParaMonte MATLAB Documentation Website
54%> The documentation
for the latest
version of the ParaMonte MATLAB library is always <a href="../../matlab/latest/index.html" target="_blank"><b>available on
this page</b></a>.<br>
56%> [⛓](#ParaMonteUsage)
57%> <!--============================================-->
58%> \section ParaMonteUsage ParaMonte MATLAB QuickStart
59%> <!--============================================-->
61%> For more information on the installation, general usage, and examples, visit:
63%>  <a
href=
"https://www.cdslab.org/paramonte/generic/latest/installation/matlab/" target=
"_blank"><b>https:
65%> To get started with the library once you download it, simply add the path to the ParaMonte library `+pm`
66%>
package to access the routines and functionalities available in the library.<br>
70%> pmlibRootDir = './'; % Change
this to the directory containing the ParaMonte MATLAB
package `+pm`.
71%> addpath(pmlibRootDir);
77%> [⛓](#ParaMonteLangModules)
78%> \section ParaMonteLangModules ParaMonte MATLAB Library Modules
80%> The MATLAB equivalent of modules is called **package**.
81%> Similar to modules in other languages, MATLAB packages can be imported to the MATLAB environment
82%> or simply be used as
namespace. For example,
88%> The ParaMonte MATLAB library currently contains a myriad of MATLAB *packages*.<br>
89%> The ParaMonte MATLAB library is currently under active development to extend the library functionalities to other tasks supported by the [ParaMonte Fortran library](../../../fortran/latest/
index.html).<br>
90%> For a full
list of all available functionalities and modules, see the [files listing](./files.html) and [class listing](./annotated.html) of this documentation website.<br>
92%> [⛓⛓](
#ParaMonteLangModulesSamplers)
93%> \section ParaMonteLangModulesSamplers ParaMonte MATLAB Library Samplers
95%> Perhaps the most relevant ParaMonte MATLAB modules to the end users are the ParaMonte samplers in the `pm.sampling`
package of the library.<br>
96%> See for example, the documentation of the parallel Delayed-Rejection Adaptive Metropolis Markov Chain Monte Carlo sampler [pm.sampling.Paradram](@ref Paradram).<br>
98%> [⛓](#ParaMonteLangNamingConventions)
99%> \section ParaMonteLangNamingConventions ParaMonte MATLAB Naming Conventions
101%> + The **camelCase** naming style is enforced throughout the ParaMonte MATLAB library for all variable and function names.<br>
102%> + The **PascalCase** naming style is enforced throughout the ParaMonte MATLAB library for all class names.<br>
103%> In other words, **all class names begin with a capital letter**.<br>
105%> [⛓⛓](#ParaMonteLangNamingConventionsVariables)
106%> \subsection ParaMonteLangNamingConventionsVariables ParaMonte MATLAB Naming Conventions: Variables
108%> By convention in this library,
110%> + All variables and procedure names except compile-time constants begin with an lowercase letter.
112%> + All constants and parameters should generally be typed in uppercase.
114%> + The names of variables that **always** represent vectors of values **may** be suffixed with `Vec` or `Vector`.
116%> + The names of variables that **always** represent matrices of values **may** be suffixed with `Mat` or `Matrix`.
118%> + A significant attempt has been made to end all `logical` variables with a passive verb.<br>
119%> This is to ensure that the full variable name virtually forms a proposition.<br>
120%> In other words, a `logical` variable name should be an English-language statement that evaluates to either `true` or `false`.<br>
121%> For example, `parallelismMpiFinalizeEnabled` is one such proposition.<br>
122%> + Occasionally, names that begin with the verb `is` can also be used to label `logical` objects.<br>
123%> + But as a general rule, names that begin with a verb should be reserved for procedures.<br>
125%> [⛓⛓](#ParaMonteLangNamingConventionsProcedures)
126%> \subsection ParaMonteLangNamingConventionsProcedures ParaMonte MATLAB Naming Conventions: Procedures
128%> + Procedure names should be descriptive of the action performed by the procedure. For example,
130%> + `getCov` means *generate (a) covariance matrix*.
131%> + `setMatCopy` means *copy the matrix into the specified buffer*.
133%> + Procedure names should preferably begin with a lowercase verb.
135%> + **Exceptions** to the above and below rules are allowed when,
136%> + the procedure name is exceptionally famous, or
137%> + it is very inconvenient to prefix the procedure name with a verb.
139%> + The names of functions with return values should preferably begin with <b>`get`</b>.<br>
140%> The reasoning is simple: Functions in mathematics *generate and obtain* a **new** object instead of changing (resetting) the state of an existing object.<br>
141%> For example, the function `getMatSym(mat)` generates a symmetric version of the input matrix and returns it as the function result.<br>
142%> **Exceptions** to this naming convention are allowed, for example, when the `get` prefix is inconvenient or when the function returns a `logical` result.<br>
144%> + Functions that return objects of type `logical` should be preferably prefixed with `is` or
145%> be named such that the name begins with a verb and reads as a proposition, evaluating to
146%> either `.true.` or `.false.`.
148%> [⛓](#ParaMonteLangAbbreviationGuidlines)
149%> \section ParaMonteLangAbbreviationGuidlines ParaMonte MATLAB Abbreviation Guidelines
151%> The following list of abbreviations is in alphabetical order to enable faster search:
153%> + The abbreviation `avg` stands for **average** (rarely used).
154%> + The abbreviation `cdf` stands for **Cumulative Distribution Function** in the context of statistics. Example: `getNormCDF()`.
155%> + The abbreviation `cho` stands for **Cholesky factorization**. Example: `setChoLow()`.
156%> + The abbreviation `chol` stands for **Cholesky factorization**. Example: `setMatChol()`.
157%> + The abbreviation `cor` stands for **correlation**. Example: `getCor()`.
158%> + The abbreviation `cov` stands for **covariance**. Example: `getCov()`.
159%> + The abbreviation `cum` stands for **cumulative**. Example: `getCumSum()`.
160%> + The abbreviation `coef` stands for **coefficient**. Example: `corcoef_type()`.
161%> + The abbreviation `def` stands for **default** in variable names (mostly as a prefix `def_` or suffix `_def`).
162%> + The abbreviation `def` stands for **definite** (mostly in procedure names dealing with positive-definite matrices)
163%> + The abbreviation `den` stands for **density**, mostly in the context of statistical procedures and objects. Example: `getLogProbDen()`.
164%> + The abbreviation `det` stands for **determinant**, mostly in the context of Matrix and linear algebra. Example: `getMatDet()`.
165%> + The abbreviation `dia` stands for **diagonal**, mostly in the context of matrix algebra, matrix packing, or Cholesky factorization. Example: `dia_type()`.
166%> + The abbreviation `diag` stands for **diagonal**, mostly as dummy argument in matrix algebra procedures.
167%> + The abbreviation `desc` stands for **description**, mostly as a dummy argument in tests.
168%> + The abbreviation `diff` stands for **difference**. Example: `setDisSortedExpDiff()`.
169%> + The abbreviation `dist` stands for **distance** or **distribution** depending on the context. Example: `DistMulti_type`.
170%> + The abbreviation `eff` stands for **effective**. Example: `effSamSize`.
171%> + The abbreviation `exp` stands for **exponential** or **exponentiated**. Example: `setDisSortedExpDiff()`.
172%> + The abbreviation `hell` stands for **Hellinger** in statistical distance computations. Example: `getDisHellSq()`.
173%> + The abbreviation `herm` stands for **hermitian** in matrix algebra.
174%> + The abbreviation `ice` stands for **Internal Compiler Error**. It typically appears in the bug descriptions tagged via Doxygen command <tt>\\bug</tt>.
175%> + The abbreviation `inv` stands for **inverse**. Example: `getMatInv()`.
176%> + The abbreviation `ks` stands for **Kolmogorov-Smirnov** test. Example: `getProbKS()`.
177%> + The abbreviation `lin` stands for **linear**. Example: `getLinSpace()`.
178%> + The abbreviation `low` stands for **lower triangle of a matrix** or **lower limits**. Example: `setChoLow()`.
179%> + The abbreviation `mahal` stands for **Mahalanobis** distance. Example: `getDisMahalSq()`.
180%> + The abbreviation `mat` stands for **matrix**. Example: `getMatInv()`.
181%> + The abbreviation `multi` stands for **multivariate** mostly used in the context of statistical distributions. Example: `getMultiNormRand()`.
182%> + The abbreviation `msn` stands for **Multivariate Skew-Normal** mostly used in the context of the statistical MultiVariate Skew-Normal distribution.
183%> + The abbreviation `mvn` stands for **MultiVariate Normal** mostly used in the context of the statistical MultiVariate Normal distribution.
184%> + The abbreviation `mvu` stands for **MultiVariate Uniform** mostly used in the context of the statistical MultiVariate (ellipsoidal) Uniform distribution.
185%> + The abbreviation `norm` stands for **normal** in the context of statistical distributions or **normalization** factor. Example: `DistMultiNorm_type`.
186%> + The abbreviation `normed` stands for **normalized** mostly in the context of statistical samples. Example: `NormedSample`.
187%> + The abbreviation `pdf` stands for **Probability Density Function** in the context of statistics. Example: `getNormLogPDF()`.
188%> + The abbreviation `pos` stands for **positive**. Example: `getInvPosDefMat()`.
189%> + The abbreviation `prob` stands for `probability`, mostly in the context of statistical applications. Example: `getLogProb()`.
190%> + The abbreviation `proc` stands for `procedure`, particularly, when it appears as the suffix `_proc` in `abstract interface` definitions.
191%> + The abbreviation `quan` stands for **quantile**, mostly in the context of statistics. Example: `getParetoLogQuan()`.
192%> + The abbreviation `rand` stands for **random**, mostly in the context of statistics. Example: `getUnifRand()`.
193%> + The abbreviation `ref` stands for **reference**, mostly in the context of testings to represent the reference values for comparison. Example: `mean_ref`.
194%> + The abbreviation `sam` stands for **sample**, mostly in the context of statistics. Example: `effSamSize`.
195%> + The abbreviation `sq` stands for **squared**. Example: `getDisMahalSq()`.
196%> + The abbreviation `stat` stands for **statistics**. Example: `StatDRAM_type`.
197%> + The abbreviation `std` stands for **standard deviation**. Example: `StdVec`.
198%> + The abbreviation `sym` stands for **symmetric**.
199%> + The abbreviation `symm` stands for **symmetric**.
200%> + The abbreviation `udf` stands for **Unnormalized Density Function** in the context of statistics. Example: `getEggBoxLogUDF()`.
201%> + The abbreviation `uni` stands for **univariate**, mostly used in the context of statistical distributions. Example: `DistUni_type`.
202%> + The abbreviation `unif` stands for **uniform**, mostly in the context of the uniform statistical distribution. Example: `getUnifRand()`.
203%> + The abbreviation `upp` stands for **upper triangle of a matrix** or **upper limits**. Example: `setChoUpp()`.
204%> + The abbreviation `vec` stands for **vector**. Example: `stdVec`.
206%> [⛓](#ParaMonteLangDeveloperWarnings)
207%> \section ParaMonteLangDeveloperWarnings ParaMonte MATLAB Developer Guidelines and Warnings
209%> The ParaMonte MATLAB library development and guidelines are summarized in
212%> [⛓](#ParaMonteLangDocumentationGuidelines)
213%> \section ParaMonteLangDocumentationGuidelines ParaMonte MATLAB Documentation Guidelines
215%> + **Doxygen custom command orderings**.
217%> + The Doxygen tag `\brief` must always be the first line of the documentation of modules, types, and procedures.<br>
218%> Example: [pm.sampling.Paradram](@ref Paradram).<br>
219%> + The Doxygen tag `\details`, if it exists, must always immediately follow the Doxygen tag `\brief`.<br>
220%> Example: [pm.sampling.Paradram](@ref Paradram).<br>
221%> + The Doxygen tag `\param`, if any number of it exists, must always immediately follow the Doxygen tag `\brief` (or `\details` if it exists).<br>
222%> Example: [pm.sampling.Paradram](@ref Paradram).<br>
223%> + The Doxygen tag `\return`, must be exclusively used to indicate the return value of functions.<br>
224%> If it exists, it must appear immediately after the set of `\param` tags. Example: [pm.sampling.Paradram](@ref Paradram).<br>
225%> + If a generic interface is being documented, the ParaMonte custom command <tt>\\interface</tt> must appear immediately
226%> after the Doxygen `\return`, `\param`, `\details`, or `\brief` tags in the specified order, if any exists.<br>
227%> + The Doxygen tag `\warning`, if any number of it exists, must immediately follow the Doxygen tag `\return` if it exists,
228%> otherwise `\param` if it exists, otherwise `\details` if it exists, otherwise `\brief`.<br>
229%> The `\warning` tag must be used to highlight situations that require special attention of the user,
230%> otherwise, there is a danger for the code section being documented to not behave normally as one may expect.<br>
231%> + The Doxygen tag `\attention` has the same functionality and usage as `\warning`.<br>
232%> Therefore, `\warning` should be preferred wherever `\attention` is needed.<br>
233%> Exceptions are allowed and if they occur, the same documentation conventions as those of `\warning` also apply to the tag `\attention`.<br>
234%> + The Doxygen tag `\remark`, if any number of it exists, must immediately follow the Doxygen tag `\warning` if it exists,
235%> otherwise the Doxygen tag `\return` if it exists, otherwise `\param` if it exists, otherwise `\details` if it exists, otherwise `\brief`.<br>
236%> The tag `\remark` should be reserved for explaining behavior that is **directly** related to the code segment being documented,
237%> but its knowledge is not so critical as warrant the use of a `\warning` tag.<br>
238%> + The Doxygen tag `\note`, if it exists, must appear after all `\warning` and `\attention` and `\remark` tags and
239%> immediately before the ParaMonte custom command tag `\see` if it exists, otherwise immediately before <tt>\\example</tt> for examples (if it exists).<br>
240%> + The Doxygen tag `\see`, if it exists, must appear after all `\warning` and `\remark` and `\note` tags.<br>
241%> If more than one item for the `\see` command exists, each must be written on a separate line and each line must end with the HTML line-break tag `<br>`.
242%> Example: See [below](#example-ParaMonteLangDocumentationGuidelines).<br>
243%> + If any example exists, it must appear immediately after the `\see` tag, otherwise after `\note`, `\remark`, `\warning`, `\param`, `\details`, or `\brief` if any exists.<br>
244%> ParaMonte examples are initiated by the custom command <tt>\\example</tt> devised in the `config.txt` file of ParaMonte Doxygen documentation.<br>
245%> If the example exists in an external file, then it must be included via the Doxygen `\include` command, followed immediately by
246%> the ParaMonte custom Doxygen command <tt>\\compile</tt> which inserts the generic example compile commands for the example, followed optionally
247%> but immediately by the output file of the example inserted in the documentation via the `\include` command, followed immediately by the inclusion
248%> of any other visualization or postprocessing scripts and output.<br>
249%> <b>In all steps, it is imperative to not leave any empty lines between the successive commands of the example
250%> section</b>, designated by the <tt>\\example</tt>, otherwise, each empty line will start a new paragraph in the documentation.<br>
251%> Example: See [below](#example-ParaMonteLangDocumentationGuidelines).<br>
252%> + The Doxygen `\test` tag, if any exists, must appear immediately after the example section designated by the <tt>\\example</tt> tag.<br>
253%> + The Doxygen `\bug` tag, if any exists, must appear immediately after the `\test` tag or any other tag immediately preceding it.<br>
254%> + The Doxygen `\todo` tag, if any exists, must appear immediately after the `\todo` tag or any other tag immediately preceding it.<br>
255%> + The closing command of each documentation section must be the ParaMonte custom command <tt>\\final</tt> separated from the tags before and after by an empty line.<br>
256%> + The Doxygen `\author` tag is the last command to appear in any documentation section, and it must preferably have the format exemplified in the example below.<br>
260%> + **ParaMonte Doxygen custom commands**.<br>
261%> To simplify documentation and avoid retyping certain frequently used keywords and sentences, a number of Doxygen aliases are predfined
262%> in the ParaMonte Doxygen `config.txt` file. These include (but are not limited to):
263%> + <tt>\\warnpure</tt> Inserts a `\warning` about procedures that are `impure` when the library is built the preprocessor macro `CHECK_ENABLED=1`.
264%> + <tt>\\elemental</tt> Inserts a `\remark` tag indicating that the procedure of interest is `elemental`.
265%> + <tt>\\pure</tt> Inserts a `\remark` tag indicating that the procedure of interest is `pure`.
266%> + <tt>\\interface</tt> Starts a **Possible calling interfaces** paragraph where different calling interfaces of a procedure can be listed.
267%> + <tt>\\benchmark</tt> Starts a new **Benchmark** paragraph which is hyper-linked to the generic anchor `#benchmark` at the same location on the same page.
268%> + <tt>\\benchmark{xxx}</tt> Starts a new **Benchmark** paragraph which is hyper-linked to the specific anchor `#benchmark-xxx` at the same location on the same page.
269%> + <tt>\\benchmark{xxx, This is the benchmark title}</tt> Starts a new **Benchmark** paragraph which is hyper-linked to
270%> the specific anchor `#benchmark-xxx` at the same location on the same page with the title `This is the benchmark title`.
271%> + <tt>\\example</tt> Starts a new **Example usage** paragraph which is hyper-linked to the generic anchor `#example` at the same location on the same page.
272%> + <tt>\\example{xxx}</tt> Starts a new **Example usage** paragraph which is hyper-linked to the specific anchor `#example-xxx` at the same location on the same page.
273%> + <tt>\\compile</tt> Inserts the set of example compile commands.
274%> + <tt>\\output</tt> Inserts a title line for the output section of an example paragraph.
275%> + <tt>\\postproc</tt> Inserts a title line for the postprocessing section of an example paragraph.
276%> + <tt>\\abbr</tt> Inserts a `\remark` tag about the naming abbreviations used in the library.
277%> + <tt>\\naming</tt> Inserts a `\remark` tag about the naming conventions used in the library.
278%> + <tt>\\license</tt> Inserts a `\remark` tag about the generic licensing of the library.
279%> + <tt>\\final</tt> Inserts the set of final generic remarks that should appear at the end of each documentation section.
283%> For an up-to-date list of all available aliases, check the value of the Doxygen `ALIASES` option in `config.txt` in the ParaMonte MATLAB documentation repository.
285%> + **Escaping the Doxygen reserved characters**.<br>
286%> Doxygen has a set of reserved characters whose usage in the documentation must be handled properly.<br>
287%> + Most importantly, the backslash character `\` begins a Doxygen command.<br>
288%> To print a backslash character to the output one should escape it via `\\`.<br>
289%> + Also, the use of the percentage symbol `%` requires special care in some instances.<br>
290%> This is particularly important when defining Windows environment variables that should typically be enclosed with percentage character.<br>
293%> For more information, see [the relevant page on Doxygen documentation website](https:
296%> + Avoid the insertion of an empty documentation line between any two lines of a single Doxygen paragraph.<br>
297%> This is crucial when the whole paragraph is indented by a vertical line as is done by Doxygen for `\warning`, `\remark`, `\note` and other similar tags.<br>
298%> \example{ParaMonteLangDocumentationGuidelines}
299%> The following is an example documentation for a procedure:
303%> This is the ParaDRAM class for generating instances of serial and parallel
304%> Delayed-Rejection Adaptive Metropolis-Hastings Markov Chain Monte Carlo
305%> sampler of the ParaMonte MATLAB library.<br>
308%> Once you assign the desired simulation specifications to the corresponding
309%> attributes within the component `spec` of an object of class [pm.sampling.Paradram](@ref Paradram),
310%> call the ParaDRAM sampler via the object method [pm.sampling.Paradram.run()](@ref Paradram::run).<br>
312%> While the constructor of this class does not take any input arguments,
313%> all ParaDRAM simulation specifications can be set after creating the object.<br>
316%> ``sampler`` : The output scalar object of class [pm.sampling.Paradram](@ref Paradram).<br>
318%> \interface{Paradram}
321%> sampler = pm.sampling.Paradram();
326%> When
using the ParaMonte MATLAB library functionalities, particularly ParaMonte samplers in
parallel,
327%> it would be best to close any such aggressive software/applications as Dropbox, ZoneAlarm, ...
328%> that interfere with your ParaMonte MATLAB library output files, potentially causing the tasks
329%> to fail and crash before successful completion.<br>
330%> These situations happen only scarcely.<br>
333%> On Windows systems, when restarting an old interrupted ParaDRAM simulation,
334%> ensure your MATLAB session is also restarted before the simulation restart.<br>
335%> This may be needed as Windows sometimes locks access to some or all of the simulation output files.<br>
338%> To unset an already-set input simulation specification, simply set the
339%> simulation attribute to empty
double `[]` or re-instantiate the
object.<br>
342%> [ParaDRAM simulation specifications listing](\pmdoc_usage_sampling/paradram/specifications/)<br>
343%> [ParaDRAM simulation restart functionality](\pmdoc_usage_sampling/paradram/restart/)<br>
344%> [ParaDRAM simulation output files](\pmdoc_usage_sampling/paradram/output/)<br>
346%> Example Usage: Serial
347%> ---------------------
349%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.
351%> Here is a MATLAB script ``main.m``
for a serial ParaDRAM simulation.<br>
352%> Copy and paste the following code into your MATLAB session:<br>
356%> sampler = pm.sampling.Paradram();
357%> sampler.run ( @(x) - sum(x.^2) ...
getLogFunc: the natural log of the objective function.
358%> , 4 ... ndim: the number of dimensions of the objective function.
360%> samples = sampler.readSample();
361%> sample = samples{1};
362%> tile = pm.vis.TileLine(sample.df);
363%> tile.make(
"coly", sample.slfc + 1 : sample.slfc + 4,
"colc",
"sampleLogFunc");
367%> The mathematical objective function in the above example is a
368%> is a multivariate Normal distribution centered at the origin,
369%> whose natural logarithm is returned by the lambda (``Anonymous``)
370%> function defined as a function handle input to the ParaDRAM sampler.<br>
372%> Running
this code will generate a set of simulation output files (in the current working directory of MATLAB).<br>
373%> Among these, the file suffixed with
"_report.txt" contains the full description of all input specifications
374%> of the ParaDRAM simulation as well as other information about the simulation results.<br>
376%> Example Usage: Thread-Parallel
377%> ------------------------------
379%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.<br>
381%> Threading parallelism is possible as of ParaMonte MATLAB
version ``3.0.0``.<br>
382%> However, only ``singleChain`` ParaDRAM simulations are supported.<br>
384%> Here is a MATLAB script ``main.m``
for a thread-
parallel ParaDRAM simulation.<br>
385%> Copy and paste the following code and paste into your MATLAB session:<br>
389%> sampler = pm.sampling.Paradram();
390%> sampler.spec.parallelismNumThread = 0; % use all available threads.
391%> sampler.run ( @(x) - sum(x.^2) ...
getLogFunc: the natural log of the objective function.
392%> , 4 ... ndim: the number of dimensions of the objective function.
394%> samples = sampler.readSample();
395%> sample = samples{1};
396%> sample.vis.tile.line.make();
400%> The statement ``sample.vis.tile.line.make();`` in
401%> the above is equivalent to the following set of lines:
405%> tile = pm.vis.TileLine(sample.df);
406%> tile.make(
"coly", sample.slfc + 1 : sample.slfc + 4,
"colc",
"sampleLogFunc");
410%> The mathematical objective function in the above example is a
411%> is a multivariate Normal distribution centered at the origin,
412%> whose natural logarithm is returned by the lambda (``Anonymous``)
413%> function defined as a function handle input to the ParaDRAM sampler.<br>
415%> Running
this code will generate a set of simulation output files (in the current working directory of MATLAB).<br>
416%> Among these, the file suffixed with ``
"_report.txt"`` contains the full description of all input specifications
417%> of the ParaDRAM simulation as well as other information about the simulation results.<br>
419%> Specifying ``0`` as the number of threads will lead to
using
420%> all available CPU threads
for thread-
parallel ParaDRAM simulation.<br>
423%> **Benefits of thread-parallelism**<br>
424%> Thread-
parallel simulations offer a much more flexible
425%> and easier approach to benefiting from parallelism without
426%> going through the hassle of MPI-
parallel simulations.<br>
427%> But they can still potentially offer much faster speed than serial simulations.<br>
428%> The actual speedup depends on a lot of factors.<br>
429%> Moreover, the number of threads is limited to maximum
430%> number of physical cores available on your system.<br>
431%> As such, thread-
parallel simulations are not scalable.<br>
432%> If you need scalability, checkout MPI-parallelism below.<br>
434%> Example Usage: MPI-Parallel
435%> ---------------------------
437%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.<br>
439%> MPI-
parallel simulations can be slightly more cumbersome than thread-
parallel simulations
440%> described above because MPI-
parallel simulations cannot be performed from within a MATLAB GUI
441%> session and require launching MATLAB via a compatible ``mpiexec`` launcher.<br>
444%> <li> Ensure you need and will get a speedup by running the an MPI-
parallel simulation.<br>
445%> Typically, your simulation may then benefit from parallelism only
if a single
446%> evaluation of the objective function takes longer than a few milliseconds.<br>
448%> <li> Ensure the required MPI libraries are installed on your system
449%> (You can skip
this step
if you know that you already have
450%> a compatible MPI library installed on your system).<br>
451%> On the MATLAB command line type the following,<br>
455%> This will
verify the existence of a valid MPI library on your system and,
456%>
if missing, will guide you to
install the MPI library on your system.<br>
458%> <li> Once the MPI installation is verified,
copy and paste the following
459%> code into your MATLAB session:
462%> fid = fopen(
"main_mpi.m",
"w");
464%>
"sampler = pm.sampling.Paradram();" + newline + ...
465%>
"%sampler.mpiname = ''; % set this to an explicit MPI library name if needed." + newline + ...
466%>
"sampler.run( @(x) - sum(x.^2) ... getLogFunc: the natural log of the objective function." + newline + ...
467%>
" , 4 ... ndim: the number of dimensions of the objective function" + newline + ...
469%> fprintf(fid,
"%s\n", sourceCode);
474%> <li> This will generate a ``main_mpi.m`` MATLAB script file in the current working directory of your MATLAB session.<br>
475%> Now, you can execute
this MATLAB script file (``main_mpi.m``) in
parallel.<br>
476%> To do so, you need to call MATLAB on a command-line, **out of MATLAB GUI**.<br>
478%> <li> **On Windows**:<br>
479%> From within command prompt that recognizes both MATLAB and ``mpiexec``,
480%> ideally, the Intel dedicated command-prompt that is shipped with Intel MPI library,
481%> type the following,
484%> mpiexec -localonly -n 3 matlab -batch
"main_mpi"
489%> In the above MPI launcher command
for Windows OS,
490%> we assumed that you would be
using the Intel MPI library, hence,
491%> the reason
for the extra flag ``-localonly``.<br>
492%> This flag runs the
parallel code only on one node, but in doing so,
493%> it avoids the use of Hydra service and its registration.<br>
494%> If you are not on a Windows cluster, (e.g., you are
using your personal device),
495%> then we recommend specifying
this flag.<br>
497%> <li> **On macOS/Linux**:<br>
498%> From within a Bash terminal that recognizes both MATLAB and ``mpiexec``,
499%> type the following,
502%> mpiexec -n 3 matlab -batch
"main_mpi"
507%> In both cases in the above, the script ``main_mpi.m`` will run on 3 processors.<br>
508%> Feel free to change the number of processors to any number desired.<br>
509%> But
do not request more than the available number of physical cores on your system.<br>
514%> Do not add postprocessing codes (such as reading and plotting the output samples) in your MPI-
parallel code.<br>
515%> There is no point in doing so, since MATLAB will run in ``-batch`` mode
for parallel simulations, disabling all plotting capabilities.<br>
516%> Moreover,
if you read and postprocess the output files in
parallel mode, the task will be done
517%> by all
parallel processes, potentially overwriting external IO activities of each other.<br>
518%> Only perform the sampling as described above in MPI-
parallel mode.<br>
520%> ParaDRAM Simulation Specifications
521%> ----------------------------------
523%> The ParaDRAM simulation specifications have lengthy comprehensive descriptions
524%> that appear in full in the output report files of every ParaDRAM simulation.<br>
526%> The best way to learn about individual ParaDRAM simulation attributes
527%> is to a run a minimal serial simulation as given in the above.<br>
528%> You can also use the ``sampler.spec.doc()`` method:
531%> sampler = pm.sampling.Paradram();
532%> sampler.spec.doc();
538%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
542%> The above example documentation snippet will generate [an HTML similar to
this documentation](@ref
Paradram).<br>
543%> Note the lack of an empty line among the commands that immediately follow <tt>\\example</tt>.<br>
544%> This is essential to keep the entire example section in the same paragraph.
548%> [⛓](#ParaMonteLangExamples)
549%> \section ParaMonteLangExamples ParaMonte MATLAB Language Examples
551%> The ParaMonte MATLAB library ships with hundreds of example usage that are available in the `example/matlab` folder in the [
root directory of the project repository](https:
552%> These examples are also available and discussed in the documentations of individual modules and procedures of
this this documentation website.<br>
554%> [⛓](#ParaMonteLangBenchmarks)
555%> \section ParaMonteLangBenchmarks ParaMonte MATLAB Language Benchmarks
557%> The ParaMonte MATLAB library currently does not ship with any benchmarks.<br>
558%> If you would like to see a relevant benchmark currently not included, [discuss it here](https:
559%> or [raise an issue here](https:
561%> [⛓](#ParaMonteLangDocumentationTroubleshooting)
562%> \section ParaMonteLangDocumentationTroubleshooting ParaMonte MATLAB Documentation Troubleshooting
565%> <li> **Side navigation pane disappears in some documentation pages.**<br>
566%> This issue most likely originates from the interference of browser addons with the documentation.<br>
567%> This issue is mostly observed on Firefox browsers.<br>
568%> If it occurs, open the page in *browser
private mode* or use other (e.g., chrome-based) browsers.<br>
571%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function verify(in varval, in vartype, in varsize, in varname)
Verify the type and number of elements of the input varval match the specified input vartype and vars...
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
function index(in array)
Given array(1 : n), return the array index indx(1 : n) such that array(indx) is in ascending order.
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
This is the ParaDRAM class for generating instances of serial and parallel Delayed-Rejection Adaptive...
function copy(in from, in to, in field, in exclude)
Copy the contents of the struct/object from to the struct/object to recursively and without destroyin...
function getLogFunc(in point)
function href(in url)
Return an HTML-style decoration of the input URL if the ParaMonte MATLAB library is used in GUI,...
function install(in vendor, in isyes)
Install or provide instructions to install the MPI library from the requested input MPI vendor.
function parallel()
Return a scalar MATLAB logical that is true if and only if the current installation of MATLAB contain...
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.