Synthetic Population Generator

Generates high-entropy integer synthetic populations from marginal and (optionally) seed data using quasirandom sampling, in arbitrary dimensionality (Smith, Lovelace and Birkin (2017) ). The package also provides an implementation of the Iterative Proportional Fitting (IPF) algorithm (Zaloznik (2011) ).

Travis Build Status Appveyor Build status codecov License

humanleague is a python and an R package for microsynthesising populations from marginal and (optionally) seed data. The core code is implemented in C++, and the current release is version 2.

The package contains algorithms that use a number of different microsynthesis techniques:

The latter provides a bridge between deterministic reweighting and combinatorial optimisation, offering advantages of both techniques:

  • generates high-entropy integral populations
  • can be used to generate multiple populations for sensitivity analysis
  • goes some way to address the 'empty cells' issues that can occur in straight IPF
  • relatively fast compuation time

The algorithms:

  • support arbitrary dimensionality* for both the marginals and the seed.
  • produce statistical data to ascertain the likelihood/degeneracy of the population (where appropriate).

[* excluding the legacy functions retained for backward compatibility with version 1.0.1]

The package also contains the following utility functions:

  • a Sobol sequence generator
  • functionality to convert fractional to nearest-integer marginals (in 1D). This can also be achieved in multiple dimensions by using the QISI algorithm.
  • functionality to 'flatten' a population into a table: this converts a multidimensional array containing the population count for each state into a table listing individuals and their characteristics.

Version 1.0.1 reflects the work described in the Quasirandom Integer Sampling (QIS) paper.

R installation

Or, for the previous version

> devtools::install_github("virgesmith/[email protected]")

python installation

Requires Python 3, with numpy installed

pip install git+[email protected]

Build and test (from local repo)

[email protected]:~/dev/humanleague/python$ ./ test

Install (from local repo)

[email protected]:~/dev/humanleague/python$ ./ install

The latter command may require admin rights. On linux, sudo is unnecessary if you have group (e.g. staff) write access to /usr/local/lib.


Consult the package documentation, e.g.

> library(humanleague)
> ?humanleague

in R, or for python:

>>> import humanleague as hl
>>> help(hl)


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.1.0 by Andrew Smith, 2 months ago

Browse source code at

Authors: Andrew Smith [aut, cre] , Steven Johnson [ctb] (Sobol sequence generator implementation) , Massachusetts Institute of Technology [cph] (Sobol sequence generator implementation) , John Burkhardt [ctb, cph] (C++ implementation of incomplete gamma function) , G Bhattacharjee [ctb] (Original FORTRAN implementation of incomplete gamma function)

Documentation:   PDF Manual  

MIT + file LICENCE license

Imports Rcpp

Suggests testthat

Linking to Rcpp

See at CRAN