The SPA SDK provides a flexible SPADataSet.Fit
method that can be used to automatically or manually fit distributions to your data.
The automated distribution fitting means the SDK will estimate the distribution parameters
from data, while the manual fitting capability allows you to manually specify the parameter
values. The only input argument of the fitting method, dist, can take on a range
values (see the table below).
The fitting method returns an array of SPAFitResult
objects, each representing a single successfully or unsuccessfully fitted model, and the number
of elements in this array. For details on how to use the distribution fitting results, see the
Fitting Results topic.
Dim fitResults() As Variant
Dim count As Long
' run the fit
count = dataSet.Fit(SPADistGamma, fitResults)
3
The SPADistribution object with FitMode=SPAFitModeAuto (the default property value)
Automatically fit the specified distribution. The key difference from the second input format (see above)
is that you can set some of the distribution parameters to a fixed value using the SPADistribution.ParamFixed
and SPADistribution.Param properties,
forcing the SDK to estimate only the rest of the parameters. When using this format,
the SDK will ignore the default domain bounds.
Dim dist as New SPADistribution
Dim fitResults() As Variant
Dim count As Long
' initialize the distribution object
dist.Type = SPADistWeibull
dist.ParamFixed(2) = True
dist.Param(2) = 0.5 ' force gamma=0.5
' run the fit
count = dataSet.Fit(dist, fitResults)
Manually fit the specified distribution with given parameters.
Dim dist as New SPADistribution
Dim fitResults() As Variant
Dim count As Long
' initialize the distribution object
dist.Type = SPADistNormal
dist.Param(0) = 2
dist.Param(1) = 1
dist.FitMode = SPAFitModeManual
' run the fit
count = dataSet.Fit(dist, fitResults)
5
An array that can include any of the above values
You can combine the automated and manual fitting in a single call to the
distribution fitting method.
Dim arr(2) As Variant
Dim dist as New SPADistribution
Dim fitResults() As Variant
Dim count As Long
' initialize the distribution object
dist.Type = SPADistExp
dist.Param(0) = 2
dist.Param(1) = 3
dist.FitMode = SPAFitModeManual
' initialize the input array
Set arr(0) = dist
arr(1) = SPADistGamma
arr(2) = SPADistJohnsonSB
' run the fit
count = dataSet.Fit(arr, fitResults)