Package com.bayesserver.data.sampling
Class DataSampler
- java.lang.Object
-
- com.bayesserver.data.sampling.DataSampler
-
public final class DataSampler extends Object
Generates samples from a Bayesian network or Dynamic Bayesian network. SeetakeSample(com.bayesserver.inference.Evidence, com.bayesserver.RandomNumberGenerator, com.bayesserver.data.sampling.DataSamplingOptions)
for sample code.
-
-
Constructor Summary
Constructors Constructor Description DataSampler(Network network)
Initializes a new instance of theDataSampler
class.DataSampler(Network network, Evidence fixedData)
Initializes a new instance of theDataSampler
class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Network
getNetwork()
Gets the Bayesian network or Dynamic Bayesian network that was used in the constructor.void
setFixedData(Evidence value)
Sets any evidence that should be fixed for each sample.void
takeSample(Evidence sampleData, RandomNumberGenerator random, DataSamplingOptions options)
Generates sample data from the Bayesian network or Dynamic Bayesian network.
-
-
-
Constructor Detail
-
DataSampler
public DataSampler(Network network)
Initializes a new instance of theDataSampler
class.- Parameters:
network
- The Bayesian network or Dynamic Bayesian network the samples will be taken from.
-
DataSampler
public DataSampler(Network network, Evidence fixedData)
Initializes a new instance of theDataSampler
class.- Parameters:
network
- The Bayesian network or Dynamic Bayesian network the samples will be taken from.fixedData
- Any data that is fixed. Can be null.
-
-
Method Detail
-
getNetwork
public Network getNetwork()
Gets the Bayesian network or Dynamic Bayesian network that was used in the constructor.- Returns:
- The Bayesian network or Dynamic Bayesian network.
-
takeSample
public void takeSample(Evidence sampleData, RandomNumberGenerator random, DataSamplingOptions options) throws InconsistentEvidenceException
Generates sample data from the Bayesian network or Dynamic Bayesian network. Each call totakeSample(com.bayesserver.inference.Evidence, com.bayesserver.RandomNumberGenerator, com.bayesserver.data.sampling.DataSamplingOptions)
generates a single sample. Call repeatedly to generate multiple samples.For Dynamic Bayesian networks, see
DataSamplingOptions.getSequenceLength()
to change the length of generated sequences.- Parameters:
sampleData
- Evidence instance to hold the sample data.random
- Random number generator.options
- The sampling options.- Throws:
InconsistentEvidenceException
- Raised if the generation of a sample leads to inconsistent evidence.
-
setFixedData
public void setFixedData(Evidence value)
Sets any evidence that should be fixed for each sample.
-
-