This class provides histograms for which the bin counts (heights of rectangles) are replaced by real-valued frequencies (in double) and can be rescaled. More...
Public Member Functions | |
| ScaledHistogram (double a, double b, int numBins) | |
| Constructs a ScaledHistogram over the interval \([a,b]\), which is divided into numBins bins of equal width. | |
| ScaledHistogram (TallyHistogram hist, double integral) | |
| Constructs a ScaledHistogram from hist by normalizing the bin counts so that the integral of the histogram is equal to integral. | |
| void | init (double a, double b, int numBins) |
| Initializes the ScaledHistogram so it covers the interval \([a,b]\), which is divided into numBins bins of equal width. | |
| void | init (TallyHistogram hist, double integral) |
| Initializes this ScaledHistogram using the TallyHistogram hist. | |
| void | init () |
| Initializes all the heights (frequencies) to 0. | |
| void | rescale (double integral) |
| Rescales the histogram by renormalizing the frequencies so its integral has the value specified by integral. | |
| ScaledHistogram | averageShiftedHistogram (int r) |
| Returns an ASH-transformed version of this scaled histogram. | |
| ScaledHistogram | averageShiftedHistogramTrunc (int r) |
| Similar to averageShiftedHistogram, except that it assumes that the density is over a close interval \([a,b]\) and is rescaled differently for the intervals that are near the boundary, to account for the fact that the intervals outside the boundaries are not counted. | |
| ScaledHistogram | averageShiftedHistogram (int r, double[] w) |
| Similar to averageShiftedHistogram, except that uses a weighted average. | |
| ScaledHistogram | averageShiftedHistogramTrunc (int r, double[] w) |
| Similar to averageShiftedHistogramTrunc, except that uses a weighted average. | |
| ScaledHistogram | averageShiftedHistogram1 (int r) |
| This is supposed to be a faster implementation of averageShiftedHistogram(r). | |
| int | getNumBins () |
| Returns the number of bins \(s\) dividing the interval. | |
| double | getA () |
| Returns the left boundary \(a\) of interval \([a,b]\). | |
| double | getB () |
| Returns the right boundary \(b\) of interval \([a,b]\). | |
| double[] | getHeights () |
| return the array counts of the histogram. | |
| double | getIntegral () |
| return the integral the histogram. | |
| double | ISEvsU01 () |
| Computes and returns the integrated square error (ISE) of a histogram w.r.t. | |
| double | ISEvsU01polygonal () |
| Computes and returns the ISE of a polygonal density w.r.t. | |
| ScaledHistogram | clone () |
| Clones this object and the array which stores the counters. | |
This class provides histograms for which the bin counts (heights of rectangles) are replaced by real-valued frequencies (in double) and can be rescaled.
The histogram is over a bounded interval \([a,b]\) and has a fixed number of bins of equal width \(h\). The frequencies can be chosen (rescaled) so that the integral of the histogram is equal to a specific value. If this value is taken as 1, i.e., if \(h\) times the sum of frequencies is equal to 1, then the histogram can be seen as a density estimator for a density whose support is contained in \([a,b]\). If part of the density is outside \([a,b]\), then the integral of the estimated density over \([a,b]\) can be less than 1.
This class also implements averaged-shifted histograms (ASH) and polygonal interpolations of histograms. See [205].
Definition at line 49 of file ScaledHistogram.java.
| umontreal.ssj.stat.ScaledHistogram.ScaledHistogram | ( | double | a, |
| double | b, | ||
| int | numBins ) |
Constructs a ScaledHistogram over the interval \([a,b]\), which is divided into numBins bins of equal width.
This constructor initializes the frequency of each bin to 0.
| a | left boundary of interval |
| b | right boundary of interval |
| numBins | number of bins |
Definition at line 69 of file ScaledHistogram.java.
| umontreal.ssj.stat.ScaledHistogram.ScaledHistogram | ( | TallyHistogram | hist, |
| double | integral ) |
Constructs a ScaledHistogram from hist by normalizing the bin counts so that the integral of the histogram is equal to integral.
Definition at line 77 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.averageShiftedHistogram | ( | int | r | ) |
Returns an ASH-transformed version of this scaled histogram.
The ASH-transformed histogram has the same bin size as the original. The new frequency (height) in any given bin is the weighted average of the frequencies in the neighboring bins, with weights \((r-d)/r^2\) given to bins that are at distance \(d\) from the target bin, for all \(d < r\).
Definition at line 148 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.averageShiftedHistogram | ( | int | r, |
| double[] | w ) |
Similar to averageShiftedHistogram, except that uses a weighted average.
For the new average in a given bin, any neighbor bin at distance \(\ell < r\) is given a weight proportional to w[i]. The given weights do not have to sum to 1; they are rescaled so the sum of weights that go to any given bin is 1.
Definition at line 208 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.averageShiftedHistogram1 | ( | int | r | ) |
This is supposed to be a faster implementation of averageShiftedHistogram(r).
Definition at line 289 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.averageShiftedHistogramTrunc | ( | int | r | ) |
Similar to averageShiftedHistogram, except that it assumes that the density is over a close interval \([a,b]\) and is rescaled differently for the intervals that are near the boundary, to account for the fact that the intervals outside the boundaries are not counted.
Definition at line 175 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.averageShiftedHistogramTrunc | ( | int | r, |
| double[] | w ) |
Similar to averageShiftedHistogramTrunc, except that uses a weighted average.
For the new average in a given bin, any neighbor bin at distance \(\ell < r\) is given a weight proportional to w[i]. The given weights do not have to sum to 1; they are rescaled so the sum of weights that go to any given bin is 1 (not counting the weights given to bins that fall outside the interval).
Definition at line 242 of file ScaledHistogram.java.
| ScaledHistogram umontreal.ssj.stat.ScaledHistogram.clone | ( | ) |
Clones this object and the array which stores the counters.
Definition at line 399 of file ScaledHistogram.java.
| double umontreal.ssj.stat.ScaledHistogram.getA | ( | ) |
Returns the left boundary \(a\) of interval \([a,b]\).
Definition at line 337 of file ScaledHistogram.java.
| double umontreal.ssj.stat.ScaledHistogram.getB | ( | ) |
Returns the right boundary \(b\) of interval \([a,b]\).
Definition at line 346 of file ScaledHistogram.java.
| double[] umontreal.ssj.stat.ScaledHistogram.getHeights | ( | ) |
return the array counts of the histogram.
Definition at line 353 of file ScaledHistogram.java.
| double umontreal.ssj.stat.ScaledHistogram.getIntegral | ( | ) |
return the integral the histogram.
Definition at line 360 of file ScaledHistogram.java.
| int umontreal.ssj.stat.ScaledHistogram.getNumBins | ( | ) |
Returns the number of bins \(s\) dividing the interval.
\([a,b]\). Does not count the two extra bins for the values of \(x<a\) or \(x>b\).
Definition at line 328 of file ScaledHistogram.java.
| void umontreal.ssj.stat.ScaledHistogram.init | ( | ) |
Initializes all the heights (frequencies) to 0.
Definition at line 124 of file ScaledHistogram.java.
| void umontreal.ssj.stat.ScaledHistogram.init | ( | double | a, |
| double | b, | ||
| int | numBins ) |
Initializes the ScaledHistogram so it covers the interval \([a,b]\), which is divided into numBins bins of equal width.
Is initializes the frequency of each bin to 0.
| a | left boundary of interval |
| b | right boundary of interval |
| numBins | number of bins |
Definition at line 90 of file ScaledHistogram.java.
| void umontreal.ssj.stat.ScaledHistogram.init | ( | TallyHistogram | hist, |
| double | integral ) |
Initializes this ScaledHistogram using the TallyHistogram hist.
It uses the same interval \([a,b]\), same bins, and rescaled the counters so the integral of the histogram equal the value specified by integral.
Definition at line 108 of file ScaledHistogram.java.
| double umontreal.ssj.stat.ScaledHistogram.ISEvsU01 | ( | ) |
Computes and returns the integrated square error (ISE) of a histogram w.r.t.
the \(U(0,1)\) distribution. Assumes the histogram integrates to 1.
Definition at line 368 of file ScaledHistogram.java.
| double umontreal.ssj.stat.ScaledHistogram.ISEvsU01polygonal | ( | ) |
Computes and returns the ISE of a polygonal density w.r.t.
the \(U(0,1)\) distribution. Assumes the histogram integrates to 1. Over interval \((a,b)\) = '(w0[j],w0[j+1])', the ISE is \(\int_0^1 ((a + (b-a)x)^2 dx = (b^3 - a^3) / (3 (b-a)) = (b^2 + a^2 + ab)/3.\)
Definition at line 381 of file ScaledHistogram.java.
| void umontreal.ssj.stat.ScaledHistogram.rescale | ( | double | integral | ) |
Rescales the histogram by renormalizing the frequencies so its integral has the value specified by integral.
Definition at line 133 of file ScaledHistogram.java.