public void ClosedDoubleUnitThousandBucketDistribution(int sampleSizePercentage) { ValidateClosedDoubleUnitBucketDistribution(SystemRandom.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(SplitMix64.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XorShift128Plus.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XoroShiro128Plus.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); ValidateClosedDoubleUnitBucketDistribution(XorShift1024Star.Create(seed), 1000, 100, 0.15f, sampleSizePercentage); }
public void HalfClosedFloatUnitTenBucketDistribution(int sampleSizePercentage) { ValidateHalfClosedFloatUnitBucketDistribution(SystemRandom.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(SplitMix64.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XorShift128Plus.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XoroShiro128Plus.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); ValidateHalfClosedFloatUnitBucketDistribution(XorShift1024Star.Create(seed), 10, 10000, 0.015f, sampleSizePercentage); }
public void ClosedDoubleUnitRange(int sampleSizePercentage) { ValidateClosedDoubleUnitRange(10000, SystemRandom.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, SplitMix64.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XorShift128Plus.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XoroShiro128Plus.Create(seed), sampleSizePercentage); ValidateClosedDoubleUnitRange(10000, XorShift1024Star.Create(seed), sampleSizePercentage); }
//[UnityEditor.MenuItem("Assets/MakeIt.Random/Calculate Arch Identity Test Values")] public static void CalculateAllTestValues() { string dataFilePath = Path.GetFullPath("Packages/com.andygainey.makeit.random/Tests/Editor/Random/Data~/"); Directory.CreateDirectory(dataFilePath); CalculateTestValues(XorShift128Plus.Create(seed), "Next32", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next32()); }, next32Count); CalculateTestValues(XorShift1024Star.Create(seed), "Next32", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next32()); }, next32Count); CalculateTestValues(XoroShiro128Plus.Create(seed), "Next32", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next32()); }, next32Count); CalculateTestValues(XorShiftAdd.Create(seed), "Next32", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next32()); }, next32Count); CalculateTestValues(SplitMix64.Create(seed), "Next32", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next32()); }, next32Count); CalculateTestValues(XorShift128Plus.Create(seed), "Next64", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next64()); }, next64Count); CalculateTestValues(XorShift1024Star.Create(seed), "Next64", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next64()); }, next64Count); CalculateTestValues(XoroShiro128Plus.Create(seed), "Next64", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next64()); }, next64Count); CalculateTestValues(XorShiftAdd.Create(seed), "Next64", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next64()); }, next64Count); CalculateTestValues(SplitMix64.Create(seed), "Next64", (IRandom random, BinaryWriter writer) => { writer.Write(random.Next64()); }, next64Count); CalculateTestValues(XorShift128Plus.Create(seed), "IntRange", (IRandom random, BinaryWriter writer) => { writer.Write(random.RangeCO(71, 1500)); }, intRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "IntRange_Pow2", (IRandom random, BinaryWriter writer) => { writer.Write(random.RangeCO(71, 1095)); }, intRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "FloatOO", (IRandom random, BinaryWriter writer) => { writer.Write(random.FloatOO()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "FloatCO", (IRandom random, BinaryWriter writer) => { writer.Write(random.FloatCO()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "FloatOC", (IRandom random, BinaryWriter writer) => { writer.Write(random.FloatOC()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "FloatCC", (IRandom random, BinaryWriter writer) => { writer.Write(random.FloatCC()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "DoubleOO", (IRandom random, BinaryWriter writer) => { writer.Write(random.DoubleOO()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "DoubleCO", (IRandom random, BinaryWriter writer) => { writer.Write(random.DoubleCO()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "DoubleOC", (IRandom random, BinaryWriter writer) => { writer.Write(random.DoubleOC()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "DoubleCC", (IRandom random, BinaryWriter writer) => { writer.Write(random.DoubleCC()); }, floatRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "UnitVector2", (IRandom random, BinaryWriter writer) => { writer.Write(random.UnitVector2()); }, geometryRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "UnitVector3", (IRandom random, BinaryWriter writer) => { writer.Write(random.UnitVector3()); }, geometryRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "UnitVector4", (IRandom random, BinaryWriter writer) => { writer.Write(random.UnitVector4()); }, geometryRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "Rotation", (IRandom random, BinaryWriter writer) => { writer.Write(random.Rotation()); }, geometryRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "PointWithinCircle", (IRandom random, BinaryWriter writer) => { writer.Write(random.PointWithinCircle()); }, geometryRangeCount); CalculateTestValues(XorShift128Plus.Create(seed), "PointWithinSphere", (IRandom random, BinaryWriter writer) => { writer.Write(random.PointWithinSphere()); }, geometryRangeCount); }
public IRandom GetRandom() { switch (seedSource) { case SeedSource.SystemTime: switch (randomType) { case RandomType.System: return(SystemRandom.Create()); case RandomType.Unity: return(UnityRandom.Create()); case RandomType.SplitMix64: return(SplitMix64.Create()); case RandomType.XorShift128Plus: return(XorShift128Plus.Create()); case RandomType.XorShift1024Star: return(XorShift1024Star.Create()); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create()); default: throw new NotImplementedException(); } case SeedSource.Numerical: switch (randomType) { case RandomType.System: return(SystemRandom.Create(seedNumber)); case RandomType.Unity: return(UnityRandom.Create(seedNumber)); case RandomType.SplitMix64: return(SplitMix64.Create(seedNumber)); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(seedNumber)); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(seedNumber)); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(seedNumber)); default: throw new NotImplementedException(); } case SeedSource.Textual: switch (randomType) { case RandomType.System: return(SystemRandom.Create(seedText)); case RandomType.Unity: return(UnityRandom.Create(seedText)); case RandomType.SplitMix64: return(SplitMix64.Create(seedText)); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(seedText)); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(seedText)); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(seedText)); default: throw new NotImplementedException(); } case SeedSource.Random: switch (randomType) { case RandomType.System: return(SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.Unity: return(UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.SplitMix64: return(SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XorShift128Plus: return(XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XorShift1024Star: return(XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>())); case RandomType.XoroShiro128Plus: return(XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>())); default: throw new NotImplementedException(); } case SeedSource.RandomAndSystemTime: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(); return(random); } default: throw new NotImplementedException(); } case SeedSource.RandomAndNumerical: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedNumber); return(random); } default: throw new NotImplementedException(); } case SeedSource.RandomAndTextual: switch (randomType) { case RandomType.System: { var random = SystemRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.Unity: { var random = UnityRandom.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.SplitMix64: { var random = SplitMix64.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XorShift128Plus: { var random = XorShift128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XorShift1024Star: { var random = XorShift1024Star.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } case RandomType.XoroShiro128Plus: { var random = XoroShiro128Plus.Create(randomSeedInputSlot.GetAsset <IRandom>()); random.MergeSeed(seedText); return(random); } default: throw new NotImplementedException(); } default: throw new NotImplementedException(); } }