@@ -0,0 +1,978 @@
+package com.github.rnowling.bps.datagenerator.framework.samplers;%0A%0Aimport java.util.Random;%0A%0Aimport com.github.rnowling.bps.datagenerator.framework.SeedFactory;%0Aimport com.github.rnowling.bps.datagenerator.framework.pdfs.ProbabilityDensityFunction;%0A%0A%0Apublic class MonteCarloSampler%3CT%3E implements Sampler%3CT%3E%0A%7B%0A%09private final Sampler%3CT%3E stateSampler;%0A%09private final Random rng;%0A%09private final ProbabilityDensityFunction%3CT%3E acceptancePDF;%0A%09%0A%09public MonteCarloSampler(Sampler%3CT%3E stateGenerator,%0A%09%09%09ProbabilityDensityFunction%3CT%3E acceptancePDF,%0A%09%09%09SeedFactory seedFactory)%0A%09%7B%0A%09%09this.acceptancePDF = acceptancePDF;%0A%09%09this.stateSampler = stateGenerator;%0A%09%09%0A%09%09rng = new Random(seedFactory.getNextSeed());%0A%09%7D%0A%0A%09public T sample() throws Exception%0A%09%7B%0A%09%09while(true)%0A%09%09%7B%0A%09%09%09T proposedState = this.stateSampler.sample();%0A%09%09%09double probability = acceptancePDF.probability(proposedState);%0A%09%09%09double r = rng.nextDouble();%0A%09%09%09%0A%09%09%09if(r %3C probability)%0A%09%09%09%7B%0A%09%09%09%09return proposedState;%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A%7D%0A

Add MonteCarloSampler