{"id":15050625,"url":"https://github.com/tmccarthy/probability","last_synced_at":"2026-02-19T16:04:40.138Z","repository":{"id":57715042,"uuid":"201755016","full_name":"tmccarthy/probability","owner":"tmccarthy","description":"A probability monad in Scala","archived":false,"fork":false,"pushed_at":"2024-06-01T10:21:49.000Z","size":234,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-14T17:15:09.503Z","etag":null,"topics":["cats","probability","probability-distribution","probability-measure","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmccarthy.png","metadata":{"files":{"readme":"README.md","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,"publiccode":null,"codemeta":null}},"created_at":"2019-08-11T11:19:02.000Z","updated_at":"2024-12-09T19:54:16.000Z","dependencies_parsed_at":"2025-03-28T09:40:38.973Z","dependency_job_id":"3890a897-87f6-452d-9fdc-a5444ef8aa17","html_url":"https://github.com/tmccarthy/probability","commit_stats":null,"previous_names":["tmccarthy/probability-measure"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tmccarthy/probability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fprobability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fprobability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fprobability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fprobability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmccarthy","download_url":"https://codeload.github.com/tmccarthy/probability/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmccarthy%2Fprobability/sbom","scorecard":{"id":889770,"data":{"date":"2025-08-11","repo":{"name":"github.com/tmccarthy/probability","commit":"2c545100ee5846609b5fb121fc8a5d68355b0ffb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/clean.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:79: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:102: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:113: update your workflow using https://app.stepsecurity.io/secureworkflow/tmccarthy/probability/ci.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T11:20:45.155Z","repository_id":57715042,"created_at":"2025-08-24T11:20:45.155Z","updated_at":"2025-08-24T11:20:45.155Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29621903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cats","probability","probability-distribution","probability-measure","scala"],"created_at":"2024-09-24T21:28:11.414Z","updated_at":"2026-02-19T16:04:35.127Z","avatar_url":"https://github.com/tmccarthy.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Probability\n\n[![CircleCI](https://circleci.com/gh/tmccarthy/probability.svg?style=svg)](https://circleci.com/gh/tmccarthy/probability)\n[![Maven Central](https://img.shields.io/maven-central/v/au.id.tmm.probability/probability-core_2.13.svg)](https://repo.maven.apache.org/maven2/au/id/tmm/probability/probability-core_2.13/)\n\nA set of Scala classes for representing probabilities, probability distributions and probability measures in Scala,\nalong with instances for [Cats](https://github.com/typelevel/cats) and [Circe](https://github.com/circe/circe).\n\n```scala\nval probabilityVersion = \"0.0.4\"\n\nlibraryDependencies += \"au.id.tmm.probability\" %% \"probability-measure-core\"  % probabilityVersion\nlibraryDependencies += \"au.id.tmm.probability\" %% \"probability-measure-cats\"  % probabilityVersion\nlibraryDependencies += \"au.id.tmm.probability\" %% \"probability-measure-circe\" % probabilityVersion\nlibraryDependencies += \"au.id.tmm.probability\" %% \"probability-distribution-core\"  % probabilityVersion\n```\n\n## `ProbabilityMeasure`\n\nA `ProbabilityMeasure[A]` is a data structure that describes the probability of some set of values\nof type `A`, with the requirement that the probabilities must sum to 1. `ProbabilityMeasure`\ninstances can be chained together using `flatMap`. This allows us to compute the probability of some\nset of final outcomes given the probability of their constituent parts.\n\nConsider this example of a fair die, and a loaded die which rolls 6 half of the time:\n\n```scala\nval diceRollProbability: ProbabilityMeasure[Int] = ProbabilityMeasure.evenly(1, 2, 3, 4, 5, 6)\n\nval loadedDiceRollProbability: ProbabilityMeasure[Int] =\n  ProbabilityMeasure(\n    1 -\u003e Rational(1, 10),\n    2 -\u003e Rational(1, 10),\n    3 -\u003e Rational(1, 10),\n    4 -\u003e Rational(1, 10),\n    5 -\u003e Rational(1, 10),\n    6 -\u003e Rational(5, 10),\n  ).getOrElse(throw new AssertionError)\n\nval probabilitiesWithLoadedDice =\n  for {\n    dice1 \u003c- diceRollProbability\n    dice2 \u003c- loadedDiceRollProbability\n  } yield dice1 + dice2\n\n// result:\n//   ProbabilityMeasure(\n//     2  -\u003e Rational(1, 60),\n//     3  -\u003e Rational(1, 30),\n//     4  -\u003e Rational(1, 20),\n//     5  -\u003e Rational(1, 15),\n//     6  -\u003e Rational(1, 12),\n//     7  -\u003e Rational(1, 6),\n//     8  -\u003e Rational(3, 20),\n//     9  -\u003e Rational(2, 15),\n//     10 -\u003e Rational(7, 60),\n//     11 -\u003e Rational(1, 10),\n//     12 -\u003e Rational(1, 12),\n//   )\n```\n\nNote that we use the [`spire.math.Rational`](https://typelevel.org/spire/api/spire/math/Rational.html)\nclass from the [Spire](https://github.com/typelevel/spire) library to ensure that we always compute\nthe exact probability, without any floating-point errors.\n\n### Why is this useful?\n\nThese classes were originally part of [`countstv`](https://github.com/tmccarthy/countstv), which\nperforms election counts according to the [single transferable vote](https://en.wikipedia.org/wiki/Single_transferable_vote)\n(STV) algorithm. In an STV election count, ballots are allocated according to voters' preferences.\nAs candidates are marked as \"elected\" or \"excluded\", ballots are allocated to the next preferences\nas expressed by the voters. If there is ever a tie, a coin toss is used to determine who is elected\nor excluded first.\n\nIn cases where a coin toss decides the order in which candidates are elected or excluded, the rest\nof the election count looks entirely different in either case. However, the vast majority of the\ntime this makes no difference to who is finally elected. `ProbabilityMeasure` makes it easy to\nrun the election count for both of the coin toss outcomes, keeping track of the differences while\nalso easily identifying that the result is the same.\n\n### Cats and Circe instances\n\n`ProbabilityMeasure` is a monad, and the `probability-measure-cats` dependency provides the\nappropriate Cats typeclasses.\n\nThe `probability-measure-circe` project provides encoders and decoders for Circe.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccarthy%2Fprobability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmccarthy%2Fprobability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmccarthy%2Fprobability/lists"}