Example #1
0
        /// <summary>
        /// Segment a signal using the Maximum Likelihood Estimation of Radhakrishnan, et al, 1991.  Attempts to identify regions of the signal that are
        /// considered "consistent."  Assumes a signal that has a state which changes only at segment boundaries.  The state change can be random and the
        /// noise on top of the signal is modeled as Gaussian, but not necessarily stationary.
        /// </summary>
        /// <param name="signal">Input signal to be segmented.</param>
        /// <param name="threshold">Segmentation threshold.</param>
        /// <param name="jumpSequenceWindowSize">Length of the moving average window sized used for smoothing the input well log to arrive at an initial estimate of the jump sequence variance.</param>
        /// <param name="noiseVarianceWindowSize">Length of the moving average window used for smoothing the noise variances.</param>
        /// <param name="noiseVarianceEstimateMethod">
        /// Noise variance estimate option.
        //        rmode = 0 ==> Point estimate of noise variance.
        //        rmode = 1 ==> Noise estimates smoothed within segments.
        /// </param>
        /// <param name="maxSMLRIterations">Upper bound on the number of Single Most Likelihood Replacement iterations.</param>
        /// <returns>A SegmentationResults instance which contains the algorithm output of binary events, segmented log, filtered log, et cetera.</returns>
        public static SegmentationResults Segment(List<double> signal, double threshold, int jumpSequenceWindowSize, int noiseVarianceWindowSize, NoiseVarianceEstimateMethod noiseVarianceEstimateMethod, int maxSMLRIterations)
        {
            // Scalars which are need for output from the call to the algorithm.
            int		numberOfBinaryEvents	= 0;
            double	jumpSequenceVariance	= 0;
            double	segmentDensity			= 0;
            int		iterations				= 0;
            int		error					= 0;

            // We seem to need to create the array in the function immediately prior to calling the unmanaged code, otherwise the garbage collector
            // gets cute and moves things around, which the unmanaged code takes offense to.
            double[] signalToPass = new double[signal.Count];
            signal.CopyTo(signalToPass, 0);

            // Create the output arrays.  After being populated by the call to the algorithm they are grouped, stored, and returned in the SegmenationResults data structure.
            double[] Q		= new double[signal.Count];
            double[] FLTLOG = new double[signal.Count];
            double[] SEGLOG	= new double[signal.Count];
            double[] R		= new double[signal.Count];

            int size			= signalToPass.Length;
            int estimateMethod	= (int)noiseVarianceEstimateMethod;

            // Function call to the C DLL.
            SegmentSignalWrapper(signalToPass, size, threshold, jumpSequenceWindowSize, noiseVarianceWindowSize, estimateMethod, maxSMLRIterations, Q, out numberOfBinaryEvents, FLTLOG, SEGLOG, R, out jumpSequenceVariance, out segmentDensity, out iterations, out error);

            return new SegmentationResults(Q, numberOfBinaryEvents, FLTLOG, SEGLOG, R, jumpSequenceVariance, segmentDensity, iterations, error);
        }
        /// <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;
        }
Example #3
0
 /// <summary>
 /// Segment a signal using the Maximum Likelihood Estimation of Radhakrishnan, et al, 1991.  Attempts to identify regions of the signal that are
 /// considered "consistent."  Assumes a signal that has a state which changes only at segment boundaries.  The state change can be random and the
 /// noise on top of the signal is modeled as Gaussian, but not necessarily stationary.
 /// 
 /// Assumes an upper bound of 300 on the number of Single Most Likelihood Replacement iterations.
 /// </summary>
 /// <param name="signal">Input signal to be segmented.</param>
 /// <param name="threshold">Segmentation threshold.</param>
 /// <param name="jumpSequenceWindowSize">Length of the moving average window sized used for smoothing the input well log to arrive at an initial estimate of the jump sequence variance.</param>
 /// <param name="noiseVarianceWindowSize">Length of the moving average window used for smoothing the noise variances.</param>
 /// <param name="noiseVarianceEstimateMethod">
 /// Noise variance estimate option.
 //        rmode = 0 ==> Point estimate of noise variance.
 //        rmode = 1 ==> Noise estimates smoothed within segments.
 /// </param>
 /// <returns>A SegmentationResults instance which contains the algorithm output of binary events, segmented log, filtered log, et cetera.</returns>
 public static SegmentationResults Segment(List<double> signal, double threshold, int jumpSequenceWindowSize, int noiseVarianceWindowSize, NoiseVarianceEstimateMethod noiseVarianceEstimateMethod)
 {
     return Segment(signal, threshold, jumpSequenceWindowSize, noiseVarianceWindowSize, noiseVarianceEstimateMethod, 300);
 }