public void NormalizeSunspots(double lo, double hi) { array= new NormalizeArray { NormalizedHigh = hi, NormalizedLow = lo }; // create arrays to hold the normalized sunspots _normalizedSunspots = array.Process(Sunspots); _closedLoopSunspots = EngineArray.ArrayCopy(_normalizedSunspots); }
public void TestNormalize() { var norm = new NormalizeArray(); double[] input = {1, 5, 10}; double[] output = norm.Process(input); Assert.AreEqual(3, output.Length); Assert.AreEqual(-1.0, output[0]); Assert.AreEqual(1.0, output[2]); Assert.AreEqual(1.0, norm.Stats.ActualLow); Assert.AreEqual(10.0, norm.Stats.ActualHigh); }
/// <summary> /// Send all the (unNormalized)inputs in the as the network was trained and this outputs a list of double ready for a network.compute(imldata result)). /// </summary> /// <param name="WindoSize"> Size of the windo. </param> /// <param name="pparamInputs"> A variable-length parameters list containing pparam inputs. </param> /// <returns> /// The compute pair ready for network computes) /// </returns> public static Tuple<List<double>, NormalizeArray> GetReadiedComputePair(int WindoSize, params double[][] pparamInputs) { try { //We make a dic with the count of inputs being the number of double series we are sending in. Dictionary<int, double[]> inputsDics = new Dictionary<int, double[]>(pparamInputs.Length); int indexS = 0; NormalizeArray Normee = new NormalizeArray(-1, 1); // PredictionStats.NormalizationClass NormingClass = new PredictionStats.NormalizationClass(); foreach (double[] doubleSeries in pparamInputs) { inputsDics.Add(indexS++, Normee.Process(doubleSeries)); } List<double> dtda = new List<double>(); int listindex = 0; int currentindex = 0; //count the fields -1 ,as it starts from zero. int dicinputsCount = inputsDics.Keys.Count - 1; foreach (double d in inputsDics[0]) { if (currentindex++ < WindoSize) { dtda.Add(d); //we put all the fields which are in the dic. while (dicinputsCount > 0) { dtda.Add(inputsDics[dicinputsCount--][listindex]); } //We reset the field count for a later pass. dicinputsCount = inputsDics.Keys.Count - 1; } if (currentindex == WindoSize) { return new Tuple<List<double>, NormalizeArray>(dtda, Normee); } //Lets increment the indexes.. listindex++; } return new Tuple<List<double>, NormalizeArray>(dtda, Normee); } catch (Exception ex) { throw ex; } }
/// <summary> /// Normalizes an array using Normalize Array (and not DataNormalization way : Faster). /// The high and low are the standard -1,1. /// </summary> /// <param name="arrays">The arrays.</param> /// <returns>returns a tuple with the array in item1 and the normalization in item 2.</returns> public static Tuple<double[], NormalizeArray> NormalizeArray(double[] arrays) { var norm = new NormalizeArray(); return new Tuple<double[], NormalizeArray>(norm.Process(arrays), norm); }
/// <summary> /// Normalizes an array using Normalize Array (and not DataNormalization way : Faster). /// </summary> /// <param name="lo">The lo.</param> /// <param name="hi">The hi.</param> /// <param name="arrays">The arrays.</param> /// <returns></returns> public static double[] NormalizeArray(double lo, double hi, double[] arrays) { var norm = new NormalizeArray {NormalizedHigh = hi, NormalizedLow = lo}; return norm.Process(arrays); }
public void NormalizeForexPair(double lo, double hi) { array= new NormalizeArray { NormalizedHigh = hi, NormalizedLow = lo }; // create arrays to hold the normalized forex pair data _normalizedForexPair = array.Process(ForexPair); _closedLoopForexPair = EngineArray.ArrayCopy(_normalizedForexPair); }
public static void normalizeSunspots(double lo, double hi) { NormalizeArray norm = new NormalizeArray(); norm.NormalizedHigh=( hi); norm.NormalizedLow = lo; // create arrays to hold the normalized sunspots normalizedSunspots = norm.Process(SUNSPOTS); closedLoopSunspots = EngineArray.ArrayCopy(normalizedSunspots); }
/// <summary> /// Loads variables inputs and one ideal double series into an imldataset. /// </summary> /// <param name="idealsinputs"></param> /// <param name="WindoSize"></param> /// <param name="pparamInputs"></param> /// <returns></returns> public static Tuple<IMLDataSet, NormalizeArray> Load(double[] idealsinputs, int WindoSize, params double[][] pparamInputs) { try { var finalSet = new BasicMLDataSet(); //We make a dic with the count of inputs being the number of double series we are sending in. Dictionary<int, double[]> inputsDics = new Dictionary<int, double[]>(pparamInputs.Length); int indexS = 0; //We make a normalizeArray which we will return as a tuple ready for denormalization. NormalizeArray Normer = new NormalizeArray(-1, 1); //Process each inputs. foreach (double[] doubleSeries in pparamInputs) { inputsDics.Add(indexS++, Normer.Process(doubleSeries)); } //Process the ideals. var idealNormed = Normer.Process(idealsinputs); //Make a list which will hold the inputs one after the others List<double> dtda = new List<double>(); int listindex = 0; int currentindex = 0; //starts from zero so count -1.. int dicinputsCount = inputsDics.Keys.Count - 1; //Process the input normed. foreach (double d in inputsDics[0]) { if (currentindex++ < WindoSize) { dtda.Add(d); //we put all the fields which are in the dic. while (dicinputsCount > 0) { dtda.Add(inputsDics[dicinputsCount--][listindex]); } //We reset the field count for a later pass. dicinputsCount = inputsDics.Keys.Count - 1; } if (currentindex == WindoSize) { //Make an imldata pair, and add it to the imldataset...reset the temp list of inputs... var pair = new BasicMLDataPair( new BasicMLData(dtda.ToArray()), new BasicMLData(new double[] { idealNormed[listindex] })); currentindex = 0; dtda.Clear(); finalSet.Add(pair); } //Lets increment the indexes.. listindex++; } //Return the dataset and the normalization array.. return new Tuple<IMLDataSet, NormalizeArray>(finalSet,Normer); } catch (Exception ex) { Console.WriteLine("Got an error : ", ex); throw new Exception("Error parsing points...."); } }
/// <summary> /// Normalizes an array. /// </summary> /// <param name="inputArray">The input array.</param> /// <returns>a normalized array of doubles</returns> public static double[] NormalizeThisArray(double[] inputArray) { return(ArrayNormalizer.Process(inputArray)); }