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


C# Random.NextNormal方法代码示例

本文整理汇总了C#中System.Random.NextNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextNormal方法的具体用法?C# Random.NextNormal怎么用?C# Random.NextNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Random的用法示例。


在下文中一共展示了Random.NextNormal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBatch

 public Batch CreateBatch(int randSeed, GeneratorParams parameters)
 {
     var rand = new Random(randSeed);
     var processeDescs = new ProcessDesc[parameters.ProcessCount];
     for (int j = 0; j < parameters.ProcessCount; j++)
     {
         processeDescs[j] = new ProcessDesc(
             cpuBurstTime: Math.Max(0, rand.NextNormal(parameters.BurstTimeMean, parameters.BurstTimeStDev)),
             delay: Math.Max(0, rand.Next(parameters.DelayMin, parameters.DelayMax)),
             priority: Math.Max(0, rand.NextNormal(parameters.PriorityMean, parameters.PriorityStDev)),
             memory: Math.Max(0, rand.NextNormal(parameters.MemoryMean, parameters.MemoryStDev)));
     }
     return new Batch(parameters.FileNameFormat, processeDescs);
 }
开发者ID:EkardNT,项目名称:CPUSchedulingSimulator,代码行数:14,代码来源:BatchCreator.cs

示例2: Run

        public static void Run(InteractiveHost plot)
        {
            // All the toolkit specific code does is one of these lines:
            // InteractiveHost plot = new Florence.GtkSharp.InteractiveHost();
            // InteractiveHost plot = new Florence.WinForms.InteractiveHost();

            // Start the interactive host; this starts up a GUI thread
            // and otherwise gets the GUI ready to go.
            plot.Start();

            // Generate some data to plot!
            var rand = new Random(0);

            var x = new double[100];
            for (int ii = 0; ii < x.Length; ++ii)
                x[ii] = rand.NextNormal(0.0, 1.0);

            var y = new double[x.Length];
            for (int ii = 0; ii < y.Length; ++ii)
                y[ii] = 2.0 + 3.0 * x[ii] + rand.NextNormal(0.0, 2.5);

            var t = new DateTime[15];
            var s = new double[t.Length];
            t[0] = new DateTime(2013,12,1);
            s[0] = 100.0;

            for (int ii = 1; ii < t.Length; ++ii)
            {
                t[ii] = t[ii-1].AddDays(1);
                s[ii] = s[ii - 1]*Math.Exp(rand.NextNormal(0.05 / 365.0, 0.15 / Math.Sqrt(365.0)));
            }

            // Create our first plot
            var plot1 = new PointPlot() { AbscissaData = x, OrdinateData = y };
            plot.Add(plot1);
            plot.XAxis1.Label = "Love of Graphs";
            plot.YAxis1.Label = "Overall Awesomeness";
            plot.Title = "Effect of Graph Affinity on Overall Awesomeness";

            // Pause execution. In an interactive environment, (C#/F# REPL) this would not be necessary
            Console.ReadLine();

            // Try putting your mouse over the numbers on either the X or Y axis,
            // pressing the mouse button then dragging left and right (for the X)
            // or up and down (for the Y).

            // Now try clicking and dragging in the main plot area.

            // Now press enter, to move on to the next example

            plot.newFigure();
            plot.Title = "A new one!";

            Console.ReadLine();

            plot.previous();
            plot.Title = "First one again!";

            Console.ReadLine();

            plot.next();
            plot.closeFigure();

            var line_plot = plot.newFigure();

            line_plot.Add(new LinePlot() { AbscissaData = t, OrdinateData = s });

            //var plot2 = new LinePlot() { AbscissaData = x, OrdinateData = y };
            //plot.Title = "Test Plot 2";
            //plot.XAxis1.Label = "X2";
            //plot.YAxis1.Label = "Y2";
            //plot.Add(plot2);

            Console.ReadLine();

            plot.Stop();
        }
开发者ID:SubaruDieselCrew,项目名称:Florence,代码行数:77,代码来源:SimpleTestCommon.cs


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