SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2 Class Reference

This class helps managing the partitions of possible outcomes into categories for applying chi-square tests. More...

Public Member Functions

 OutcomeCategoriesChi2 (double[] nbExp)
 Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observations in each category.
 OutcomeCategoriesChi2 (double[] nbExp, int smin, int smax)
 Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array.
 OutcomeCategoriesChi2 (double[] nbExp, int[] loc, int smin, int smax, int nbCat)
 Constructs an OutcomeCategoriesChi2 object.
void regroupCategories (double minExp)
 Regroup categories as explained earlier, so that the expected number of observations in each category is at least minExp.
String toString ()
 Provides a report on the categories.

Public Attributes

int nbCategories
 Total number of categories.
int smin
 Minimum index for valid expected numbers in the array nbExp.
int smax
 Maximum index for valid expected numbers in the array nbExp.
double[] nbExp
 Expected number of observations for each category.
int[] loc
 loc[i] gives the relocation of the category i in the nbExp array.

Detailed Description

This class helps managing the partitions of possible outcomes into categories for applying chi-square tests.

It permits one to automatically regroup categories to make sure that the expected number of observations in each category is large enough. To use this facility, one must first construct an OutcomeCategoriesChi2 object by passing to the constructor the expected number of observations for each original category. Then, calling the method regroupCategories will regroup categories in a way that the expected number of observations in each category reaches a given threshold minExp. Experts in statistics recommend that minExp be always larger than or equal to 5 for the chi-square test to be valid. Thus, minExp = 10 is a safe value to use. After the call, nbExp gives the expected numbers in the new categories and loc[i] gives the relocation of category \(i\), for each \(i\). That is, loc[i] = j means that category \(i\) has been merged with category \(j\) because its original expected number was too small, and nbExp[i] has been added to nbExp[j] and then set to zero. In this case, all observations that previously belonged to category \(i\) are redirected to category \(j\). The variable nbCategories gives the final number of categories, smin contains the new index of the lowest category, and smax the new index of the highest category.

Definition at line 297 of file GofStat.java.

Constructor & Destructor Documentation

◆ OutcomeCategoriesChi2() [1/3]

umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.OutcomeCategoriesChi2 ( double[] nbExp)

Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observations in each category.

The smin and smax fields are set to 0 and

\((n-1)\) respectively, where \(n\) is the length of array nbExp. The loc field is set such that loc[i]=i for each i. The field nbCategories is set to \(n\).

Parameters
nbExparray of expected observations for each category

Definition at line 334 of file GofStat.java.

◆ OutcomeCategoriesChi2() [2/3]

umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.OutcomeCategoriesChi2 ( double[] nbExp,
int smin,
int smax )

Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array.

Only the expected numbers from the smin to smax (inclusive) indices will be considered valid. The loc field is set such that loc[i]=i for each i in the interval [smin, smax]. All loc[i] for i \(\le\) smin are set to smin, and all loc[i] for i \(\ge\) smax are set to smax. The field nbCategories is set to (smax - smin + 1).

Parameters
nbExparray of expected observations for each category
sminMinimum index for valid expected number of observations
smaxMaximum index for valid expected number of observations

Definition at line 358 of file GofStat.java.

◆ OutcomeCategoriesChi2() [3/3]

umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.OutcomeCategoriesChi2 ( double[] nbExp,
int[] loc,
int smin,
int smax,
int nbCat )

Constructs an OutcomeCategoriesChi2 object.

The field nbCategories is set to nbCat.

Parameters
nbExparray of expected observations for each category
sminMinimum index for valid expected number of observations
smaxMaximum index for valid expected number of observations
locarray for which loc[i] gives the relocation of the category i

Definition at line 382 of file GofStat.java.

Member Function Documentation

◆ regroupCategories()

void umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.regroupCategories ( double minExp)

Regroup categories as explained earlier, so that the expected number of observations in each category is at least minExp.

We usually choose minExp = 10.

Parameters
minExpmininum number of expected observations in each category

Definition at line 397 of file GofStat.java.

◆ toString()

String umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.toString ( )

Provides a report on the categories.

Returns
the categories represented as a string

Definition at line 448 of file GofStat.java.

Member Data Documentation

◆ loc

int [] umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.loc

loc[i] gives the relocation of the category i in the nbExp array.

Definition at line 322 of file GofStat.java.

◆ nbCategories

int umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.nbCategories

Total number of categories.

Definition at line 302 of file GofStat.java.

◆ nbExp

double [] umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.nbExp

Expected number of observations for each category.

Definition at line 317 of file GofStat.java.

◆ smax

int umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.smax

Maximum index for valid expected numbers in the array nbExp.

Definition at line 312 of file GofStat.java.

◆ smin

int umontreal.ssj.gof.GofStat.OutcomeCategoriesChi2.smin

Minimum index for valid expected numbers in the array nbExp.

Definition at line 307 of file GofStat.java.


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