在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:virgesmith/humanleague开源软件地址:https://github.com/virgesmith/humanleague开源编程语言:C++ 59.0%开源软件介绍:humanleagueIntroductionhumanleague is a python and an R package for microsynthesising populations from marginal and (optionally) seed data. The package is implemented in C++ for performance. 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:
The algorithms:
The package also contains the following utility functions:
Version 1.0.1 reflects the work described in the Quasirandom Integer Sampling (QIS) paper. InstallationPythonRequires Python 3.5 or newer. PyPIpython3 -m pip install humanleague --user Anacondaconda install -c conda-forge humanleague Build, install and test (from cloned repo)pip install -e .
pytest ROfficial release: > install.packages("humanleague") For a development version > devtools::install_github("virgesmith/humanleague") Or, for the legacy version > devtools::install_github("virgesmith/[email protected]") Documentation and ExamplesRConsult the package documentation, e.g. > library(humanleague)
> ?humanleague PythonThe package now contains type annotations and your IDE should automatically display this, e.g.: Multidimensional integerisationBuilding on the >>> import numpy as np
>>> import humanleague
>>> p=np.array([0.1, 0.2, 0.3, 0.4])
>>> humanleague.prob2IntFreq(p, 11)
{'freq': array([1, 2, 3, 5]), 'rmse': 0.3535533905932736} produces the optimal (i.e. closest possible) integer population to the discrete distribution. The 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. >>> a = np.array([[ 0.3, 1.2, 2. , 1.5],
[ 0.6, 2.4, 4. , 3. ],
[ 1.5, 6. , 10. , 7.5],
[ 0.6, 2.4, 4. , 3. ]])
# marginal sums
>> sum(a)
array([ 3., 12., 20., 15.])
>>> sum(a.T)
array([ 5., 10., 25., 10.])
# perform integerisation
>>> r = humanleague.integerise(a)
>>> r["conv"]
True
>>> r["result"]
array([[ 0, 2, 2, 1],
[ 0, 3, 4, 3],
[ 2, 6, 10, 7],
[ 1, 1, 4, 4]])
>>> r["rmse"]
0.5766281297335398
# check marginals are preserved
>>> sum(r["result"]) == sum(a)
array([ True, True, True, True])
>>> sum(r["result"].T) == sum(a.T)
array([ True, True, True, True]) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论