• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IRandomGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IRandomGenerator的典型用法代码示例。如果您正苦于以下问题:C# IRandomGenerator类的具体用法?C# IRandomGenerator怎么用?C# IRandomGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRandomGenerator类属于命名空间,在下文中一共展示了IRandomGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PinkNoise

        public PinkNoise(IRandomGenerator randomGenerator, float rmsAmplitude)
        {
            if (null == randomGenerator)
                throw new ArgumentNullException("randomGenerator");

            _whiteGenerator = new NormalDistribution(randomGenerator, 0, RmsScale * rmsAmplitude);
        }
开发者ID:henricj,项目名称:phonesm,代码行数:7,代码来源:PinkNoise.cs


示例2: GenerateData

        public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
        {
            var allAddedEmployees = new List<Employee>();
            var departmentIds = data.Departments.Select(d => d.Id).ToList();

            for (int i = 0; i < count; i++)
            {
                var employee = new Employee
                                   {
                                       FirstName = random.GetRandomString(random.GetRandomNumber(5, 20)),
                                       LastName = random.GetRandomString(random.GetRandomNumber(5, 20)),
                                       Salary = random.GetRandomNumber(50000, 200000),
                                       DepartmentId =
                                           departmentIds[random.GetRandomNumber(0, departmentIds.Count - 1)]
                                   };

                if (allAddedEmployees.Count > 0 && random.GetRandomNumber(1, 100) <= 95)
                {
                    employee.Employee1 = allAddedEmployees[random.GetRandomNumber(0, allAddedEmployees.Count - 1)];
                }

                allAddedEmployees.Add(employee);
            }

            data.Employees.AddRange(allAddedEmployees);
        }
开发者ID:nikistefanov,项目名称:Telerik-Academy-Homework,代码行数:26,代码来源:EmployeeDataGenerator.cs


示例3: Initialize

        public override void Initialize()
        {
            randomGenerator = GameServiceManager.GetService<IRandomGenerator>();
            ResetTimer();

            base.Initialize();
        }
开发者ID:shadercoder,项目名称:Icicle-Framework,代码行数:7,代码来源:BasicEnemySpawnerBehavior.cs


示例4: SetUp

 public void SetUp()
 {
     var builderSetup = new BuilderSettings();
     reflectionUtil = Substitute.For<IReflectionUtil>();
     generator = Substitute.For<IRandomGenerator>();
     propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false,builderSetup);
 }
开发者ID:nbuilder,项目名称:nbuilder,代码行数:7,代码来源:RandomValuePropertyNamerTests.cs


示例5: Train

        public override void Train(IList<InputOutput> trainingSet,
            IList<InputOutput> validationSet,
            IRandomGenerator rand,
            INeuralNetwork nn)
        {
            var prevWeightGradients = nn.Weights.DeepClone();

            foreach (var gradSet in prevWeightGradients)
            {
                for (var j = 0; j < gradSet.Length; j++)
                    gradSet[j] = 0;
            }

            for (var s = 0; s < NumEpochs; s++)
            {
                var t = rand.Next(trainingSet.Count);
                var inputOutput = trainingSet[t];

                var batch = GetBatch(trainingSet, BatchSize, rand);

                var gradients = nn.Weights.DeepCloneToZeros();

                for (var j = 0; j < BatchSize; j++)
                {
                    gradients.AddInPlace(
                        nn.CalculateGradients(batch[j].Input.AddRelativeNoise(MaxRelativeNoise, rand), batch[j].Output));
                }

                gradients.MultiplyInPlace(1 / ((double)BatchSize));

                //var gradients = nn.CalculateGradients(inputOutput.Input, inputOutput.Output);
                AdjustWeights(nn, gradients, prevWeightGradients);
                gradients.DeepCopyTo(prevWeightGradients);
            }
        }
开发者ID:ikhramts,项目名称:NNX,代码行数:35,代码来源:SimpleGradientTrainer.cs


示例6: GenerateData

        public void GenerateData(MongoDatabase db, IRandomGenerator random, int count)
        {
            string name;
            decimal price;
            int? upgradeToId;

            List<MongoUpgrade> mongoUpgrades = new List<MongoUpgrade>();

            for (int i = 0; i < count; i++)
            {
                name = random.GetRandomString(random.GetRandomNumber(5, 50));
                price = (decimal)(random.GetRandomNumber(10000, 1000000) / 100);
                upgradeToId = i;
                if(i % 4 == 0)
                {
                    upgradeToId = null;
                }

                var upgrade = new MongoUpgrade(name, price, upgradeToId);
                mongoUpgrades.Add(upgrade);
            }

            MongoCollection<MongoUpgrade> upgrades = db.GetCollection<MongoUpgrade>("Upgrades");
            upgrades.InsertBatch(mongoUpgrades);
        }
开发者ID:Astatine-Haphazard,项目名称:AstatineTeamwork,代码行数:25,代码来源:UpgradesDataGenerator.cs


示例7: Player

 public Player(IRandomGenerator generator, IBoard gameBoard, string name = "")
 {
     Generator = generator;
     GameBoard = gameBoard;
     Name = name;
     Position = 0;
 }
开发者ID:foxguardsolutions,项目名称:AHoward-Monopoly,代码行数:7,代码来源:Player.cs


示例8: Setup

 public void Setup()
 {
     _udp = MockRepository.GenerateMock<IStatsdUDP>();
     _randomGenerator = MockRepository.GenerateMock<IRandomGenerator>();
     _randomGenerator.Stub(x => x.ShouldSend(Arg<double>.Is.Anything)).Return(true);
     _stopwatch = MockRepository.GenerateMock<IStopWatchFactory>();
 }
开发者ID:FrancisVarga,项目名称:statsd-csharp-client,代码行数:7,代码来源:StatsdTests.cs


示例9: DefaultFieldRandomizer

		/// <summary>
		/// Initializes a new instance of the DefaultFieldRandomizer class.
		/// </summary>
		/// <param name="randomGenerator">The random generator.</param>
		public DefaultFieldRandomizer(IRandomGenerator randomGenerator)
		{
			Validation.ThrowIfNull(randomGenerator);

			this._randomGenerator = randomGenerator;
			this._totalElementsInDirection = Enum.GetNames(typeof(Direction)).Length;
		}
开发者ID:nikolay-radkov,项目名称:Telerik-Academy,代码行数:11,代码来源:DefaultFieldRandomizer.cs


示例10: GenerateData

        public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
        {
            var employeeIds = data.Employees.Select(e => e.Id).ToList();
            var projectIds = data.Projects.Select(p => p.Id).ToList();

            foreach (var employeeId in employeeIds)
            {
                var employeeProjectsCount = random.GetRandomNumber((int)(count * 0.5), (int)(count * 1.5));
                var currentProjects = new HashSet<int>();

                while (currentProjects.Count < employeeProjectsCount)
                {
                    var randomProjectId = projectIds[random.GetRandomNumber(0, projectIds.Count - 1)];
                    currentProjects.Add(randomProjectId);
                }

                foreach (var projectId in currentProjects)
                {
                    var endDateTimeSpan = random.GetRandomNumber(-500, 1000);
                    var startDateTimeSpan = endDateTimeSpan + random.GetRandomNumber(1, 500);

                    data.EmployeesInProjects.Add(new EmployeesInProject
                                                     {
                                                         EmployeeId = employeeId,
                                                         ProjectId = projectId,
                                                         StartDate = DateTime.Now.AddDays(-startDateTimeSpan),
                                                         EndDate = DateTime.Now.AddDays(-endDateTimeSpan)
                                                     });
                }
            }
        }
开发者ID:ilkodzhambazov,项目名称:Databases,代码行数:31,代码来源:EmployeesInProjectsDataGenerator.cs


示例11: GenerateData

        public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
        {
            var employeeIds = data.Employees.Select(x => x.EmployeeId);
            var projectIds = data.Projects.Select(x => x.ProjectId).ToList();

            foreach (var employee in employeeIds)
            {
                var employeeProjects = random.GetRandomNumber((int)count / 2, (int)(count * 1.5));

                for (var i = 0; i < employeeProjects; i++)
                {
                    var projectId = projectIds[random.GetRandomNumber(1, projectIds.Count - 1)];

                    var startDate = DateTime.Now.AddDays(-random.GetRandomNumber(-500, 1000));
                    var endDate = startDate.AddDays(random.GetRandomNumber(1, 1234));

                    var employeeInProj = new Employees_Projects
                    {
                        ProjectId = projectId,
                        Startdate = startDate,
                        Enddate = endDate,
                        EmployeeId = employee
                    };

                    data.Employees_Projects.Add(employeeInProj);
                }
            }
        }
开发者ID:cwetanow,项目名称:Telerik,代码行数:28,代码来源:EmployeesInProjectsDataGenerator.cs


示例12: GenerateData

 public void GenerateData(CompanyEntities data, IRandomGenerator random, int count)
 {
     for (int i = 0; i < count; i++)
     {
         var project = new Project { Name = random.GetRandomString(random.GetRandomNumber(5, 50)) };
         data.Projects.Add(project);
     }
 }
开发者ID:ilkodzhambazov,项目名称:Databases,代码行数:8,代码来源:ProjectsDataGenerator.cs


示例13: Get

 /// <summary>
 /// Returns a random number generator.
 /// </summary>
 /// <returns></returns>
 public static IRandomGenerator Get()
 {
     if (_generator == null)
     {
         _generator = new RandomGenerator();
     }
     return _generator;
 }
开发者ID:robert-hickey,项目名称:OsmSharp,代码行数:12,代码来源:StaticRandomGenerator.cs


示例14: Roulette

 public Roulette(IRandomGenerator randomGenerator)
 {
     if (RunningGames == null)
     {
         RunningGames = new Dictionary<string, Game>();
     }
     _randomGenerator = randomGenerator;
 }
开发者ID:skjohansen,项目名称:spinroulette,代码行数:8,代码来源:Roulette.cs


示例15: Person

 public Person(IRandomGenerator random, List<IGene> genes, bool isFemale)
 {
     _random = random;
     _personId = Guid.NewGuid();
     _age = 0;
     _isFemale = isFemale;
     _genes = genes;
 }
开发者ID:nheinbaugh,项目名称:PopulationGenetics,代码行数:8,代码来源:Person.cs


示例16: Board

 /// <summary>
 /// Initializes a new instance of the <see cref="Board" /> class.
 /// Board object containing multiple Balloon objects. The Board serves as the interface through which Balloons are accessed.
 /// </summary>
 /// <param name="rows">The max amount of rows the board will contain.</param>
 /// <param name="cols">The max amount of columns the board will contain.</param>
 /// <param name="randomGenerator">The random generator on which depends the balloons' randomness.</param>
 public Board(int rows, int cols, IRandomGenerator randomGenerator)
 {
     this.Rows = rows;
     this.Cols = cols;
     this.board = new IBalloon[this.Rows, this.Cols];
     this.RandomGenerator = randomGenerator;
     this.balloonFactory = new BalloonFactory();
     this.Fill();
 }
开发者ID:Baloons-Pop-2,项目名称:Balloons-Pop-2,代码行数:16,代码来源:Board.cs


示例17: Initialize

        public override void Initialize()
        {
            var health = ParentGameObject.GetComponent<IHealthComponent>();
            health.OnHealthDepleted += HealthOnOnHealthDepleted;

            randGen = GameServiceManager.GetService<IRandomGenerator>();
            
            base.Initialize();
        }
开发者ID:shadercoder,项目名称:Icicle-Framework,代码行数:9,代码来源:BrickBehavior.cs


示例18: GameField

 /// <summary>
 /// Initializes a new instance of the <see cref="GameField" /> class.
 /// </summary>
 /// <param name="random">Random generator.</param>
 /// <param name="mineFactory">Mine factory.</param>
 /// <param name="size">Size of the game field.</param>
 /// <param name="isExplosionChained">True if there is explosions chaining.</param>
 public GameField(IRandomGenerator random, IMineFactory mineFactory, int size, bool isExplosionChained = false)
 {
     this.random = random;
     this.mineFactory = mineFactory;
     this.field = new Cell[size, size];
     this.MinesCount = this.CalculateInitialMineCount();
     this.FillFieldWithEmptyCells();
     this.FillFieldMines();
     this.isExplosionChained = isExplosionChained;
 }
开发者ID:Ivorankov,项目名称:HQ-Programing-Team-BattleField-5,代码行数:17,代码来源:GameField.cs


示例19: ReversedWindowGenerator

        public ReversedWindowGenerator(IRandomGenerator generator, int windowSize)
        {
            if (generator == null)
                throw new ArgumentNullException("generator");
            if (windowSize < 2)
                throw new ArgumentException(@"Window size must be at least 2", "windowSize");

            _generator = generator;
            _window = new byte[windowSize];
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:10,代码来源:ReversedWindowGenerator.cs


示例20: InitializeWeights

        //========================= Misc public helpers =========================
        public static void InitializeWeights(INeuralNetwork nn, IRandomGenerator rand)
        {
            var weights = nn.Weights;

            foreach (var weightsSubList in weights)
            {
                for (int i = 0; i < weightsSubList.Length; i++)
                    weightsSubList[i] = rand.NextDouble() - 0.5;
            }
        }
开发者ID:ikhramts,项目名称:NNX,代码行数:11,代码来源:BaseTrainer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IRange类代码示例发布时间:2022-05-24
下一篇:
C# IRandomAccessStream类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap