ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
Contents.m
Go to the documentation of this file.
1%> \mainpage
2%>
3%> \tableofcontents
4%>
5%> This is the <b>ParaMonte MATLAB</b> documentation website for the MATLAB users and developers.
6%>
7%> [⛓](#ParaMonte)
8%> <!--==============================-->
9%> \section ParaMonte What is ParaMonte?
10%> <!--==============================-->
11%>
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
15%>
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.
21%>
22%> [⛓](#ParaMonteRepository)
23%> <!--==================================================-->
24%> \section ParaMonteRepository ParaMonte Project Repository
25%> <!--==================================================-->
26%>
27%> The ParaMonte library is open-source and is permanently located and maintained on **GitHub** at:
28%>
29%> &emsp;<a href="https://github.com/cdslaborg/paramonte" target="_blank"><b>https://github.com/cdslaborg/paramonte</b></a>
30%>
31%> [⛓](#ParaMonteReleases)
32%> <!--===============================================-->
33%> \section ParaMonteReleases ParaMonte Prebuilt Releases
34%> <!--===============================================-->
35%>
36%> The pre-built releases of the ParaMonte library for select configurations and compilers are available on **GitHub Release** page at:
37%>
38%> &emsp;<a href="https://github.com/cdslaborg/paramonte/releases" target="_blank"><b>https://github.com/cdslaborg/paramonte/releases</b></a>
39%>
40%> For instructions to build the ParaMonte library from source files, visit the ParaMonte library main documentation website [linked below](@ref ParaMonteDocumentation).
41%>
42%> [⛓](#ParaMonteDocumentation)
43%> <!--========================================================-->
44%> \section ParaMonteDocumentation ParaMonte Documentation Website
45%> <!--========================================================-->
46%>
47%> For information about the ParaMonte library in general and in other supported programming languages, visit:
48%>
49%> &emsp;<a href="https://www.cdslab.org/paramonte" target="_blank"><b>https://www.cdslab.org/paramonte</b></a>
50%>
51%> [⛓](#ParaMonteLangDocumentation)
52%> \section ParaMonteLangDocumentation ParaMonte MATLAB Documentation Website
53%>
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>
55%>
56%> [⛓](#ParaMonteUsage)
57%> <!--============================================-->
58%> \section ParaMonteUsage ParaMonte MATLAB QuickStart
59%> <!--============================================-->
60%>
61%> For more information on the installation, general usage, and examples, visit:
62%>
63%> &emsp;<a href="https://www.cdslab.org/paramonte/generic/latest/installation/matlab/" target="_blank"><b>https://www.cdslab.org/paramonte/generic/latest/installation/matlab/</b></a>
64%>
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>
67%>
68%> \code{.m}
69%>
70%> pmlibRootDir = './'; % Change this to the directory containing the ParaMonte MATLAB package `+pm`.
71%> addpath(pmlibRootDir);
72%> pm.lib.version();
73%> doc pm
74%>
75%> \endcode
76%>
77%> [⛓](#ParaMonteLangModules)
78%> \section ParaMonteLangModules ParaMonte MATLAB Library Modules
79%>
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,
83%>
84%> \code{.m}
85%> pm.lib.version()
86%> \endcode
87%>
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>
91%>
92%> [⛓⛓](#ParaMonteLangModulesSamplers)
93%> \section ParaMonteLangModulesSamplers ParaMonte MATLAB Library Samplers
94%>
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>
97%>
98%> [⛓](#ParaMonteLangNamingConventions)
99%> \section ParaMonteLangNamingConventions ParaMonte MATLAB Naming Conventions
100%>
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>
104%>
105%> [⛓⛓](#ParaMonteLangNamingConventionsVariables)
106%> \subsection ParaMonteLangNamingConventionsVariables ParaMonte MATLAB Naming Conventions: Variables
107%>
108%> By convention in this library,
109%>
110%> + All variables and procedure names except compile-time constants begin with an lowercase letter.
111%>
112%> + All constants and parameters should generally be typed in uppercase.
113%>
114%> + The names of variables that **always** represent vectors of values **may** be suffixed with `Vec` or `Vector`.
115%>
116%> + The names of variables that **always** represent matrices of values **may** be suffixed with `Mat` or `Matrix`.
117%>
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>
124%>
125%> [⛓⛓](#ParaMonteLangNamingConventionsProcedures)
126%> \subsection ParaMonteLangNamingConventionsProcedures ParaMonte MATLAB Naming Conventions: Procedures
127%>
128%> + Procedure names should be descriptive of the action performed by the procedure. For example,
129%>
130%> + `getCov` means *generate (a) covariance matrix*.
131%> + `setMatCopy` means *copy the matrix into the specified buffer*.
132%>
133%> + Procedure names should preferably begin with a lowercase verb.
134%>
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.
138%>
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>
143%>
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.`.
147%>
148%> [⛓](#ParaMonteLangAbbreviationGuidlines)
149%> \section ParaMonteLangAbbreviationGuidlines ParaMonte MATLAB Abbreviation Guidelines
150%>
151%> The following list of abbreviations is in alphabetical order to enable faster search:
152%>
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`.
205%>
206%> [⛓](#ParaMonteLangDeveloperWarnings)
207%> \section ParaMonteLangDeveloperWarnings ParaMonte MATLAB Developer Guidelines and Warnings
208%>
209%> The ParaMonte MATLAB library development and guidelines are summarized in
210%> <a href="https://github.com/cdslaborg/paramonte/blob/main/src/matlab/CONTRIBUTING.md" target="_blank">CONTRIBUTING.md</a>.
211%>
212%> [⛓](#ParaMonteLangDocumentationGuidelines)
213%> \section ParaMonteLangDocumentationGuidelines ParaMonte MATLAB Documentation Guidelines
214%>
215%> + **Doxygen custom command orderings**.
216%>
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>
257%> <br>
258%> <br>
259%>
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.
280%> <br>
281%> <br>
282%>
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.
284%>
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>
291%> <br>
292%>
293%> For more information, see [the relevant page on Doxygen documentation website](https://www.doxygen.nl/manual/commands.html#cmdfdollar).
294%> <br>
295%>
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:
300%> \verbatim
301%>
302%> \brief
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>
306%>
307%> \brief
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>
311%>
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>
314%>
315%> \return
316%> ``sampler`` : The output scalar object of class [pm.sampling.Paradram](@ref Paradram).<br>
317%>
318%> \interface{Paradram}
319%> \code{.m}
320%>
321%> sampler = pm.sampling.Paradram();
322%>
323%> \endcode
324%>
325%> \warning
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>
331%>
332%> \note
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>
336%>
337%> \note
338%> To unset an already-set input simulation specification, simply set the
339%> simulation attribute to empty double `[]` or re-instantiate the object.<br>
340%>
341%> \see
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>
345%>
346%> Example Usage: Serial
347%> ---------------------
348%>
349%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.
350%>
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>
353%>
354%> \code{.m}
355%>
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.
359%> );
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");
364%>
365%> \endcode
366%>
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>
371%>
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>
375%>
376%> Example Usage: Thread-Parallel
377%> ------------------------------
378%>
379%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.<br>
380%>
381%> Threading parallelism is possible as of ParaMonte MATLAB version ``3.0.0``.<br>
382%> However, only ``singleChain`` ParaDRAM simulations are supported.<br>
383%>
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>
386%>
387%> \code{.m}
388%>
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.
393%> );
394%> samples = sampler.readSample();
395%> sample = samples{1};
396%> pm.vis.tile(sample.contents)
397%>
398%> \endcode
399%>
400%> The mathematical objective function in the above example is a
401%> is a multivariate Normal distribution centered at the origin,
402%> whose natural logarithm is returned by the lambda (``Anonymous``)
403%> function defined as a function handle input to the ParaDRAM sampler.<br>
404%>
405%> Running this code will generate a set of simulation output files (in the current working directory of MATLAB).<br>
406%> Among these, the file suffixed with ``"_report.txt"`` contains the full description of all input specifications
407%> of the ParaDRAM simulation as well as other information about the simulation results.<br>
408%>
409%> Specifying ``0`` as the number of threads will lead to using
410%> all available CPU threads for thread-parallel ParaDRAM simulation.<br>
411%>
412%> \note
413%> **Benefits of thread-parallelism**<br>
414%> Thread-parallel simulations offer a much more flexible
415%> and easier approach to benefiting from parallelism without
416%> going through the hassle of MPI-parallel simulations.<br>
417%> But they can still potentially offer much faster speed than serial simulations.<br>
418%> The actual speedup depends on a lot of factors.<br>
419%> Moreover, the number of threads is limited to maximum
420%> number of physical cores available on your system.<br>
421%> As such, thread-parallel simulations are not scalable.<br>
422%> If you need scalability, checkout MPI-parallelism below.<br>
423%>
424%> Example Usage: MPI-Parallel
425%> ---------------------------
426%>
427%> First, ensure the ParaMonte ``+pm`` package (i.e., folder) is available in your MATLAB paths.<br>
428%>
429%> MPI-parallel simulations can be slightly more cumbersome than thread-parallel simulations
430%> described above because MPI-parallel simulations cannot be performed from within a MATLAB GUI
431%> session and require launching MATLAB via a compatible ``mpiexec`` launcher.<br>
432%>
433%> <ol>
434%> <li> Ensure you need and will get a speedup by running the an MPI-parallel simulation.<br>
435%> Typically, your simulation may then benefit from parallelism only if a single
436%> evaluation of the objective function takes longer than a few milliseconds.<br>
437%>
438%> <li> Ensure the required MPI libraries are installed on your system
439%> (You can skip this step if you know that you already have
440%> a compatible MPI library installed on your system).<br>
441%> On the MATLAB command line type the following,<br>
442%> \code{.m}
443%> pm.lib.verify();
444%> \endcode
445%> This will verify the existence of a valid MPI library on your system and,
446%> if missing, will guide you to install the MPI library on your system.<br>
447%>
448%> <li> Once the MPI installation is verified, copy and paste the following
449%> code into your MATLAB session:
450%> \code{.m}
451%>
452%> fid = fopen("main_mpi.m", "w");
453%> sourceCode = ...
454%> "sampler = pm.sampling.Paradram();" + newline + ...
455%> "%sampler.mpiname = ''; % set this to an explicit MPI library name if needed." + newline + ...
456%> "sampler.run( @(x) - sum(x.^2) ... getLogFunc: the natural log of the objective function." + newline + ...
457%> " , 4 ... ndim: the number of dimensions of the objective function" + newline + ...
458%> " );";
459%> fprintf(fid, "%s\n", sourceCode);
460%> fclose(fid);
461%>
462%> \endcode
463%>
464%> <li> This will generate a ``main_mpi.m`` MATLAB script file in the current working directory of your MATLAB session.<br>
465%> Now, you can execute this MATLAB script file (``main_mpi.m``) in parallel.<br>
466%> To do so, you need to call MATLAB on a command-line, **out of MATLAB GUI**.<br>
467%> <ol>
468%> <li> **On Windows**:<br>
469%> From within command prompt that recognizes both MATLAB and ``mpiexec``,
470%> ideally, the Intel dedicated command-prompt that is shipped with Intel MPI library,
471%> type the following,
472%> \code{.m}
473%>
474%> mpiexec -localonly -n 3 matlab -batch "main_mpi"
475%>
476%> \endcode
477%>
478%> \note
479%> In the above MPI launcher command for Windows OS,
480%> we assumed that you would be using the Intel MPI library, hence,
481%> the reason for the extra flag ``-localonly``.<br>
482%> This flag runs the parallel code only on one node, but in doing so,
483%> it avoids the use of Hydra service and its registration.<br>
484%> If you are not on a Windows cluster, (e.g., you are using your personal device),
485%> then we recommend specifying this flag.<br>
486%>
487%> <li> **On macOS/Linux**:<br>
488%> From within a Bash terminal that recognizes both MATLAB and ``mpiexec``,
489%> type the following,
490%> \code{.m}
491%>
492%> mpiexec -n 3 matlab -batch "main_mpi"
493%>
494%> \endcode
495%>
496%> \note
497%> In both cases in the above, the script ``main_mpi.m`` will run on 3 processors.<br>
498%> Feel free to change the number of processors to any number desired.<br>
499%> But do not request more than the available number of physical cores on your system.<br>
500%> </ol>
501%> </ol>
502%>
503%> \warning
504%> Do not add postprocessing codes (such as reading and plotting the output samples) in your MPI-parallel code.<br>
505%> There is no point in doing so, since MATLAB will run in ``-batch`` mode for parallel simulations, disabling all plotting capabilities.<br>
506%> Moreover, if you read and postprocess the output files in parallel mode, the task will be done
507%> by all parallel processes, potentially overwriting external IO activities of each other.<br>
508%> Only perform the sampling as described above in MPI-parallel mode.<br>
509%>
510%> ParaDRAM Simulation Specifications
511%> ----------------------------------
512%>
513%> The ParaDRAM simulation specifications have lengthy comprehensive descriptions
514%> that appear in full in the output report files of every ParaDRAM simulation.<br>
515%>
516%> The best way to learn about individual ParaDRAM simulation attributes
517%> is to a run a minimal serial simulation as given in the above.<br>
518%> You can also use the ``sampler.spec.doc()`` method:
519%>
520%> \code{.m}
521%> sampler = pm.sampling.Paradram();
522%> sampler.spec.doc();
523%> \endcode
524%>
525%> \final{Paradram}
526%>
527%> \author
528%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
529%>
530%> \endverbatim
531%> <br>
532%> The above example documentation snippet will generate [an HTML similar to this documentation](@ref Paradram).<br>
533%> Note the lack of an empty line among the commands that immediately follow <tt>\\example</tt>.<br>
534%> This is essential to keep the entire example section in the same paragraph.
535%>
536%> <br>
537%>
538%> [⛓](#ParaMonteLangExamples)
539%> \section ParaMonteLangExamples ParaMonte MATLAB Language Examples
540%>
541%> The ParaMonte MATLAB library ships with tens of thousands of example usage that are available in the `example/matlab` folder in the [root directory of the project repository](https://github.com/cdslaborg/paramonte).<br>
542%> These examples are also available and discussed in the documentations of individual modules and procedures of this this documentation website.<br>
543%>
544%> [⛓](#ParaMonteLangBenchmarks)
545%> \section ParaMonteLangBenchmarks ParaMonte MATLAB Language Benchmarks
546%>
547%> The ParaMonte MATLAB library currently does not ship with any benchmarks.<br>
548%> If you would like to see a relevant benchmark currently not included, [discuss it here](https://github.com/cdslaborg/paramonte/discussions)
549%> or [raise an issue here](https://github.com/cdslaborg/paramonte/issues) for consideration or volunteer to implement it!<br>
550%>
551%> [⛓](#ParaMonteLangDocumentationTroubleshooting)
552%> \section ParaMonteLangDocumentationTroubleshooting ParaMonte MATLAB Documentation Troubleshooting
553%>
554%> <ol>
555%> <li> **Side navigation pane disappears in some documentation pages.**<br>
556%> This issue most likely originates from the interference of browser addons with the documentation.<br>
557%> This issue is mostly observed on Firefox browsers.<br>
558%> If it occurs, open the page in *browser private mode* or use other (e.g., chrome-based) browsers.<br>
559%> </ol>
560%>
561%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562%
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...
Definition: Paradram.m:18
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.