{ "info": { "author": "Andrew P Smith", "author_email": "a.p.smith@leeds.ac.uk", "bugtrack_url": null, "classifiers": [], "description": "# humanleague\n\n[![CRAN\\_Status\\_Badge](https://www.r-pkg.org/badges/version/humanleague)](https://CRAN.R-project.org/package=humanleague)\n[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/humanleague?color=black)](https://cran.r-project.org/package=humanleague)\n[![PyPI version](https://badge.fury.io/py/humanleague.svg)](https://badge.fury.io/py/humanleague)\n[![Travis Build Status](https://travis-ci.org/virgesmith/humanleague.png?branch=master)](https://travis-ci.org/virgesmith/humanleague)\n[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/x9oypgryt21ndc3p?svg=true)](https://ci.appveyor.com/project/virgesmith/humanleague)\n[![codecov](https://codecov.io/gh/virgesmith/humanleague/branch/master/graph/badge.svg)](https://codecov.io/gh/virgesmith/humanleague)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1116318.svg)](https://doi.org/10.5281/zenodo.1116318)\n[![status](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4/status.svg)](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4)\n\n> ## Latest news: 2.1 release\n> - adds new functionality for multidimensional integerisation. \n> - deletes previously deprecated functionality `synthPop` and `synthPopG`.\n> ### Multidimensional integerisation\n> Building on the `prob2IntFreq` function - which takes a discrete probability distribution and a count, and returns the closest integer population to the distribution that sums to the count - a multidimensional equivalent `integerise` is introduced.\n> \n> In one dimension, for example:\n> ```python\n> >>> import numpy as np\n> >>> import humanleague\n> >>> p=np.array([0.1, 0.2, 0.3, 0.4])\n> >>> humanleague.prob2IntFreq(p, 11)\n> {'freq': array([1, 2, 3, 5]), 'rmse': 0.3535533905932736}\n> ```\n> produces the optimal (i.e. closest possible) integer population to the discrete distribution.\n> \n> The `integerise` function generalises this problem and applies it to higher dimensions: given an n-dimensional array of real numbers where the 1-d marginal sums in every dimension are integral (and thus the total population is too), it attempts to find an integral array that also satisfies these constraints. \n\n> The QISI algorithm is repurposed to this end. As it is a sampling algorithm it cannot guarantee that a solution is found, and if so, whether the solution is optimal. If it fails this does not prove that a solution does not exist for the given input.\n\n> ```python\n> >>> a = np.array([[ 0.3, 1.2, 2. , 1.5],\n> [ 0.6, 2.4, 4. , 3. ],\n> [ 1.5, 6. , 10. , 7.5],\n> [ 0.6, 2.4, 4. , 3. ]])\n> # marginal sums\n> >> sum(a)\n> array([ 3., 12., 20., 15.])\n> >>> sum(a.T)\n> array([ 5., 10., 25., 10.])\n> # perform integerisation\n> >>> r = humanleague.integerise(a)\n> >>> r[\"conv\"]\n> True\n> >>> r[\"result\"]\n> array([[ 0, 2, 2, 1],\n> [ 0, 3, 4, 3],\n> [ 2, 6, 10, 7],\n> [ 1, 1, 4, 4]])\n> >>> r[\"rmse\"]\n> 0.5766281297335398\n> # check marginals are preserved\n> >>> sum(r[\"result\"]) == sum(a)\n> array([ True, True, True, True])\n> >>> sum(r[\"result\"].T) == sum(a.T)\n> array([ True, True, True, True])\n> ```\n>\n> ### Removed functions\n> The functions `synthPop` and `synthPopG` implement restricted versions of algorithms that are available in other functions.\n>\n> Use `qis` ins place of `synthPop`, and `qisi` in place of `synthPopG`.\n\n### Introduction\n\n*humanleague* is a python and an R package for microsynthesising populations from marginal and (optionally) seed data. The package is implemented in C++ for performance.\n\nThe package contains algorithms that use a number of different microsynthesis techniques:\n- [Iterative Proportional Fitting (IPF)](https://en.wikipedia.org/wiki/Iterative_proportional_fitting)\n- [Quasirandom Integer Sampling (QIS)](http://jasss.soc.surrey.ac.uk/20/4/14.html) (no seed population)\n- Quasirandom Integer Sampling of IPF (QISI): A combination of the two techniques whereby the integral population is sampled (without replacement) from a distribution constructed from a dynamic IPF solution.\n\nThe latter provides a bridge between deterministic reweighting and combinatorial optimisation, offering advantages of both techniques:\n- generates high-entropy integral populations \n- can be used to generate multiple populations for sensitivity analysis\n- goes some way to address the 'empty cells' issues that can occur in straight IPF\n- relatively fast compuation time\n\nThe algorithms: \n- support arbitrary dimensionality* for both the marginals and the seed.\n- produce statistical data to ascertain the likelihood/degeneracy of the population (where appropriate).\n\nThe package also contains the following utility functions:\n- a Sobol sequence generator\n- construct a closest integer population from a discrete univariate probability distribution.\n- an algorithm for sampling an integer population from a discrete multivariate probability distribution, constrained to the marginal sums in every dimension.\n- 'flatten' a multidimensional population into a table: this converts a multidimensional array containing the population count for each state into a table listing individuals and their characteristics. \n\nVersion 1.0.1 reflects the work described in the [Quasirandom Integer Sampling (QIS)](http://jasss.soc.surrey.ac.uk/20/4/14.html) paper.\n\n## R installation\nOfficial release:\n```\n> install.packages(\"humanleague\")\n```\nFor development version\n```bash\n> devtools::install_github(\"virgesmith/humanleague\")\n```\nOr, for the legacy version\n```bash\n> devtools::install_github(\"virgesmith/humanleague@1.0.1\")\n```\n## python installation\n\nRequires Python 3 and numpy. PyPI package:\n```bash\npython3 -m pip install humanleague --user\n```\n[Conda-forge package is being worked on]\n\n### Build, install and test (from local cloned repo)\n```bash\n$ ./setup.py install --user\n```\n```bash\n$ ./setup.py test\n```\n### Examples\n\nConsult the package documentation, e.g.\n```\n> library(humanleague)\n> ?humanleague\n```\nin R, or for python:\n```\n>>> import humanleague as hl\n>>> help(hl)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/virgesmith/humanleague", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "humanleague", "package_url": "https://pypi.org/project/humanleague/", "platform": "", "project_url": "https://pypi.org/project/humanleague/", "project_urls": { "Homepage": "http://github.com/virgesmith/humanleague" }, "release_url": "https://pypi.org/project/humanleague/2.1.1/", "requires_dist": null, "requires_python": "", "summary": "Microsynthesis using quasirandom sampling and/or IPF", "version": "2.1.1" }, "last_serial": 4563469, "releases": { "2.0.3": [ { "comment_text": "", "digests": { "md5": "d2b367d587acb4ad4e6ef993e5f07f12", "sha256": "5dd3744495b8ee72b706e632b6cb9e860a6c7434cdc5b4be4cb4b05ade1f5b67" }, "downloads": -1, "filename": "humanleague-2.0.3.tar.gz", "has_sig": false, "md5_digest": "d2b367d587acb4ad4e6ef993e5f07f12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 66589, "upload_time": "2018-07-18T10:54:15", "url": "https://files.pythonhosted.org/packages/9d/42/c7ff4fa34c17809e12d245c2ee801b3615e5795db67785973dd787cc56e9/humanleague-2.0.3.tar.gz" } ], "2.0.5": [ { "comment_text": "", "digests": { "md5": "58d3c55cc92d7401b1039a727d76c9b1", "sha256": "71b238559eda9cfb2d2f5320bf190ef9212ae7cc02acf397752352464b8d3701" }, "downloads": -1, "filename": "humanleague-2.0.5.tar.gz", "has_sig": false, "md5_digest": "58d3c55cc92d7401b1039a727d76c9b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 73060, "upload_time": "2018-11-28T16:09:22", "url": "https://files.pythonhosted.org/packages/1a/46/9a538065131bf71278d956d240b0bcd7381837b37f290f1f868c37918c18/humanleague-2.0.5.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "cfd5fb546eff3d7068dda15354505b8c", "sha256": "c3e7706c1391b5240d2ffd6baa54d0a186eec1172055f71600a48b077d1d290b" }, "downloads": -1, "filename": "humanleague-2.1.0.tar.gz", "has_sig": false, "md5_digest": "cfd5fb546eff3d7068dda15354505b8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63458, "upload_time": "2018-12-05T10:25:50", "url": "https://files.pythonhosted.org/packages/9e/a0/f7e1a0b0b11f715ea8b5553aefdb12091c602617a8d3991da08ff94d5479/humanleague-2.1.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "c85cbe7f1ce6cac2c72f7190e059cfd4", "sha256": "bc4daae7178c9459324328823215054e2630da796c6d64457e25e3b154c36081" }, "downloads": -1, "filename": "humanleague-2.1.1.tar.gz", "has_sig": false, "md5_digest": "c85cbe7f1ce6cac2c72f7190e059cfd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63457, "upload_time": "2018-12-05T11:36:33", "url": "https://files.pythonhosted.org/packages/74/21/3e9a825dfc4213bcf3310a40f461d2b27971c308ec9607227d9671ed9a2f/humanleague-2.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c85cbe7f1ce6cac2c72f7190e059cfd4", "sha256": "bc4daae7178c9459324328823215054e2630da796c6d64457e25e3b154c36081" }, "downloads": -1, "filename": "humanleague-2.1.1.tar.gz", "has_sig": false, "md5_digest": "c85cbe7f1ce6cac2c72f7190e059cfd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63457, "upload_time": "2018-12-05T11:36:33", "url": "https://files.pythonhosted.org/packages/74/21/3e9a825dfc4213bcf3310a40f461d2b27971c308ec9607227d9671ed9a2f/humanleague-2.1.1.tar.gz" } ] }