MVN_COEF = NDIM * np.log(1. / np.sqrt(2. * np.pi)) + np.log( np.sqrt(np.linalg.det(INVCOV))) # the logarithm of objective function: log(MVN) def getLogFunc(point): ''' Return the logarithm of the MVN PDF. ''' normedPoint = MEAN - point return MVN_COEF - 0.5 * (np.dot(normedPoint, np.matmul( INVCOV, normedPoint))) import paramonte as pm pmpd = pm.ParaDRAM() # define a ParaMonte sampler instance pmpd.mpiEnabled = True # This is essential as it enables the invocation of the MPI-parallelized ParaDRAM routines. pmpd.spec.overwriteRequested = True # overwrite existing output files if needed pmpd.spec.randomSeed = 3751 # initialize the random seed to generate reproducible results. pmpd.spec.outputFileName = "./out/mvn_parallel_singleChain" pmpd.spec.progressReportPeriod = 20000 pmpd.spec.chainSize = 30000 # the default 100,000 unique points is too large for this simple example. # call the ParaDRAM sampler pmpd.runSampler(ndim=4, getLogFunc=getLogFunc)
import paramonte as pm import os import numpy as np from scipy.stats import multivariate_normal import StarFormationRate import paramonte as pm pmpd = pm.ParaDRAM() pmpd.spec.mpiFinalizeRequested = False pmpd.spec.sampleSize = 10000 pmpd.spec.domainLowerLimitVec = [0.1] pmpd.spec.domainUpperLimitVec = [100] model_names=['H06' # model names being use ,'L08' ,'B10' ,'M14' ,'M17' ,'F18' ] fileNamesPrefixList = [ "LogRate"+model in model_names] # makes list of LogRateModelName to name directory for multiple models out_dir='../out' sfr_functions = [ getattr(StarFormationRate,'get'+PrefixNames) for PrefixNames in fileNamesPrefixList] #calls functions within StarFormationRate given model names sfr_functions_len = len(sfr_functions) # length of functions used to determine when mpiFinalizeRequested will close