unbbayes.simulation.montecarlo.sampling
Class MatrixMonteCarloSampling

java.lang.Object
  extended by unbbayes.simulation.montecarlo.sampling.AMonteCarloSampling
      extended by unbbayes.simulation.montecarlo.sampling.MatrixMonteCarloSampling
All Implemented Interfaces:
IMonteCarloSampling, ILongTaskProgressObservable
Direct Known Subclasses:
LikelihoodWeightingSampling

public class MatrixMonteCarloSampling
extends AMonteCarloSampling

Class that implements the Monte Carlo simulation. It uses forward sampling to calculate a RV's probability mass function. Based on its pmf, it then calculates the cumulative density function. Finally, a random number between 0 and 1 is generated and the sampled state is defined by the state the random number relates based on its cdf.

Author:
Danilo Custodio, Rommel Carvalho

Field Summary
 
Fields inherited from class unbbayes.simulation.montecarlo.sampling.AMonteCarloSampling
currentProgress, currentProgressStatus, factors, maxProgress, nTrials, pn, sampledStatesMap, sampledStatesMatrix, samplingNodeOrderQueue, timesSampled
 
Constructor Summary
MatrixMonteCarloSampling()
           
 
Method Summary
 byte[][] getSampledStatesCompactMatrix()
          Returns the generated compact sample matrix.
 Map<Integer,Integer> getSampledStatesMap()
          Not implemented.
 byte[][] getSampledStatesMatrix()
          Returns the generated sample matrix.
 int[] getStatesSetTimesSampled()
          Not implemented.
protected  void simulate(int nTrial)
          Responsible for simulating MC for sampling.
 void start(ProbabilisticNetwork pn, int nTrials)
          Generates the MC sample with the given size for the given probabilistic network.
 
Methods inherited from class unbbayes.simulation.montecarlo.sampling.AMonteCarloSampling
addToSamplingOrderQueue, computeFactors, createSamplingOrderQueue, getCumulativeDistributionFunction, getCurrentProgress, getCurrentProgressStatus, getIndexInQueue, getLinearCoord, getMaxProgress, getMultidimensionalCoord, getParentsIndexesInQueue, getPercentageDone, getProbabilityMassFunction, getSamplingNodeOrderQueue, getState, initSamplingOrderQueue, notityObservers, registerObserver, removeObserver, updateProgress, updateProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatrixMonteCarloSampling

public MatrixMonteCarloSampling()
Method Detail

getSampledStatesCompactMatrix

public byte[][] getSampledStatesCompactMatrix()
Description copied from class: AMonteCarloSampling
Returns the generated compact sample matrix. The row represents the ith sampled state set and the column represents the jth node from the sampled order. The value matrix[i][j] represents the sampled state index (respecting the node's states order) for the jth node in the ith sampled state set. To get the number of times the ith set of states was sampled use getStatesSetTimesSampled().

Specified by:
getSampledStatesCompactMatrix in interface IMonteCarloSampling
Specified by:
getSampledStatesCompactMatrix in class AMonteCarloSampling
Returns:
The generated compact sample matrix.

getStatesSetTimesSampled

public int[] getStatesSetTimesSampled()
Not implemented.

Specified by:
getStatesSetTimesSampled in interface IMonteCarloSampling
Specified by:
getStatesSetTimesSampled in class AMonteCarloSampling
Returns:
null.

getSampledStatesMap

public Map<Integer,Integer> getSampledStatesMap()
Not implemented.

Specified by:
getSampledStatesMap in interface IMonteCarloSampling
Specified by:
getSampledStatesMap in class AMonteCarloSampling
Returns:
null.

getSampledStatesMatrix

public byte[][] getSampledStatesMatrix()
Returns the generated sample matrix.

Specified by:
getSampledStatesMatrix in interface IMonteCarloSampling
Specified by:
getSampledStatesMatrix in class AMonteCarloSampling
Returns:
The generated sample matrix.

start

public void start(ProbabilisticNetwork pn,
                  int nTrials)
Generates the MC sample with the given size for the given probabilistic network.

Specified by:
start in interface IMonteCarloSampling
Specified by:
start in class AMonteCarloSampling
Parameters:
pn - Probabilistic network that will be used for sampling.
nTrials - Number of trials to generate.

simulate

protected void simulate(int nTrial)
Responsible for simulating MC for sampling.

Parameters:
nTrial - The trial number to simulate.


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.