https://github.com/ordo-one/distributions
Performant implementations of statistical distributions in pure Swift
https://github.com/ordo-one/distributions
autosync statistics
Last synced: 4 days ago
JSON representation
Performant implementations of statistical distributions in pure Swift
- Host: GitHub
- URL: https://github.com/ordo-one/distributions
- Owner: ordo-one
- License: apache-2.0
- Created: 2025-06-27T23:51:34.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2026-05-19T10:27:13.000Z (15 days ago)
- Last Synced: 2026-05-19T13:20:05.723Z (15 days ago)
- Topics: autosync, statistics
- Language: Swift
- Homepage:
- Size: 211 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Notice: NOTICE
Awesome Lists containing this project
README
๐ ย **distributions** ย ๐
a portable, Foundation-free library for working with statistical distributions in Swift, with a focus on efficient sampling and random number generation
[documentation](https://swiftinit.org/docs/package-distributions) ยท
[license](LICENSE)
## Requirements
The package-distributions library requires Swift 6.1 or later.
| Platform | Status |
| -------- | ------ |
| ๐ฌ Documentation | [](https://github.com/ordo-one/package-distributions/actions/workflows/Documentation.yml) |
| ๐ง Linux | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
| ๐ Darwin | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
| ๐ Darwin (iOS) | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
| ๐ Darwin (tvOS) | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
| ๐ Darwin (visionOS) | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
| ๐ Darwin (watchOS) | [](https://github.com/ordo-one/package-distributions/actions/workflows/Tests.yml) |
[Check deployment minimums](https://swiftinit.org/docs/package-distributions#ss:platform-requirements)
## Examples
```swift
import Random
var random: PseudoRandom = .init(seed: 13)
let binomial: (Int64, Int64, Int64, Int64) = (
Binomial[10, 0.2].sample(using: &random.generator),
Binomial[10, 0.2].sample(using: &random.generator),
Binomial[10, 0.2].sample(using: &random.generator),
Binomial[10, 0.2].sample(using: &random.generator),
)
// Generated binomial samples: (1, 4, 2, 4)
let normal: (Double, Double, Double, Double) = (
Normal[0, 1].sample(using: &random.generator),
Normal[0, 1].sample(using: &random.generator),
Normal[0, 1].sample(using: &random.generator),
Normal[0, 1].sample(using: &random.generator),
)
// Generated normal samples: (1.031, 1.201, -1.607, -0.243)
```