FittedAgainstDataPlot

class FittedAgainstDataPlot(data: DoubleArray, fitted: ContinuousDistributionIfc, numDrawn: Int = data.size, streamNum: Int = 1, streamProvider: RNStreamProviderIfc = ksl.utilities.random.rvariable.KSLRandom.DefaultRNStreamProvider, binWidth: Double = defaultDotBinWidth(data), variableName: String = "observed value") : BasePlot(source)

The real sample against a sample drawn from the fitted density, side by side.

The check an analyst asks for first, and the one a test cannot replace. A goodness-of-fit p-value says reject or do not reject; this shows where the fit departs from the data, which is what decides whether the departure matters. A fitted density that misses a small bump in the middle may be perfectly usable as a simulation input, while one that misses the upper tail is not, and no single number distinguishes those two cases.

The picture is honest even where the formal test is not. A two-sample test between these two samples would be invalid, because the drawn sample comes from a density fitted to the real one and so inherits its peculiarities — FitAdequacy records what that costs when measured. Looking at them together carries no such assumption: the eye is comparing two sets of numbers, not computing a null distribution.

Drawn at the same size as the real sample by default, so that the raggedness of the two is comparable. A larger drawn sample produces a smoother picture that flatters the fit, which is why it is not the default.

Parameters

data

the real observations

fitted

the fitted density

numDrawn

how many observations to draw from the fit; the real sample size by default

streamNum

the stream to draw with, so the figure is reproducible

streamProvider

the stream provider

binWidth

the dot bin width, defaulting to a hundredth of the range

variableName

what the observations measure, for the axis label

Constructors

Link copied to clipboard
constructor(data: DoubleArray, fitted: ContinuousDistributionIfc, numDrawn: Int = data.size, streamNum: Int = 1, streamProvider: RNStreamProviderIfc = ksl.utilities.random.rvariable.KSLRandom.DefaultRNStreamProvider, binWidth: Double = defaultDotBinWidth(data), variableName: String = "observed value")

Properties

Link copied to clipboard

An optional caption. Empty by default; see AdmissibleCutPlot.caption for why.

Link copied to clipboard

The drawn sample, so a caller can report on it rather than only look at it.

Functions

Link copied to clipboard
open override fun buildPlot(): Plot

Builds a new instance of a Lets-Plot representation of the plot