本文整理汇总了C#中Randomizer.nextDouble方法的典型用法代码示例。如果您正苦于以下问题:C# Randomizer.nextDouble方法的具体用法?C# Randomizer.nextDouble怎么用?C# Randomizer.nextDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Randomizer
的用法示例。
在下文中一共展示了Randomizer.nextDouble方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generateParticleSetForPredictedState
public ParticleSet generateParticleSetForPredictedState(String action,
Randomizer randomizer)
{
ParticleSet predictedParticleSet = new ParticleSet(this.hmm);
foreach (Particle p in particles)
{
String newState = hmm.transitionModel().getStateForProbability(
p.getState(), action, randomizer.nextDouble());
Particle generatedParticle = new Particle(newState);
predictedParticleSet.add(generatedParticle);
}
return predictedParticleSet;
}
示例2: mbRandomSample
/**
* Get a random sample from <b>P</b>(X<sub>i</sub> | mb(X<sub>i</sub>)),
* where mb(X<sub>i</sub>) is the Markov Blanket of X<sub>i</sub>. The
* probability of a variable given its Markov blanket is proportional to the
* probability of the variable given its parents times the probability of
* each child given its respective parents (see equation 14.12 pg. 538
* AIMA3e):<br>
* <br>
* P(x'<sub>i</sub>|mb(Xi)) =
* αP(x'<sub>i</sub>|parents(X<sub>i</sub>)) *
* ∏<sub>Y<sub>j</sub> ∈ Children(X<sub>i</sub>)</sub>
* P(y<sub>j</sub>|parents(Y<sub>j</sub>))
*
* @param Xi
* a Node from a Bayesian network for the Random Variable
* X<sub>i</sub>.
* @param event
* comprising assignments for the Markov Blanket X<sub>i</sub>.
* @param r
* a Randomizer for generating a probability choice for the
* sample.
* @return a random sample from <b>P</b>(X<sub>i</sub> | mb(X<sub>i</sub>))
*/
public static Object mbRandomSample(Node Xi,
Map<RandomVariable, Object> evt, Randomizer r)
{
return sample(r.nextDouble(), Xi.getRandomVariable(),
mbDistribution(Xi, evt));
}
示例3: perceptionUpdate
public ParticleSet perceptionUpdate(String perception, Randomizer r)
{
// compute Particle Weight
foreach (Particle p in particles)
{
double particleWeight = hmm.sensorModel().get(p.getState(),
perception);
p.setWeight(particleWeight);
}
// weighted sample to create new ParticleSet
ParticleSet result = new ParticleSet(hmm);
while (result.size() != size())
{
foreach (Particle p in particles)
{
double probability = r.nextDouble();
if (probability <= p.getWeight())
{
if (result.size() < size())
{
result.add(new Particle(p.getState(), p.getWeight()));
}
}
}
}
return result;
}
示例4: randomSample
/**
* Get a random sample from <b>P</b>(X<sub>i</sub> | parents(X<sub>i</sub>))
*
* @param Xi
* a Node from a Bayesian network for the Random Variable
* X<sub>i</sub>.
* @param event
* comprising assignments for parents(X<sub>i</sub>)
* @param r
* a Randomizer for generating a probability choice for the
* sample.
* @return a random sample from <b>P</b>(X<sub>i</sub> |
* parents(X<sub>i</sub>))
*/
public static Object randomSample(Node Xi,
Map<RandomVariable, Object> evt, Randomizer r)
{
return Xi.getCPD().getSample(r.nextDouble(),
getEventValuesForParents(Xi, evt));
}
示例5: getPriorSample
public Dictionary<String, bool> getPriorSample(Randomizer r)
{
Dictionary<String, bool> h = new Dictionary<String, bool>();
List<BayesNetNode> variableNodes = getVariableNodes();
foreach (BayesNetNode node in variableNodes)
{
h.Add(node.getVariable(), node.isTrueFor(r.nextDouble(), h));
}
return h;
}
示例6: createRandomEvent
private Dictionary<String, bool> createRandomEvent(
List<string> nonEvidenceVariables, Dictionary<String, bool> evidence,
Randomizer r)
{
Dictionary<String, bool> table = new Dictionary<String, bool>();
List<String> variables = getVariables();
foreach (String variable in variables)
{
if (nonEvidenceVariables.Contains(variable))
{
bool value = r.nextDouble() <= 0.5 ? true
: false;
table.Add(variable, value);
}
else
{
table.Add(variable, evidence[variable]);
}
}
return table;
}
示例7: truthValue
private bool truthValue(double[] ds, Randomizer r)
{
double value = r.nextDouble();
if (value < ds[0])
{
return true;
}
else
{
return false;
}
}
示例8: likelihoodWeighting
public double[] likelihoodWeighting(String X,
Dictionary<String, bool> evidence, int numberOfSamples,
Randomizer r)
{
double[] retval = new double[2];
for (int i = 0; i < numberOfSamples; i++)
{
Dictionary<String, bool> x = new Dictionary<String, bool>();
double w = 1.0;
List<BayesNetNode> variableNodes = getVariableNodes();
foreach (BayesNetNode node in variableNodes)
{
if ( evidence.ContainsKey(node.getVariable()))
{
w *= node.probabilityOf(x);
x.Add(node.getVariable(), evidence[node.getVariable()]);
}
else
{
x
.Add(node.getVariable(), node.isTrueFor(r
.nextDouble(), x));
}
}
bool queryValue = x[X];
if (queryValue)
{
retval[0] += w;
}
else
{
retval[1] += w;
}
}
return Util.normalize(retval);
}