private static void RunStocksEntropy(Random random) { //int numOfNodes = 20; var window = 50; var minVolumeBucket = 100.0; var maxVolumeBucket = 4.0 * 10E8; var approximation = new MultiplicativeApproximation(0.005); DateTime startingDateTime = new DateTime(2006, 1, 3); int minAmountAtDay = 1000; var iterations = 1000; //var wantedVectorLength = 100; //foreach (var wantedVectorLength in ArrayUtils.Init(50, 100, 200, 400, 800, 1300, 1600, 2000, 2400)) for (var wantedVectorLength = 4000; wantedVectorLength <= 4000; wantedVectorLength += 100) { for (var numOfNodes = 30; numOfNodes <= 30; numOfNodes += 30) //foreach (var numOfNodes in ArrayUtils.Init(30, 40)) { var mulFactor = Math.Pow(maxVolumeBucket / minVolumeBucket, 1.0 / wantedVectorLength); var closestValueQuery = ClosestValueQuery.InitExponential((long)minVolumeBucket, (long)maxVolumeBucket, mulFactor); var vectorLength = closestValueQuery.Data.Length; foreach (var(entropy, cbName) in ArrayUtils.Init((new EntropyFunction(vectorLength).MonitoredFunction, "RegularCB"))) // (new SpecialCBEntropy(vectorLength).MonitoredFunction, "SmartCB"))) { EntropyRunner.RunStocks(random, entropy, cbName, iterations, closestValueQuery, numOfNodes, window, startingDateTime, minAmountAtDay, approximation, stocksDirPath, resultDir); } } } }
private static void RunStocksSketchEntropy(Random random) { //int numOfNodes = 20; var window = 60; var minVolumeBucket = 100.0; var maxVolumeBucket = 4.0 * 10E8; var approximation = new MultiplicativeApproximation(0.0035); DateTime startingDateTime = new DateTime(2006, 1, 3); int minAmountAtDay = 1000; var iterations = 2500; for (var baseVectorLength = 100; baseVectorLength <= 100; baseVectorLength += 100) { for (var numOfNodes = 10; numOfNodes <= 10; numOfNodes += 10) { for (var reducedDimension = 30; reducedDimension <= 30; reducedDimension += 100) { var mulFactor = Math.Pow(maxVolumeBucket / minVolumeBucket, 1.0 / baseVectorLength); var closestValueQuery = ClosestValueQuery.InitExponential((long)minVolumeBucket, (long)maxVolumeBucket, mulFactor); var vectorLength = closestValueQuery.Data.Length; EntropySketchRunner.RunStocks(random, iterations, closestValueQuery, numOfNodes, window, reducedDimension, startingDateTime, minAmountAtDay, approximation, stocksDirPath, resultDir); } } } }
public void GeneralTest() { int[] array = ArrayUtils.Init(1, 6, 9, 20, -20); var query = ClosestValueQuery.Init(array); Array.Sort(array); Assert.AreEqual(Array.IndexOf(array, 1), query.GetClosestSmallerValueIndex(5)); Assert.AreEqual(Array.IndexOf(array, 20), query.GetClosestSmallerValueIndex(100)); Assert.AreEqual(Array.IndexOf(array, 9), query.GetClosestSmallerValueIndex(9)); Assert.AreEqual(Array.IndexOf(array, 9), query.GetClosestSmallerValueIndex(10)); Assert.AreEqual(Array.IndexOf(array, 9), query.GetClosestSmallerValueIndex(13)); Assert.AreEqual(Array.IndexOf(array, -20), query.GetClosestSmallerValueIndex(-5)); Assert.ThrowsException <IndexOutOfRangeException>(() => query.GetClosestSmallerValueIndex(-100)); }
public void ExponensialGeneratorTest() { var query = ClosestValueQuery.InitExponential(2, 65556, 2.0); var array = query.Data; Assert.AreEqual(Array.IndexOf(array, 0), query.GetClosestSmallerValueIndex(1)); Assert.AreEqual(Array.IndexOf(array, 0), query.GetClosestSmallerValueIndex(0)); Assert.AreEqual(Array.IndexOf(array, 2), query.GetClosestSmallerValueIndex(3)); Assert.AreEqual(Array.IndexOf(array, 2), query.GetClosestSmallerValueIndex(2)); Assert.AreEqual(Array.IndexOf(array, 8), query.GetClosestSmallerValueIndex(15)); Assert.AreEqual(Array.IndexOf(array, 16), query.GetClosestSmallerValueIndex(16)); Assert.AreEqual(Array.IndexOf(array, 256), query.GetClosestSmallerValueIndex(333)); Assert.AreEqual(Array.IndexOf(array, 512), query.GetClosestSmallerValueIndex(777)); Assert.AreEqual(Array.IndexOf(array, 512), query.GetClosestSmallerValueIndex(512)); Assert.AreEqual(Array.IndexOf(array, 512), query.GetClosestSmallerValueIndex(1023)); Assert.ThrowsException <IndexOutOfRangeException>(() => query.GetClosestSmallerValueIndex(-100)); }