Stanford Researchers Beat Sparse Data Limits by Encoding Time Order Into Density Estimates
A mixed-integer optimization approach uses ordering constraints between related distributions to squeeze more accuracy out of small samples on a pregnancy Q&A platform.
ProTakeaways
- New paper formulates multi-distribution estimation as a mixed-integer convex quadratic program with stochastic order constraints.
- Averages 2.2% JSD reduction over unimodal baselines, up to 6.3% when samples are scarce.
- Motivated by search timing analysis on Mamari, a Japanese pregnancy and childcare Q&A platform.
- Encodes prior knowledge that related queries follow a known temporal precedence between distributions.
- Solved with Gurobi; runs in seconds but produces overly steep distributions needing smoothing.
- Best when many small-sample distributions share ordering; unhelpful when data is already plentiful.
When you have plenty of data, density estimation is a solved problem. When you don't, every scrap of prior knowledge counts. A new paper from researchers at Stanford, Hosei University, and Erdos Inc. shows how encoding one specific piece of prior knowledge, that one distribution should come before another in time, can meaningfully improve estimates when samples are scarce.
The setup comes from a real product problem. The paper tackles search behavior analysis on Mamari, a Japanese pregnancy and childcare Q&A platform. By 2024, Mamari is projected to have 3.5 million users, with 4 million monthly searches and 1.1 million monthly Q&A posts. The operators want to know when users search for specific terms relative to their child's age, so they can surface the right content at the right moment.
Why small samples break density estimation
For popular queries, the empirical distribution over search timing is already smooth and unimodal. The trouble starts with long-tail multi-word queries. Unimodal regression outperformed baseline methods in estimating search timing distributions for typical keywords, but estimation error increases for multi-term keywords such as first_trimester_body_weight, owing to smaller sample sizes.
Kernel density estimation, the usual go-to, tends to overfit spiky histograms when there are only a handful of observations. Gaussian fits assume symmetry the real data does not have. And fitting each distribution in isolation ignores an obvious structural fact: searches about the first trimester have to happen before searches about the second trimester, which have to happen before searches about the third.

Turning ordering into a constraint
The paper formalizes that intuition using stochastic order. For two random variables X1 and X2, X1 is stochastically smaller than X2 if the expectation of any increasing function is smaller under X1 than under X2, which is equivalent to the cumulative distribution of X1 being pointwise greater than or equal to that of X2. For discrete distributions on a shared support, that reduces to a set of linear inequalities on the cumulative sums, which is exactly the kind of thing an integer programming solver can chew on.
The authors stack three types of structure into one optimization problem:
- A simplex constraint so each estimate is a valid probability distribution.
- Unimodality, enforced with binary indicator variables marking whether each index sits before or after the peak.
- Stochastic order across pairs of distributions, tying the estimates together.
The objective is mean squared error against the empirical distribution. They also tested the Earth mover's distance and mean absolute error, but these did not demonstrate satisfactory performance. The final formulation is a mixed-integer convex quadratic program, which they solve with Gurobi Optimizer.
What the numbers look like
On synthetic data drawn from two overlapping normals, the proposed method (OURS) beats kernel density estimation handily at small sample sizes and converges to comparable performance as data grows.

On the real Mamari dataset, evaluated across 27 instances of related search queries, the pattern holds. Averaged Jensen-Shannon divergence at 10 records per query:
| Method | JSD (10 records) | JSD (80 records) |
|---|---|---|
| Empirical | 0.1425 | 0.0385 |
| Kernel | 0.0983 | 0.0302 |
| Unimodal | 0.0888 | 0.0286 |
| Ours | 0.0869 | 0.0287 |
Against the plain unimodal baseline, the reduction in estimation error was 2.19% on average, up to 6.35% at most, and as low as -0.68% at least. The gains are largest when more distributions are being estimated jointly, which makes sense: more ordering constraints means more information sharing between the sparse per-query samples.
When it helps and when it hurts
The honest failure mode is documented in the paper. When the number of records grows, unimodality and stochastic order constraints are often satisfied automatically, and imposing them can unnecessarily restrict the estimator and deteriorate accuracy. There is also a shape issue worth flagging for practitioners. The method can produce extremely steep distributions due to the monotonicity constraint, which may cause practical issues when computing summary statistics such as quantiles, so additional smoothing or regularization may be necessary.
Use this if:
- You are estimating several discrete distributions that share a natural temporal or ordinal precedence.
- Per-distribution sample sizes are small, roughly under 40 in the paper's experiments.
- You already trust the unimodality assumption for your data.
Skip it if you have plenty of data, if your distributions are multimodal, or if you need smooth quantile estimates without post-processing.
The broader takeaway
The real contribution here is not a new estimator so much as a clean template for injecting cross-distribution structure into density estimation as linear constraints inside an off-the-shelf solver. The model readily extends to alternatives such as convex and increasing convex orders, since their definitions also admit linear representations. The authors also point out that future extensions could automatically decide which stochastic order constraints to impose, rather than hard-coding them from domain knowledge.
The paper does not release code, and reproducing it requires a Gurobi license, which limits accessibility. Still, the formulation is short enough to reimplement in a few dozen lines against any MIQP solver, and the underlying idea generalizes cleanly to any setting where you have multiple related distributions with a known ordering, such as tracking customer interest across a marketing funnel or modeling disease progression stages.