The question is about the process, not the numbers
Phitter asks you to choose fit_type before it fits anything, and the choice cannot be deferred: continuous and discrete distributions are fitted by different procedures and compared against different tests.
The decision is not made by looking at how the values are stored. A column of integers may describe a continuous quantity that happened to be rounded. A column of decimals may describe counts that were averaged upstream. The question to answer is what the underlying process can produce:
- Discrete if the outcome is countable — the number of arrivals in an hour, defects per batch, items in an order. Between 3 and 4 there is nothing.
- Continuous if the outcome is measurable — duration, weight, distance, temperature. Between 3 and 4 there is everything, and the recorded precision is a property of the instrument, not of the quantity.
The useful test is whether “3.5” is meaningful. Half an hour of downtime is meaningful. Half a customer is not.
Cases that look like the wrong one
Rounded continuous data. Repair times logged in whole minutes look like counts. They are continuous measurements at one-minute resolution. Fit them as continuous. The rounding is a recording artefact, and it will show up as ties, not as discreteness.
Money. Prices in cents are technically discrete, but the grid is so fine relative to the range that a continuous model is both simpler and more accurate. The exception is a small set of allowed prices — a fare table, a menu — which is genuinely discrete.
Ordinal ratings. A five-point satisfaction scale produces integers, but the distance between 2 and 3 is not the distance between 4 and 5. Fitting a discrete distribution to it treats the codes as counts, which they are not. This usually needs a categorical or ordinal model rather than either option here.
Counts stored as floats. A pipeline that writes 4.0 has not created a continuous quantity. Check whether the fractional part is always zero.
Aggregated counts. An average of counts is continuous even though the inputs were discrete. Fitting an average of daily arrivals as discrete is a category error.
A diagnostic that takes one line
import numpy as np
distinct = len(np.unique(data))
print(distinct, len(data), distinct / len(data))
print(np.all(np.equal(np.mod(data, 1), 0))) # integer-valued?
Two signals, read together with what you know about the process:
- All values integer and few distinct values relative to n — say fewer than 30 distinct in 500 observations — points to genuinely discrete data.
- Nearly every value distinct points to continuous data, whatever the storage type.
- Integer-valued with many distinct values is the ambiguous case, and it is where knowing the process matters. Thousands of distinct integer counts behave enough like a continuum that a continuous model often works well; the decision should rest on what you intend to compute.
What breaks when the choice is wrong
Continuous model on discrete data. The model assigns zero probability to every individual value, so P(X = 3) is unavailable — often the exact quantity a count model exists to provide. Quantiles come back fractional: an inventory model that recommends holding 4.7 units has to be rounded by hand, and rounding a quantile is not the same as computing the quantile of the rounded variable. The chi-square test still works, but Kolmogorov–Smirnov and Anderson–Darling become unreliable, because their theory assumes a continuous underlying distribution and the ties created by repeated values violate it.
Discrete model on continuous data. Resolution is lost at the point where it usually matters. A discrete fit to durations rounded to the minute cannot represent anything finer, and the tail — where simulation spends its time — becomes a step function whose steps are an artefact of the recording precision.
How Phitter splits the two
phi = phitter.Phitter(data=data, fit_type="continuous") # or "discrete"
phi.fit(n_workers=4)
The two paths draw on different catalogues. The continuous side covers the standard families and their location-shifted and four-parameter variants; the discrete side covers Bernoulli, binomial, geometric, hypergeometric, logarithmic, negative binomial, Poisson, uniform and others. The reported diagnostics differ accordingly: chi-square is the primary test for discrete fits, where binning is natural rather than imposed.
Support is the constraint to check first in either case. Many count distributions are bounded below at zero and unbounded above; some, like the binomial and hypergeometric, are bounded at both ends by parameters that must correspond to something real in your process. A binomial fit whose estimated n is smaller than your largest observation is not a marginal result — it is an impossible one.
A checklist
- Can the process produce a value between two adjacent observations? If yes, continuous.
- Is every value an integer and is the count of distinct values small relative to n? If yes, discrete.
- Are the integers codes rather than counts — ratings, categories, identifiers? Then neither of these two options is right.
- Will you need
P(X = k)for a specific k? That requires a discrete model. - Does the process have a hard upper bound, and does the fitted model respect it?
Answer these before running the fit. They are cheaper than discovering the problem in the diagnostics, and some mismatches produce a plausible-looking fit that quietly answers the wrong question.