{"id":13849702,"url":"https://github.com/mynl/aggregate","last_synced_at":"2025-04-10T17:55:34.995Z","repository":{"id":43325551,"uuid":"146960817","full_name":"mynl/aggregate","owner":"mynl","description":"Tools for creating and working with aggregate probability distributions.","archived":false,"fork":false,"pushed_at":"2024-03-06T21:21:27.000Z","size":72885,"stargazers_count":38,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-25T20:01:56.420Z","etag":null,"topics":["actuarial","actuarial-modeling","actuarial-science","actuary","aggregate","compound","compound-poisson","distribution","insurance","probability","probability-distribution","risk","risk-management","risk-theory","ruin-theory"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mynl.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-09-01T02:32:35.000Z","updated_at":"2024-04-25T20:01:56.420Z","dependencies_parsed_at":"2022-09-01T09:41:39.145Z","dependency_job_id":"bfade5a5-377e-41d9-8ee3-f8a5e54e1a3a","html_url":"https://github.com/mynl/aggregate","commit_stats":{"total_commits":287,"total_committers":5,"mean_commits":57.4,"dds":0.6376306620209059,"last_synced_commit":"3885427df035c1eb7275ff70ea9c645cebd916aa"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynl%2Faggregate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynl%2Faggregate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynl%2Faggregate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mynl%2Faggregate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mynl","download_url":"https://codeload.github.com/mynl/aggregate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262467,"owners_count":21074314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actuarial","actuarial-modeling","actuarial-science","actuary","aggregate","compound","compound-poisson","distribution","insurance","probability","probability-distribution","risk","risk-management","risk-theory","ruin-theory"],"created_at":"2024-08-04T20:00:38.486Z","updated_at":"2025-04-10T17:55:34.986Z","avatar_url":"https://github.com/mynl.png","language":"Python","funding_links":[],"categories":["P\u0026C-related packages","Python"],"sub_categories":["Experience Analysis"],"readme":"|  |activity| |doc| |version|\n|  |py-versions| |downloads| |stars| |forks| \n|  |license| |packages| |zenodo|\n\n-----\n\naggregate: working with actuarial compound distributions\n===========================================================\n\nPurpose\n-----------\n\n``aggregate`` builds approximations to compound (aggregate) probability distributions quickly and accurately.\nIt can be used to solve insurance, risk management, and actuarial problems using realistic models that reflect\nunderlying frequency and severity. It delivers the speed and accuracy of parametric distributions to situations\nthat usually require simulation, making it as easy to work with an aggregate (compound) probability distribution\nas the lognormal. ``aggregate`` includes an expressive language called DecL to describe aggregate distributions\nand is implemented in Python under an open source BSD-license.\n\nAggregate White Paper\n----------------------\n\n`Aggregate: fast, accurate, and flexible approximation of compound probability distributions \u003chttps://www.cambridge.org/core/journals/annals-of-actuarial-science/article/aggregate-fast-accurate-and-flexible-approximation-of-compound-probability-distributions/1BF9A534D944D983B1D780C60885F065\u003e`_ describes the ``Aggregate`` class within ``aggregate``. This paper has been published in the peer reviewed journal `Annals of Actuarial Science \u003chttps://www.cambridge.org/core/journals/annals-of-actuarial-science\u003e`_'s Actuarial Software series.\nThe paper describes the purpose, implementation, and use ``Aggregate``, showing how it can be used to create and manipulate compound frequency-severity distributions.\n\nVersion History\n-----------------\n\n.. Conda Forge: https://github.com/conda-forge/aggregate-feedstock https://anaconda.org/conda-forge/aggregate/files\n\n\n0.26.0\n~~~~~~~~~~\n* ``extensions`` no longer sets ``pd.float_format`` to Engineering.\n* Added ``tweedie.Tweedie`` class to ``extensions`` to compute the Tweedie class distributions for\n  all valid :math:`p`. (Dangling jax dependence.)\n\n0.25.0\n~~~~~~~~~~~~\n* Tweak ``extensions.ft.FourierTools``: added ``invert_simpson`` method using Simpson's rule,\n  better for stable distributions. This is the method used by ``scipy.stats``.\n* Bumped to 0.25 which should have done in 0.24.2 because it added new functionality\n* Tidied docs\n* ``knobble_fonts`` uses serif font by default in matplotlib, and sets up\n  in color mode by default. \n\n0.24.2\n~~~~~~~~~~\n\n* Added ``Distortion.make_q`` to return the risk adjusted probabilities used\n  in pricing. Same logic as ``price_ex``. Makes it easy to compute the natural\n  allocation from a distortion.\n* Added ``extensions.ft.FourierTools`` class, which performs direct inversion of a (continuous) Fourier transform (characteristic function)\n  using FFTs. This is particularly useful for stable distributions, where the Fourier transform is known but the density is not. See examples in Section 5 of the documentation.\n* Added ``make_levy_chf`` to ``extensions`` to compute the characteristic function of a Levy stable distribution.\n\n0.24.1\n~~~~~~~~~~\n* Added script to build the documentation from a local clone of the repository.\n* Added ``Aggregate.unwrap`` to adjust aggregates computed with too few buckets\n  but enough space. It unwraps the computed aggregate by adjusting the index. This\n  reverses the \"wagon-wheel\" effect, whereby FFTs wrap-around the end of the array.\n* Vectorized ``ultilities.estimate_agg_percentile`` for use in ``Aggregate.unwrap``\n\n0.24.0\n~~~~~~~~~~\n* Added state to Distortions so they can be pickled. Involved separating part of ``Distortion.__init__``\n  into a new method, ``Distortion._complete_init``. This is called from ``__init__`` and ``__setstate__``.\n  Ensured _complete_init refers to arguments as self.argname, not argname and set self\n  variables in class ``__init__`` method.\n* Fixed mixture g functions to handle input multidimensional arrays.\n* Simplified ``Distortion.__repr__`` and ``Distortion.__str__``.\n* Added ``Distortion.id`` to generate a unique ID depending on ``__dict__`` argument elements.\n* Corrected ``g_prime`` for minimum distortion.\n* Fixed biTVaR distortion to handle p1==1 by including the mass explicitly.\n* Added ``Distortion.price_ex`` to combine best of price and price2 methods and improve flexibility. It sorts and summarizes if needed. Optional return formats.\n* Added four numba compiled functions to Distortion for fast computation of\n  g.g(1-ps.cumsum()) and g.price( kind='ask'). These are tvar_gS, bitvar_gS,\n  tvar_ra (for risk adjusted expected value) and bitvar_ra. In each case the\n  values are computed without any copies of the original data, making them\n  far more memory efficient for very large input arrays. At the extreme,\n  bitvar_ra results in a speed up of the order of 2000x in realistic\n  situations, even with small (100s) input vectors. The functions are static\n  members of Distortion (numba requirement). They are not parallelized\n  because of the cumulative computation of S. See the file\n  PyWork/Distortion-price-tester.ipynb for tests (TODO: integraete into the\n  documentation.)  This addition results in numba being a required package.\n* Removed dependency on ``titlecase`` package.\n* Removed ``Distortion.calibrate`` method, which was not used and never tested. It lives with ``Portfolio``.\n\n0.23.0\n~~~~~~~~~~\n\n* Added ``sample_df`` dataframe to ``Portfolio`` when created from a sample\n  to store the sample. Original sample is needed in various applications.\n* Added ``swap_density_df(self, new_df, padding=1)`` to ``Portfolio``.\n* Fixed errors in Case Studies caused by changes in Pandas.\n* Added ability to create Markdown case output, rather than HTML.\n* Added beta distortion (generalizes the PH and dual)\n* Updated ``np.alltrue`` to ``np.all``; updated ``NoConverge`` in ``scipy.optimize``.\n* Added ``Distortion.calibrate`` to calibrate to a pricing target from input ``density_df`` (TODO: needs testing).\n* Added `wtdtvar`` to ``Distortion`` to compute the weighted TVaR from p values and weights,\n  masses and mean components.\n* Added ``minimum`` to ``Distortion`` to create a new ``Distortion`` as the minimum of a list of input Distortions. The list is passed as shape.\n* Added ``random_distortion`` to ``Distortions`` to compute a random distortion, useful\n  for testing!\n* Fixed ``tvar`` distortion to allow p=1 (max)\n* Simplified ``Distortion.__repr__`` and ``Distortion.__str__``.\n* Added `Distortion.ph``, ``.wang``, ...,  methods for common distortions, with better\n  hints for parameters. All are static methods that delegate to the constructor.\n* Fixed documentation build errors.\n\n0.22.0\n~~~~~~~~~~\n\n* Created version 0.22.0, \"convolation\" for AAS submission\n\n0.21.4\n~~~~~~~~\n\n* Updated requirement using ``pipreqs`` recommendations\n* Color graphics in documentation\n* Added ``expected_shift_reduce = 16  # Set this to the number of expected shift/reduce conflicts`` to ``parser.py``\n  to avoid warnings. The conflicts are resolved in the correct way for the grammar to work.\n* Issues: there is a difference between ``dfreq[1]`` and ``1 claim ... fixed``, e.g.,\n  when using spliced severities. These should not  occur.\n\n\n0.21.3\n~~~~~~~~\n\n* Risk progression, defaults to linear allocation.\n* Added ``g_insurance_statistics`` to ``extensions`` to plot insurance statistics from a distortion ``g``.\n* Added ``g_risk_appetite`` to ``extensions`` to plot risk appetite from a distortion ``g`` (value, loss ratio,\n  return on capital, VaR and TVaR weights).\n* Corrected Wang distortion derivative.\n* Vectorized ``Distortion.g_prime`` calculation for proportional hazard\n* Added ``tvar_weights`` function to ``spectral`` to compute the TVaR weights of a distortion. (Work in progress)\n* Updated dependencies in pyproject.toml file.\n\n0.21.2\n~~~~~~~~\n\n* Misc documentation updates.\n* Experimental magic functions, allowing, eg. %agg [spec] to create an aggregate object (one-liner).\n* 0.21.1 yanked from pypi due to error in pyproject.toml.\n\n0.21.0\n~~~~~~~~~\n\n* Moved ``sly`` into the project for better control.  ``sly`` is a Python implementation of lex and yacc parsing tools.\n  It is written by Dave Beazley. Per the sly repo on github:\n\n  The SLY project is no longer making package-installable releases. It's fully functional, but if choose to use it,\n  you should vendor the code into your application. SLY has zero-dependencies. Although I am semi-retiring the project,\n  I will respond to bug reports and still may decide to make future changes to it depending on my mood.\n  I'd like to thank everyone who has contributed to it over the years. --Dave\n\n* Experimenting with a line/cell DecL magic interpreter in Jupyter Lab to obviate the\n  need for ``build``.\n\n0.20.2\n~~~~~~~~~\n\n* risk progression logic adjusted to exclude values with zero probability; graphs\n  updated to use step drawstyle.\n\n0.20.1\n~~~~~~~\n\n* Bug fix in parser interpretation of arrays with step size\n* Added figures for AAS paper to extensions.ft and extensions.figures\n* Validation \"not unreasonable\" flag set to 0\n* Added aggregate_white_paper.pdf\n* Colors in risk_progression\n\n0.20.0\n~~~~~~~\n\n* ``sev_attachment``: changed default to ``None``; in that case gross losses equal\n  ground-up losses, with no adjustment. But if layer is 10 xs 0 then losses\n  become conditional on X \u003e 0. That results in a different behaviour, e.g.,\n  when using ``dsev[0:3]``. Ripple through effect in Aggregate (change default),\n  Severity (change default, and change moment calculation; need to track the \"attachment\"\n  of zero and the fact that it came from None, to track Pr attaching)\n* dsev: check if any elements are \u003c 0 and set to zero before computing moments\n  in dhistogram\n* same for dfreq; implemented in ``validate_discrete_distribution`` in distributions module\n* Default ``recommend_p=0.99999`` set in constsants module.\n* ``interpreter_test_suite`` renamed to ``run_test_suite`` and includes test\n  to count and report if there are errors.\n* Reason codes for failing validation; Aggregate.qt becomes Aggregte.explain_validation\n\n0.19.0\n~~~~~~~\n\n* Fixed reinsurance description formatting\n* Improved splice parsing to allow explicit entry of lb and ub; needed to\n  model mixtures of mixtures (Albrecher et al. 2017)\n\n0.18.0 (major update)\n~~~~~~~~~~~~~~~~~~~~~~~\n\n* Added ability to specify occ reinsurance after a built in agg; this\n  allows you to alter a gross aggregate more easily.\n* ``Underwriter.safe_lookup`` uses deepcopy rather than copy to avoid\n  problems array elements.\n* Clean up and improved Parser and grammar\n\n    - atom -\u003e term is much cleaner (removed power, factor; now\n      managed with prcedence and assoicativity)\n    - EXP and EXPONENT are right\n      associative, division is not associative so 1/2/3 gives an error.\n    - Still SR conflict from dfreq [ ] [  ] because it could be the\n      probabilities clause or the start of a vectorized limit clause\n    - Remaining SR conflicts are from NUMBER, which is used in many\n      places. This is a problem with the grammar, not the parser.\n    - Added more tests to the parser test suite\n    - Severity weights clause must come after locations (more natural)\n    - Added ability for unconditional dsev.\n    - Support for splicing (see below)\n\n* Cleanup of ``Aggregate`` class, concurrent with creating a cheat sheet\n\n    - many documentation updates\n    - ``plot_old`` deleted\n    - deleted ``delbaen_haezendonck_density``; not used; not doing anything\n      that isn't easy by hand. Includes dh_sev_density and dh_agg_density.\n    - deleted ``fit`` as alternative name for ``approximate``\n    - deleted unused fields\n\n* Cleanup of ``Portfolio`` class, concurrent with creating a cheat sheet\n\n    - deleted ``fit`` as alternative name for ``approximate``\n    - deleted ``q_old_0_12_0`` (old quantile), ``q_temp``, ``tvar_old_0_12_0``\n    - deleted ``plot_old``, ``last_a``, ``_(inverse)_tail_var(_2)``\n    - deleted ``def get_stat(self, line='total', stat='EmpMean'): return self.audit_df.loc[line, stat]``\n    - deleted ``resample``, was an alias for sample\n\n* Management of knowledge in ``Underwriter`` changed to support loading\n  a database after creation. Databases not loaded until needed - alas\n  that includes printing the object. TODO: Consider a change?\n* Frequency mfg renamed to freq_pgf to match other Frequency class methods and\n  to accuractely describe the function as a probability generating function\n  rather than a moment generating function.\n* Added ``introspect`` function to Utilities. Used to create a cheat sheet\n  for Aggregate.\n* Added cheat sheets, completed for Aggregate\n* Severity can now be conditional on being in a layer (see splice); managed\n  adjustments to underlying frozen rv using decorators. No overhead if not\n  used.\n* Added \"splice\" option for Severity (see Albrecher et. al ch XX) and Aggregate,\n  new arguments ``sev_lb`` and ``sev_ub``, each lists.\n* ``Underwriter.build`` defaults update argument to None, which uses the object default.\n* pretty printing: now returns a value, no tacit mode; added _html version to\n  run through pygments, that looks good in Jupyter Lab.\n\n0.17.1\n~~~~~~~~\n\n* Adjusted pyproject.toml\n* pygments lexer tweaks\n* Simplified grammar: % and inf now handled as part of resolving NUMBER; still 16 = 5 * 3 + 1 SR conflicts\n* Reading databases on demand in Underwriter, resulting in faster object creation\n* Creating and testing exsitance of subdirectories in Undewriter on demand using properties\n* Creating directories moved into Extensions __init__.py\n* lexer and parser as properties for Underwriter object creation\n* Default ``recommend_p`` changed from 0.999 to 0.99999.\n* ``recommend_bucket`` now uses ``p=max(p, 1-1e-8)`` if severity is unlimited.\n\n\n0.17.0 (July 2023)\n~~~~~~~~~~~~~~~~~~~~\n\n* ``more`` added as a proper method\n* Fixed debugfile in parser.py which stops installation if not None (need to\n  enure the directory exists)\n* Fixed build and MANIFEST to remove build warning\n* parser: semicolon no longer mapped to newline; it is now used to provide hints\n  notes\n* ``recommend_bucket`` uses p=max(p, 1-1e-8) if limit=inf. Default increased from 0.999\n  to 0.99999 based on examples; works well for limited severity but not well for unlimited severity.\n* Implemented calculation hints in note strings. Format is k=v; pairs; k\n  bs, log2, padding, recommend_p, normalize are recognized. If present they are used\n  if no arguments are passed explicitly to ``build``.\n* Added ``interpreter_test_suite()`` to ``Underwriter`` to run the test suite\n* Added ``test_suite_file`` to ``Underwriter`` to return ``Path`` to ``test_suite.agg``` file\n* Layers, attachments, and the reinsurance tower can now be ranges, ``[s:f:j]`` syntax\n\n0.16.1 (July 2023)\n~~~~~~~~~~~~~~~~~~~~\n\n* IDs can now include dashes: Line-A is a legitimate date\n* Include templates and test-cases.agg file in the distribution\n* Fixed mixed severity / limit profile interaction. Mixtures now work with\n  exposure defined by losses and premium (as opposed to just claim count),\n  correctly account for excess layers (which requires re-weighting the\n  mixture components). Involves fixing the ground up severity and using it\n  to adjust weights first. Then, by layer, figure the severity and convert\n  exposure to claim count if necessary. Cases where there is no loss in the\n  layer (high layer from low mean / low vol componet) replace by zero. Use\n  logging level 20 for more details.\n* Added ``more`` function to ``Portfolio``, ``Aggregate`` and ``Underwriter`` classes.\n  Given a regex it returns all methods and attributes matching. It tries to call a method\n  with no arguments and reports the answer. ``more`` is defined in utilities\n  and can be applied to any object.\n* Moved work of ``qt`` from utilities into ``Aggregate``` (where it belongs).\n  Retained ``qt`` for backwards compatibility.\n* Parser: power \u003c- atom ** factor to power \u003c- factor ** factor to allow (1/2)**(3/4)\n* ``random` module renamed `random_agg`` to avoid conflict with Python ``random``\n* Implemented exact moments for exponential (special case of gamma) because\n  MED is a common distribution and computing analytic moments is very time\n  consuming for large mixtures.\n* Added ZM and ZT examples to test_cases.agg; adjusted Portfolio examples to\n  be on one line so they run through interpreter_file tests.\n\n0.16.0 (June 2023)\n~~~~~~~~~~~~~~~~~~~~\n\n* Implemented ZM and ZT distributions using decorators!\n* Added panjer_ab to Frequency, reports a and b values, p_k = (a + b / k) p_{k-1}. These values can be tested\n  by computing implied a and b values from r_k = k p_k / p_{k-1} = ak + b; diff r_k = a and b is an easy\n  computation.\n* Added freq_dist(log2) option to Freq to return the frequency distribution stand-alone\n* Added negbin frequency where freq_a equals the variance multiplier\n\n\n0.15.0 (June 2023)\n~~~~~~~~~~~~~~~~~~~~\n\n* Added pygments lexer for decl (called agg, agregate, dec, or decl)\n* Added to the documentation\n* using pygments style in ``pprint_ex`` html mode\n* removed old setup scripts and files and stack.md\n\n0.14.1 (June 2023)\n~~~~~~~~~~~~~~~~~~~~\n\n* Added scripts.py for entry points\n* Updated .readthedocs.yaml to build from toml not requirements.txt\n* Fixes to documentation\n* ``Portfolio.tvar_threshold`` updated to use ``scipy.optimize.bisect``\n* Added ``kaplan_meier`` to ``utilities`` to compute product limit estimator survival\n  function from censored data. This applies to a loss listing with open (censored)\n  and closed claims.\n* doc to docs []\n* Enhanced ``make_var_tvar`` for cases where all probabilities are equal, using linspace rather\n  than cumsum.\n\n0.13.0 (June 4, 2023)\n~~~~~~~~~~~~~~~~~~~~~~~\n\n* Updated ``Portfolio.price`` to implement ``allocation='linear'`` and\n  allow a dictionary of distortions\n* ``ordered='strict'`` default for ``Portfolio.calibrate_distortions``\n* Pentagon can return a namedtuple and solve does not return a dataframe (it has no return value)\n* Added random.py module to hold random state. Incorporated into\n\n    - Utilities: Iman Conover (ic_noise permuation) and rearrangement algorithms\n    - ``Portfolio`` sample\n    - ``Aggregate`` sample\n    - Spectral ``bagged_distortion``\n\n* ``Portfolio`` added ``n_units`` property\n* ``Portfolio`` simplified ``__repr__``\n* Added ``block_iman_conover``  to ``utilitiles``. Note tester code in the documentation. Very Nice! 😁😁😁\n* New VaR, quantile and TVaR functions: 1000x speedup and more accurate. Builder function in ``utilities``.\n* pyproject.toml project specification, updated build process, now creates whl file rather than egg file.\n\n0.12.0 (May 2023)\n~~~~~~~~~~~~~~~~~~~\n\n* ``add_exa_sample`` becomes method of ``Portfolio``\n* Added ``create_from_sample`` method to ``Portfolio``\n* Added ``bodoff`` method to compute layer capital allocation to ``Portfolio``\n* Improved validation error reporting\n* ``extensions.samples`` module deleted\n* Added ``spectral.approx_ccoc`` to create a ct approx to the CCoC distortion\n* ``qdp`` moved to ``utilities`` (describe plus some quantiles)\n* Added ``Pentagon`` class in ``extensions``\n* Added example use of the Pollaczeck-Khinchine formula, reproducing examples from\n  the `actuar`` risk vignette to Ch 5 of the documentation.\n\nEarlier versions\n~~~~~~~~~~~~~~~~~~\n\nSee github commit notes.\n\nVersion numbers follow semantic versioning, MAJOR.MINOR.PATCH:\n\n* MAJOR version changes with incompatible API changes.\n* MINOR version changes with added functionality in a backwards compatible manner.\n* PATCH version changes with backwards compatible bug fixes.\n\n\nDocumentation\n-------------\n\nhttps://aggregate.readthedocs.io/\n\n\nWhere to get it\n---------------\n\nhttps://github.com/mynl/aggregate\n\n\nInstallation\n------------\n\nTo install into a new ``Python\u003e=3.10`` virtual environment::\n\n    python -m venv path/to/your/venv``\n    cd path/to/your/venv\n\nfollowed by::\n\n    \\path\\to\\env\\Scripts\\activate\n\non Windows, or::\n\n    source /path/to/env/bin/activate\n\non Linux/Unix or MacOS. Finally, install the package::\n\n    pip install aggregate[dev]\n\nAll the code examples have been tested in such a virtual environment and the documentation will build.\n\nTo build the documentation run\n\n\nIssues and Todo\n-----------------\n\n* Treatment of zero lb is not consistent with attachment equals zero.\n* Flag attempts to use fixed frequency with non-integer expected value.\n* Flag attempts to use mixing with inconsistent frequency distribution.\n\nGetting started\n---------------\n\nTo get started, import ``build``. It provides easy access to all functionality.\n\nHere is a model of the sum of three dice rolls. The DataFrame ``describe`` compares exact mean, CV and skewness with the ``aggregate`` computation for the frequency, severity, and aggregate components. Common statistical functions like the cdf and quantile function are built-in. The whole probability distribution is available in ``a.density_df``.\n\n::\n\n  from aggregate import build, qd\n  a = build('agg Dice dfreq [3] dsev [1:6]')\n  qd(a)\n\n\u003e\u003e\u003e        E[X] Est E[X]    Err E[X]   CV(X) Est CV(X)   Err CV(X) Skew(X) Est Skew(X)\n\u003e\u003e\u003e  X\n\u003e\u003e\u003e  Freq     3                            0\n\u003e\u003e\u003e  Sev    3.5      3.5           0 0.48795   0.48795 -3.3307e-16       0  2.8529e-15\n\u003e\u003e\u003e  Agg   10.5     10.5 -3.3307e-16 0.28172   0.28172 -8.6597e-15       0 -1.5813e-13\n\n::\n\n  print(f'\\nProbability sum \u003c 12 = {a.cdf(12):.3f}\\nMedian = {a.q(0.5):.0f}')\n\n\u003e\u003e\u003e  Probability sum \u003c 12 = 0.741\n\u003e\u003e\u003e  Median = 10\n\n\n``aggregate`` can use any ``scipy.stats`` continuous random variable as a severity, and\nsupports all common frequency distributions. Here is a compound-Poisson with lognormal\nseverity, mean 50 and cv 2.\n\n::\n\n  a = build('agg Example 10 claims sev lognorm 50 cv 2 poisson')\n  qd(a)\n\n\u003e\u003e\u003e       E[X] Est E[X]   Err E[X]   CV(X) Est CV(X) Err CV(X)  Skew(X) Est Skew(X)\n\u003e\u003e\u003e X\n\u003e\u003e\u003e Freq    10                     0.31623                      0.31623\n\u003e\u003e\u003e Sev     50   49.888 -0.0022464       2    1.9314 -0.034314       14      9.1099\n\u003e\u003e\u003e Agg    500   498.27 -0.0034695 0.70711   0.68235 -0.035007   3.5355      2.2421\n\n::\n\n  # cdf and quantiles\n  print(f'Pr(X\u003c=500)={a.cdf(500):.3f}\\n0.99 quantile={a.q(0.99)}')\n\n\u003e\u003e\u003e Pr(X\u003c=500)=0.611\n\u003e\u003e\u003e 0.99 quantile=1727.125\n\nSee the documentation for more examples.\n\nDependencies\n------------\n\nSee requirements.txt.\n\nInstall from source\n--------------------\n::\n\n    git clone --no-single-branch --depth 50 https://github.com/mynl/aggregate.git .\n\n    python -mvirtualenv ./venv\n    # activate the virtual environment (Windows, YRMV)\n    venv\\Scripts\\activate.bat\n\n    # install the package\n    pip install aggregate[dev]\n\n\nLicense\n-------\n\nBSD 3 licence.\n\nHelp and contributions\n-------------------------\n\nLimited help available. Email me at help@aggregate.capital.\n\nAll contributions, bug reports, bug fixes, documentation improvements,\nenhancements and ideas are welcome. Create a pull request on github and/or\nemail me.\n\nSocial media: https://www.reddit.com/r/AggregateDistribution/.\n\n\n.. substitutions\n\n.. |downloads| image:: https://img.shields.io/pypi/dm/aggregate.svg\n    :target: https://pepy.tech/project/aggregate\n    :alt: Downloads\n\n.. |stars| image:: https://img.shields.io/github/stars/mynl/aggregate.svg\n    :target: https://github.com/mynl/aggregate/stargazers\n    :alt: Github stars\n\n.. |forks| image:: https://img.shields.io/github/forks/mynl/aggregate.svg\n    :target: https://github.com/mynl/aggregate/network/members\n    :alt: Github forks\n\n.. |contributors| image:: https://img.shields.io/github/contributors/mynl/aggregate.svg\n    :target: https://github.com/mynl/aggregate/graphs/contributors\n    :alt: Contributors\n\n.. |version| image:: https://img.shields.io/pypi/v/aggregate.svg?label=pypi\n    :target: https://pypi.org/project/aggregate\n    :alt: Latest version\n\n.. |activity| image:: https://img.shields.io/github/commit-activity/m/mynl/aggregate\n   :target: https://github.com/mynl/aggregate\n   :alt: Latest Version\n\n.. |py-versions| image:: https://img.shields.io/pypi/pyversions/aggregate.svg\n    :alt: Supported Python versions\n\n.. |license| image:: https://img.shields.io/pypi/l/aggregate.svg\n    :target: https://github.com/mynl/aggregate/blob/master/LICENSE\n    :alt: License\n\n.. |packages| image:: https://repology.org/badge/tiny-repos/python:aggregate.svg\n    :target: https://repology.org/metapackage/python:aggregate/versions\n    :alt: Binary packages\n\n.. |doc| image:: https://readthedocs.org/projects/aggregate/badge/?version=latest\n    :target: https://aggregate.readthedocs.io/en/latest/\n    :alt: Documentation Status\n\n.. |zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.10557199.svg\n    :target: https://zenodo.org/records/10557199\n    :alt: Zenodo DOI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynl%2Faggregate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmynl%2Faggregate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmynl%2Faggregate/lists"}