当前位置: 首页>>代码示例>>C#>>正文


C# Randomizer.nextDouble方法代码示例

本文整理汇总了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;
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:14,代码来源:ParticleSet.cs

示例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)) =
         * &alpha;P(x'<sub>i</sub>|parents(X<sub>i</sub>)) *
         * &prod;<sub>Y<sub>j</sub> &isin; 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));
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:30,代码来源:ProbUtil.cs

示例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;
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:29,代码来源:ParticleSet.cs

示例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));
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:21,代码来源:ProbUtil.cs

示例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;
 }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:10,代码来源:BayesNet.cs

示例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;
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:22,代码来源:BayesNet.cs

示例7: truthValue

        private bool truthValue(double[] ds, Randomizer r)
        {
            double value = r.nextDouble();
            if (value < ds[0])
            {
                return true;
            }
            else
            {
                return false;
            }

        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:13,代码来源:BayesNet.cs

示例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);
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:37,代码来源:BayesNet.cs


注:本文中的Randomizer.nextDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。