本文整理汇总了C#中IRandomGenerator类的典型用法代码示例。如果您正苦于以下问题:C# IRandomGenerator类的具体用法?C# IRandomGenerator怎么用?C# IRandomGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRandomGenerator类属于命名空间,在下文中一共展示了IRandomGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PinkNoise
public PinkNoise(IRandomGenerator randomGenerator, float rmsAmplitude)
{
if (null == randomGenerator)
throw new ArgumentNullException("randomGenerator");
_whiteGenerator = new NormalDistribution(randomGenerator, 0, RmsScale * rmsAmplitude);
}
示例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);
}
示例3: Initialize
public override void Initialize()
{
randomGenerator = GameServiceManager.GetService<IRandomGenerator>();
ResetTimer();
base.Initialize();
}
示例4: SetUp
public void SetUp()
{
var builderSetup = new BuilderSettings();
reflectionUtil = Substitute.For<IReflectionUtil>();
generator = Substitute.For<IRandomGenerator>();
propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false,builderSetup);
}
示例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);
}
}
示例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);
}
示例7: Player
public Player(IRandomGenerator generator, IBoard gameBoard, string name = "")
{
Generator = generator;
GameBoard = gameBoard;
Name = name;
Position = 0;
}
示例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>();
}
示例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;
}
示例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)
});
}
}
}
示例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);
}
}
}
示例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);
}
}
示例13: Get
/// <summary>
/// Returns a random number generator.
/// </summary>
/// <returns></returns>
public static IRandomGenerator Get()
{
if (_generator == null)
{
_generator = new RandomGenerator();
}
return _generator;
}
示例14: Roulette
public Roulette(IRandomGenerator randomGenerator)
{
if (RunningGames == null)
{
RunningGames = new Dictionary<string, Game>();
}
_randomGenerator = randomGenerator;
}
示例15: Person
public Person(IRandomGenerator random, List<IGene> genes, bool isFemale)
{
_random = random;
_personId = Guid.NewGuid();
_age = 0;
_isFemale = isFemale;
_genes = genes;
}