本文整理汇总了C#中FastRandom类的典型用法代码示例。如果您正苦于以下问题:C# FastRandom类的具体用法?C# FastRandom怎么用?C# FastRandom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FastRandom类属于命名空间,在下文中一共展示了FastRandom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitBoxes
private void InitBoxes(int Seed)
{
FastRandom rnd = new FastRandom(Seed);
for (int i = 0; i < DataSize; i++)
{
//set random values in Box B (The output box)
byte[] TempValues = new byte[BOX_SIZE];
for (int x = 0; x < BOX_SIZE; x++)
TempValues[x] = (byte)x;
ShuffleValues(TempValues, Seed);
for (int j = 0; j < BOX_SIZE; j++)
{
BOX_B[i, j] = TempValues[j];
}
//Set in Box A where the index of Box B
for (int j = 0; j < BOX_SIZE; j++)
{
for (int x = 0; x < BOX_SIZE; x++)
{
if (BOX_B[i, x] == j)
{
BOX_A[i, j] = (byte)x;
break;
}
}
}
}
}
示例2: RandomDecimalString
public static String RandomDecimalString(FastRandom r)
{
int count = r.NextValue(20) + 1;
StringBuilder sb = new StringBuilder();
if (r.NextValue(2) == 0) sb.Append('-');
for (int i = 0; i < count; i++) {
if (i == 0)
sb.Append((char)('1' + r.NextValue(9)));
else
sb.Append((char)('0' + r.NextValue(10)));
}
if (r.NextValue(2) == 0) {
sb.Append('.');
count = r.NextValue(20) + 1;
for (int i = 0; i < count; i++) {
sb.Append((char)('0' + r.NextValue(10)));
}
}
if (r.NextValue(2) == 0) {
sb.Append('E');
count = r.NextValue(20);
if (count != 0) {
sb.Append(r.NextValue(2) == 0 ? '+' : '-');
}
sb.Append(Convert.ToString(
(int)count, CultureInfo.InvariantCulture));
}
return sb.ToString();
}
示例3: GenerateInputOutput
protected override Tuple<string[], string[]> GenerateInputOutput() {
FastRandom rand = new FastRandom();
List<List<int>> vectors = GetHardcodedTrainingSamples();
var zeros = GetHardcodedZeros();
var trainZeros = zeros.SampleRandomWithoutRepetition(rand, 30).ToList();
var testZeros = zeros.Except<List<int>>(trainZeros, new EnumerableValueEqualityComparer<int>()).ToList();
var help1 = GetDistinctPermutations(new int[4] { 0, 5, -8, 9 });
var trainHelp1 = help1.SampleRandomWithoutRepetition(rand, 20).ToList();
var testHelp1 = help1.Except<List<int>>(trainHelp1, new EnumerableValueEqualityComparer<int>()).ToList();
var help2 = GetDistinctPermutations(new int[4] { 0, 0, -8, 9 });
var trainHelp2 = help2.SampleRandomWithoutRepetition(rand, 10).ToList();
var testHelp2 = help2.Except<List<int>>(trainHelp2, new EnumerableValueEqualityComparer<int>()).ToList();
var help3 = GetDistinctPermutations(new int[4] { 0, 0, 0, 9 });
vectors.AddRange(trainZeros);
vectors.AddRange(trainHelp1);
vectors.AddRange(trainHelp2);
vectors.AddRange(help3);
vectors.AddRange(GetRandomVectors(78, rand).ToList());
vectors = vectors.Shuffle(rand).ToList();
vectors.AddRange(testZeros);
vectors.AddRange(testHelp1);
vectors.AddRange(testHelp2);
vectors.AddRange(GetRandomVectors(974, rand).ToList());
var input = vectors.Select(x => String.Format("[{0}]", String.Join(", ", x))).ToArray();
var output = vectors.Select(x => x.LastIndexOf(0).ToString()).ToArray();
return new Tuple<string[], string[]>(input, output);
}
示例4: NeuralColorQuantizer
/// <summary>
/// Initializes a new instance of the <see cref="NeuralColorQuantizer"/> class.
/// </summary>
public NeuralColorQuantizer()
{
Quality = DefaultQuality;
random = new FastRandom(0);
uniqueColors = new ConcurrentDictionary<Int32, Boolean>();
}
示例5: MsgKeepAlive
public MsgKeepAlive()
: base()
{
FastRandom fastRand = new FastRandom();
this.Payload = new byte[fastRand.Next(32, 256)];
fastRand.NextBytes(this.Payload);
}
示例6: MarkovChainSampler
public MarkovChainSampler()
{
this.sampleCache = new Stack<Sample>(100);
rnd = new FastRandom();
TotalSamples = 0L;
samplesInPass = 0;
}
示例7: PreyCaptureWorld
/// <summary>
/// Constructs with the provided world parameter arguments.
/// </summary>
public PreyCaptureWorld(int gridSize, int preyInitMoves, double preySpeed, double sensorRange, int maxTimesteps)
{
_gridSize = gridSize;
_preyInitMoves = preyInitMoves;
_preySpeed = preySpeed;
_sensorRange = sensorRange;
_maxTimesteps = maxTimesteps;
_rng = new FastRandom();
}
示例8: InitNoise
public void InitNoise() {
var RNG = new FastRandom();
NoiseTable = new float[NoiseDim + 1, NoiseDim + 1, NoiseDim + 1];
int i, j, k;
for (i = 0; i < NoiseDim; i++)
for (j = 0; j < NoiseDim; j++)
for (k = 0; k < NoiseDim; k++)
NoiseTable[i, j, k] = RNG.NextFloat();
}
示例9: FastRandom
/// <summary>
/// Initializes a new instance from an existing one (copy constructor).
/// </summary>
/// <param name="original">The original <see cref="FastRandom"/> instance which is used to initialize the new instance.</param>
/// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param>
private FastRandom(FastRandom original, Cloner cloner)
: base(original, cloner) {
x = original.x;
y = original.y;
z = original.z;
w = original.w;
bitBuffer = original.bitBuffer;
bitMask = original.bitMask;
}
示例10: PathGenerator
public PathGenerator(uint seed, GetHeight getHeight)
{
m_getHeight = getHeight;
var fastRandom = new FastRandom(seed);
m_cellNoise = new CellNoise2D(fastRandom.NextUInt());
m_sources = new Dictionary<uint, PathGraphNode>();
m_sinks = new Dictionary<uint, PathGraphNode>();
m_general = new Dictionary<uint, PathGraphNode>();
m_paths = new List<PathNodeList>();
}
示例11: MarkovChain
public MarkovChain(MarkovChainNode[] nodes, int stepsPerActivation, FastRandom random)
{
_nodes = nodes;
_stepsPerActivation = stepsPerActivation;
_random = random;
_rouletteWheels = new RouletteWheelLayout[nodes.Length];
for (int i = 0; i < nodes.Length; i++)
_rouletteWheels[i] = new RouletteWheelLayout(nodes[i].TransitionProbabilities);
}
示例12: GetRandomVectors
private IEnumerable<List<int>> GetRandomVectors(int n, FastRandom rand) {
for (int i = 0; i < n; i++) {
int length = rand.Next(1, 50);
List<int> cur = new List<int>(length) { 0 };
for (int j = 0; j < length - 1; j++) {
cur.Add(rand.Next(-50, 50));
}
yield return cur.Shuffle(rand).ToList();
}
}
示例13: FiniteAppertureCamera
public FiniteAppertureCamera(Point eye, Vector dirt, Vector up, int width, int height, float fov)
{
rnd = new FastRandom();
this.fieldOfView = fov;
this.Height = height;
this.Width = width;
this.Position = eye;
this.Target = dirt;
this.Up = up;
this.Update();
}
示例14: TestCBORObjectDecimal
public void TestCBORObjectDecimal()
{
FastRandom rand = new FastRandom();
for (int i = 0; i <= 28; i++) { // Try a random decimal with a given exponent
for (int j = 0; j < 8; j++) {
decimal d = RandomDecimal(rand, i);
CBORObject obj = CBORObject.FromObject(d);
TestCommon.AssertRoundTrip(obj);
Assert.AreEqual(d, obj.AsDecimal());
}
}
}
示例15: RandomBigIntString
public static String RandomBigIntString(FastRandom r)
{
int count = r.NextValue(50) + 1;
StringBuilder sb = new StringBuilder();
if (r.NextValue(2) == 0) sb.Append('-');
for (int i = 0; i < count; i++) {
if (i == 0)
sb.Append((char)('1' + r.NextValue(9)));
else
sb.Append((char)('0' + r.NextValue(10)));
}
return sb.ToString();
}