Documentation

Least Fill

For the design rationale, the algorithm, and how this technique is also used inside conjoint_question and MaxDiff, see Least-fill balancing methodology.

When and Why to Use

Use this to dynamically select a subset of items that have the fewest responses (i.e. are underrepresented) in a given quota. Ideal for:

  • Ensuring even coverage across a large set of items (e.g., brands, ads, concepts)
  • Avoiding over-exposure or over-sampling of frequently selected items
  • Dynamically balancing stimulus presentation

This does not enforce quotas or terminate users. It simply ranks items by current counts and returns the least-filled ones.

How It Works

  • Takes a list of items
  • Checks which ones are least filled in the named quota
  • Returns the top N least-filled items
  • Often paired with multi_select_question or select_question

Configuration Options

ParameterTypeRequiredDescription
numberintyesMaximum number of items to return
from_listList[Any]yesFull list of items to choose from
quotastryesName for the counter that tracks per-item assignments. Created on first use — you don't need to set it up separately.
group_byCallable[[Any], object] | NonenoReturn a hashable key to limit selection to one item per group.

Example Code

python
from survey import Survey s = Survey(**globals()) brand_list = [ 'Acura', 'Alfa Romeo', 'Aston Martin', 'Audi', 'Bentley', 'BMW', 'Bugatti', 'Buick', 'Cadillac', 'Chevrolet', 'Chrysler', 'Citroen', 'Dodge', 'Ferrari', 'Fiat', 'Ford', 'Geely', 'Genesis', 'GMC', 'Honda', 'Hyundai' # ...and so on ] brands = s.get_least_filled( number=10, from_list=brand_list, quota="Brand familiarity" ) familiar_brands = s.multi_select_question( question="Which of the following car brands have you heard of?", options=brands )

Select creatives from distinct brands

Give each image in the Creatives material a survey_brand value. Filter the candidate list to brands relevant to the respondent and pass a grouping function. This example can show up to two creatives, each from a different brand:

Code
eligible_brands = ["Alder", "Beacon", "Cedar"] candidates = [ ad for ad in s.get_images("Creatives") if ad.survey_brand in eligible_brands ] assigned_creatives = s.get_least_filled( 2, candidates, "Creative rotation", group_by=lambda ad: ad.survey_brand, ) for creative in assigned_creatives: s.show_image(image=creative)

The platform considers the least-filled item in each group. Each candidate must have a unique string identity, which is the filename for media. Use the same quota name across respondents to keep each creative's count when the eligible list changes. The counter tracks assignments among completed respondents. In-progress respondents do not reserve places.

For quotas that can terminate respondents, see Setting up quotas.

Notes

  • This is often used for rotating large brand or product lists evenly
  • Use set_quota() if you want to enforce a fixed distribution with termination
  • The counter named by quota is created the first time get_least_filled is called with that name — you do not need to set it up beforehand. Two calls that share the same quota name share the same counter; calls with different names track independently.