/// <summary> /// Write results to a file. Useful for bringing into Excel and plotting. /// </summary> /// <param name="input">Input to the function and the known solution.</param> /// <param name="results">Results of the segmentation.</param> void WriteResultsFile(double[][] input, SegmentationResults results) { // Write a file that can be used for plotting, if desired. // First open the file and check that it was opened. StreamWriter writer = new StreamWriter(Path.Combine(_workingDirectory, "C Sharp Output.txt"), false); // Loop over data points and write to file. Writing as floats seems to work best. for (int i = 0; i < _numberOfDataPoints; i++) { writer.WriteLine("{0:N2} {1:N5} {2:N0} {3:N5}", (float)input[(int)InputType.Log][i], (float)results.SegmentedLog[i], (float)results.BinaryEventSequence[i], (float)results.FilteredSignal[i]); } // Close our file. writer.Close(); }
/// <summary> /// Separate function for making the call to SegmentSignal.Segment to test repeated passing of large(r) data sets. /// </summary> /// <param name="data">Data set.</param> private SegmentationResults[] DoLogSeparateForLargeDataSet(List<double> data, double threshold, int jumpSequenceWindowSize, int noiseVarienceWindowSize, NoiseVarianceEstimateMethod noiseVarianceEstimateMethod, int maxIterations) { SegmentationResults[] results = new SegmentationResults[2]; results[0] = SegmentSignal.Segment(data.ToArray(), threshold, jumpSequenceWindowSize, noiseVarienceWindowSize, noiseVarianceEstimateMethod, maxIterations); results[1] = SegmentSignal.Segment(data, threshold, jumpSequenceWindowSize, noiseVarienceWindowSize, noiseVarianceEstimateMethod, maxIterations); return results; }