SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Attributes | List of all members
ScaledHistogram Class Reference

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. More...
 
 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. More...
 
void init (TallyHistogram hist, double integral)
 Initializes this ScaledHistogram using the TallyHistogram hist. More...
 
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. More...
 
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. More...
 
ScaledHistogram averageShiftedHistogramTrunc (int r, double[] w)
 Similar to averageShiftedHistogramTrunc, except that uses a weighted average. More...
 
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 \([a,b]\). More...
 
double getA ()
 Returns the left boundary \(a\) of interval \([a,b]\). More...
 
double getB ()
 Returns the right boundary \(b\) of interval \([a,b]\). More...
 
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. More...
 
double ISEvsU01polygonal ()
 Computes and returns the ISE of a polygonal density w.r.t. More...
 
ScaledHistogram clone ()
 Clones this object and the array which stores the counters.
 

Protected Attributes

int numBins
 
double m_h
 
double m_a
 
double m_b
 
double [] height
 
double integral
 

Detailed Description

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 [213].

Constructor & Destructor Documentation

◆ 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.

Parameters
aleft boundary of interval
bright boundary of interval
numBinsnumber of bins

Member Function Documentation

◆ averageShiftedHistogram() [1/2]

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\).

◆ averageShiftedHistogram() [2/2]

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.

◆ averageShiftedHistogramTrunc()

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).

◆ getA()

double getA ( )

Returns the left boundary \(a\) of interval \([a,b]\).

Returns
left boundary of interval

◆ getB()

double getB ( )

Returns the right boundary \(b\) of interval \([a,b]\).

Returns
right boundary of interval

◆ getNumBins()

int 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\).

Returns
the number of bins

◆ init() [1/2]

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.

Is initializes the frequency of each bin to 0.

Parameters
aleft boundary of interval
bright boundary of interval
numBinsnumber of bins

◆ init() [2/2]

void 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.

◆ ISEvsU01()

double 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.

◆ ISEvsU01polygonal()

double 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.\)


The documentation for this class was generated from the following file: