예제 #1
0
 /// <summary>Uses Scott's choice algorithm to assign bin width:
 /// http://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width</summary>
 public Histogram(TimeSeries data)
 {
     var bS = (3.5 * data.StandardDeviation) / Math.Pow(data.Count(), .33333333333333);
     if (bS <= 0)
         bS = .01;
     this.binSize = bS;
     for (int i = 0; i < data.Count(); i++) {
         IncrementAt((int)Math.Floor(data[i] / binSize));
     }
 }
예제 #2
0
 public Histogram(TimeSeries data, double binSize)
 {
     this.binSize = binSize;
     for (int i = 0; i < data.Count(); i++) {
         IncrementAt((int)Math.Floor(data[i] / binSize));
     }
 }
예제 #3
0
        public ScatterSeries Correlate2(TimeSeries ts2)
        {
            ScatterSeries ss = new ScatterSeries() { MarkerSize = .8, MarkerStroke = OxyColors.Blue, MarkerFill = OxyColors.Blue };
            bool axis1Direction = this.domain[1] - this.domain[0] > 0;
            bool axis2Direction = ts2.domain[1] - ts2.domain[0] > 0;
            int i, j;
            if (axis1Direction) {
                i = this.Count() - 1;
            } else {
                i = 0;
            }
            if (axis2Direction) {
                j = ts2.Count() - 1;
            } else {
                j = 0;
            }

            while (i >= 0 && j >= 0 && i < this.Count() && j < ts2.Count()) {
                double domaini = this.domain[i];
                double domainj = ts2.domain[j];
                if (domaini != domainj) {
                    if (domaini > domainj) {
                        //Move i
                        if (axis1Direction) {
                            i--;
                        } else {
                            i++;
                        }
                    } else {
                        //Move j
                        if (axis2Direction) {
                            j--;
                        } else {
                            j++;
                        }
                    }
                    continue;
                } else {
                    ss.Points.Add(new ScatterPoint(this.range[i], ts2.range[j]));
                    //Move both
                    if (axis1Direction) {
                        i--;
                    } else {
                        i++;
                    }
                    if (axis2Direction) {
                        j--;
                    } else {
                        j++;
                    }
                }
            }
            return ss;
        }