{"id":20862394,"url":"https://github.com/bencheeorg/statistex","last_synced_at":"2025-04-05T22:05:21.361Z","repository":{"id":57552995,"uuid":"193720124","full_name":"bencheeorg/statistex","owner":"bencheeorg","description":"Calculate statistics on data sets, reusing previously calculated values or just all metrics at once. Part of the benchee library family.","archived":false,"fork":false,"pushed_at":"2025-01-12T17:19:35.000Z","size":60,"stargazers_count":27,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T21:04:07.314Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bencheeorg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-25T14:08:08.000Z","updated_at":"2025-01-12T17:19:37.000Z","dependencies_parsed_at":"2023-12-10T10:25:51.682Z","dependency_job_id":"a1d2696c-ec4f-4392-abca-506d7fe587fd","html_url":"https://github.com/bencheeorg/statistex","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"e9dd90fa961b6af9480d9ea8a32f4c089917c6d2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencheeorg%2Fstatistex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencheeorg%2Fstatistex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencheeorg%2Fstatistex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencheeorg%2Fstatistex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bencheeorg","download_url":"https://codeload.github.com/bencheeorg/statistex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406085,"owners_count":20933803,"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":[],"created_at":"2024-11-18T05:23:32.429Z","updated_at":"2025-04-05T22:05:21.342Z","avatar_url":"https://github.com/bencheeorg.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Statistex [![Hex Version](https://img.shields.io/hexpm/v/statistex.svg)](https://hex.pm/packages/statistex) [![docs](https://img.shields.io/badge/docs-hexpm-blue.svg)](https://hexdocs.pm/statistex/) [![CI](https://github.com/bencheeorg/statistex/actions/workflows/main.yml/badge.svg)](https://github.com/bencheeorg/statistex/actions/workflows/main.yml) [![Coverage Status](https://coveralls.io/repos/github/bencheeorg/statistex/badge.svg?branch=main)](https://coveralls.io/github/bencheeorg/statistex?branch=main)\n\nStatistex helps you do common statistics calculations and to explore a data set. It focusses on two things:\n\n* providing you a `statistics/2` function that just **computes all statistics it knows for a data set**, reusing previously made calculations to not compute something again (for instance standard deviation needs the average, so it first computes the average and then passes it on): `Statistex.statistics(samples)`\n* gives you the opportunity to **pass known values to functions** so that it doesn't need to compute more than it absolutely needs to: `Statistex.standard_deviation(samples, average: computed_average)`\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:statistex, \"~\u003e 1.0\"}\n  ]\nend\n```\n\nSupported elixir versions are 1.6+ (together with their respective erlang OTP versions aka 19+).\nTests are only running against elixir 1.12+ though, as some dependencies aren't compatible with versions that old.\nBut also, most people probably don't care about them.\n\n## Usage\n\nCheck out the [documentation of the main Statistex module](https://hexdocs.pm/statistex/Statistex.html) but here is a small overview:\n\n```elixir\niex\u003e samples = [1, 3.0, 2.35, 11.0, 1.37, 35, 5.5, 10, 0, 2.35]\n# calculate all available statistics at once, efficiently reusing already calculated values\niex\u003e Statistex.statistics(samples)\n%Statistex{\n  average: 7.156999999999999,\n  frequency_distribution: %{\n    0 =\u003e 1,\n    1 =\u003e 1,\n    10 =\u003e 1,\n    35 =\u003e 1,\n    1.37 =\u003e 1,\n    2.35 =\u003e 2,\n    3.0 =\u003e 1,\n    5.5 =\u003e 1,\n    11.0 =\u003e 1\n  },\n  maximum: 35,\n  median: 2.675,\n  minimum: 0,\n  mode: 2.35,\n  percentiles: %{50 =\u003e 2.675},\n  sample_size: 10,\n  standard_deviation: 10.47189577445799,\n  standard_deviation_ratio: 1.46316833512058,\n  total: 71.57,\n  variance: 109.6606011111111\n}\n# or just calculate the value you need\niex\u003e Statistex.average(samples)\n7.156999999999999\n# Calculate the value you want reusing values you already know\n# (check the docs for what functions accepts what options)\niex\u003e Statistex.average(samples, sample_size: 10)\n7.156999999999999\n# Most Statistex functions raise given an empty list as most functions don't make sense then.\n# It is recommended that you manually handle the empty list case should that occur as your\n# output is likely also very different from when you have statistics.\niex\u003e Statistex.statistics([])\n** (ArgumentError) Passed an empty list ([]) to calculate statistics from, please pass a list containing at least one number.\n```\n\n## Supported Statistics\n\nFor an up to date overview with explanations please check out the [documentation of the Statistex module](https://hexdocs.pm/statistex/Statistex.html).\n\nStatistics currently supported:\n\n* average\n* frequency_distribution\n* maximum\n* median\n* minimum\n* mode\n* percentiles\n* sample_size\n* standard_deviation\n* standard_deviation_ratio\n* total\n* variance\n\n## Alternatives\n\nIn elixir there are 2 notable other libraries that I'm aware of: [statistics](https://github.com/msharp/elixir-statistics) and [Numerix](https://github.com/safwank/Numerix).\n\nBoth include more functions than just for statistics: general math and more (drawing of random values for instance). They also have more statistics related functions as of this writing. So if you'e looking for something, that Statistex doesn't provide (yet) these are some of the first places I'd look.\n\nWhy would you still want to use Statistex?\n\n* `statistics/2` is really nice when you're just exploring a data set or just want to have _everything_ at once\n* when calling `statistics/2` Statistex **reuses previously calculated values** (_average_ for _standard_deviation_ for instance, or a sorted list of samples for some calculations) which makes for more efficient calculations. Statistex **extends that capability to you** so that you can pass pre calculated values as optional arguments.\n* small and focussed on just statistics :)\n\nWe're naturally also looking to add more statistical functions as we go along, and pull requests are very welcome :)\n\n## Performance\n\nStatistex is written in pure elixir. C-extensions and friends would surely be faster. The goal of statistex is to be as fast possible in pure elixir while providing correct results. Hence, the focus on reusing previously calculated values and providing that ability to users.\n\n## History\n\nStatistex was extracted from [benchee](https://github.com/bencheeorg/benchee) and as such it powers benchees statistics calculations. Its great ancestor (if you will) was first conceived in [this commit](https://github.com/bencheeorg/benchee/commit/60fba66f927e0da20c4d16379dbf7274f77e63b5#diff-9d500e7ee9bd945a93b7172cca013d64).\n\n## Contributing\n\nContributions to benchee are **very welcome**! Bug reports, documentation, spelling corrections, new statistics, bugfixes... all of those (and probably more) are much appreciated contributions!\n\nPlease respect the [Code of Conduct](//github.com/bencheeorg/statistex/blob/master/CODE_OF_CONDUCT.md).\n\nYou can also look directly at the [open issues](https://github.com/bencheeorg/statistex/issues).\n\nA couple of (hopefully) helpful points:\n\n* Feel free to ask for help and guidance on an issue/PR (\"How can I implement this?\", \"How could I test this?\", ...)\n* Feel free to open early/not yet complete pull requests to get some early feedback\n* When in doubt if something is a good idea open an issue first to discuss it\n* In case I don't respond feel free to bump the issue/PR or ping me in other places\n\n## Development\n\n* `mix deps.get` to install dependencies\n* `mix test` to run tests\n* `mix dialyzer` to run dialyzer for type checking, might take a while on the first invocation (try building plts first with `mix dialyzer --plt`)\n* `mix credo --strict` to find code style problems\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencheeorg%2Fstatistex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbencheeorg%2Fstatistex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencheeorg%2Fstatistex/lists"}