CB.Fit

This function fits a specific probability distribution to a set of data (range of cells) and returns information about the fit.

Table 75. CB.Fit Returned Data Type

Returned Value

Returned Data Type

The goodness-of-fit statistic for the fit of the data to the selected distribution

Variant

You select the distribution to fit to your data (among the possible distributions listed in Table 76, CB.Fit Parameters) and the statistic to return.

CB.Fit must be used with CB.SetFitRange (CB.SetFitRange), as shown in the examples for this call.

Note:

You cannot fit to distributions that are not listed.

Table 76. CB.Fit Parameters

Parameter

VBA Data Type

Value

Description

Dist

Integer

See Table 77

Used to specify the distribution to use for fitting. Values are listed in Table 77.

Criterion

Integer

See Table 78

Used to specify which fitting statistics to return. Values appear in Table 78.

pValue (Optional)

Boolean

True or False

If False, returns the statistic; if True, returns the p-value. The default is False.

DistBestFit

Integer

See Table 77

If only one distribution is passed for Dist, DistBestFit returns the index of that distribution. Otherwise it returns the index of the best fitted distribution.

CriterionBestFit

Integer

See Table 78

If a specific ranking method is passed for Criterion, CriterionBestFit returns the index of this ranking method. Otherwise, it returns the index of the selected ranking method.

The following table shows Dist parameter values, used to select a distribution for fitting. You can only fit to distributions listed in this table.

Table 77. CB.Fit Dist Parameter Values — Required, Integer

Named Constant Value

Index Value

Description

cbDfaNormal

0

Fits to a normal distribution

cbDfaTriangular

1

Fits to a triangular distribution

cbDfaPoisson

2

Fits to a Poisson distribution

cbDfaBinomial

3

Fits to a binomial distribution

cbDfaLognormal

4

Fits to a lognormal distribution

cbDfaUniform

5

Fits to a uniform distribution

cbDfaExponential

6

Fits to an exponential distribution

cbDfaGeometric

7

Fits to a geometric distribution

cbDfaWeibull

8

Fits to a Weibull distribution

cbDfaBeta

9

Fits to a beta distribution

cbDfaGamma

12

Fits to a gamma distribution

cbDfaLogistic

13

Fits to a logistic distribution

cbDfaPareto

14

Fits to a Pareto distribution

cbDfaExtremeValue

15

Fits to an extreme value distribution

cbDfaNegBinomial

16

Fits to a negative binomial distribution

cbDfaHypergeometric Success

17

Fits to a hypergeometric distribution with Success parameter

cbDfaMinExtreme

18

Fits to a minimum extreme value distribution

cbDfaMaxExtreme

19

Fits to a maximum extreme value distribution

cbDfaStudentsT

20

Fits to a Student’s t distribution

cbDfaDiscreteUniform

22

Fits to a discrete uniform distribution

cbDfaBetaPert

23

Fits to a betaPERT distribution

cbDfaAutoSelectDist

50

Fits to whatever Crystal Ball chooses in the Distribution Gallery as the best type of distribution for fitting.

cbDfaAllContinuous

51

Fits the data to all continuous distributions in the Distribution Gallery (those distributions in which every value in the distribution’s range is possible).

cbDfaAllDiscrete

52

Fits the data to all discrete (non-continuous) distributions in the Distribution Gallery (except Yes-No)

cbDfaAllDistributions

53

Fits to all continuous and discrete distributions (except Yes-No)

Note:

The cbDfaExtremeValue constant is deprecated. It is included for Crystal Ball 2000.5 (5.5) compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball . Beginning with version 11.1.1.0.00, the lognormal distribution has three parameters instead of two. If this call is used in a model that was created in an earlier version of Crystal Ball, the third parameter has a value of 0.

The following table shows Criterion parameter values, used to specify which fitting statistics to return.

Table 78. CB.Fit Criterion Parameter Values — Required, Integer

Named Constant Value

Index Value

Description

cbFitChiSquare

1

Returns the chi-square statistic

cbFitChiSquareP

2

Returns the chi-square statistic p-value.

cbFitKolmogorovSmirnov

3

Returns the Kolmogorov-Smirnov statistic

cbFitAndersonDarling

4

Returns the Anderson-Darling statistic

cbDfaAutoSelectRanking Method

5

Automatically selects a ranking method depending on characteristics of the data