/** * \copydoc Simulation::simulate() */ void MetropolisHastingsSimulation::simulate() { GetRNGstate(); lScores[0].fill(0); lDerivative[0].fill(0); LOGS(Priority::DEBUG)<<"Simulate with theta: "<<rParameters().transpose(); for (int m = 0; m < lpData->observationCount() - 1; ++m) { printRNGTrace simulatePeriod(m); } PutRNGstate(); lMeanScoresMinusTargets = lScores[0]; fireResult(lResult); }
/** * Sequentially simulate each period. * * @param withSeeds True if stored seeds should be used to reset the RNG at the * beginning of each period. */ void StatisticsSimulation::simulatePeriods(bool withSeeds) { GetRNGstate(); #pragma omp parallel num_threads(lNThreads) { #pragma omp for schedule(dynamic, 1) for (unsigned int thread = 0; thread < lNThreads; ++thread) { // Run epoch simulation for each period LOGS(Priority::DEBUG) << "simulate with theta: " << rParameters().transpose(); for (int m = 0; m < lpData->observationCount() - 1; ++m) { if (withSeeds) { setSeed(lSeeds[m]); } else { getSeed(lSeeds[m]); } simulatePeriod(thread, m); } } } PutRNGstate(); }