1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4%%%% ParaMonte: Parallel Monte Carlo and Machine Learning Library. %%%%
6%%%% Copyright (C) 2012-present, The Computational Data Science Lab %%%%
8%%%% This file is part of the ParaMonte library. %%%%
14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23format compact; format long;
25% set path to the ParaMonte MATLAB library
27pmlibRootDir =
'./'; % set
this path to the paramonte library
root dir
28addpath(genpath(pmlibRootDir));
30% change MATLAB
's working directory to the folder containing this script
32filePath = mfilename('fullpath
');
33[currentDir,fileName,fileExt] = fileparts(filePath); cd(currentDir); % Change working directory to source code directory.
34cd(fileparts(mfilename('fullpath
'))); % Change working directory to source code directory.
36% define the objective function
38NDIM = 4; % number of dimensions of the domain of the distribution
40% create a ParaMonte object
42pm = paramonte(); % use paramonte("matlab") to use the MATLAB kernel instead of interface
44% create a ParaDRAM simulation object
48% specifity path to the input specification file.
49% This is optional: all simulation specifications can be
50% also set as attributes of the pmpd.spec component of the object.
51% KEEP IN MIND: if you set pmpd.inputFile to any non-empty value, then
52% the inputFile will override any values specified via pmpd.spec properties.
53% pmpd.inputFile = fullfile( string(currentDir) , "paramonte.in" );
55pmpd.bldtype = "testing";
56pmpd.mpiEnabled = true;
57pmpd.spec.chainSize = 10000;
58pmpd.spec.randomSeed = 31731;
60pmpd.runSampler ( NDIM ... number of dimensions of the objective function
61 , @getLogFunc ... the objective function: multivariate normal distribution
64function logFunc = getLogFunc(point)
65 mean = [ 0.0;0.0;0.0;0.0 ]; % mean of the Multivariate Normal distribution
66 covmat = [ 1.0,0.5,0.5,0.5 ... covariance matrix of the Multivariate Normal distribution
70 logFunc = log(mvnpdf(point,mean,covmat));
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.
function getLogFunc(in point)