# @lazy-random/distributions

> 彙整 @lazy-random 系列各種亂數分佈 (Distribution) 的聚合套件 (Aggregate Package)，一次安裝即可取得常見的機率分佈與亂數工具 API

Latest version **4.0.0** (published 2026-10-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @lazy-random/distributions
pnpm add @lazy-random/distributions
yarn add @lazy-random/distributions
bun add @lazy-random/distributions
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-10-13 |
| First published | 2021-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 8 |
| Unpacked size | 58.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | aggregate, bates, distribution, distributions, exponential, lognormal, normal, poisson, probability, prng, random, rng, shuffle, stats, uniform, uuid, weighted, create-by-yarn-tool, create-by-tsdx |

## Links

- npm: https://www.npmjs.com/package/@lazy-random/distributions
- Repository: https://github.com/bluelovers/ws-random
- Homepage: https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/distributions#readme
- Issues: https://github.com/bluelovers/ws-random/issues
- npm.io page: https://npm.io/package/@lazy-random/distributions

## Dependencies (8)

- [@lazy-random/df-sum](https://npm.io/package/@lazy-random/df-sum.md) ^3.0.0
- [@lazy-random/df-uuid](https://npm.io/package/@lazy-random/df-uuid.md) ^2.0.1
- [@lazy-random/df-array](https://npm.io/package/@lazy-random/df-array.md) ^3.0.1
- [@lazy-random/df-char-id](https://npm.io/package/@lazy-random/df-char-id.md) ^2.0.1
- [@lazy-random/df-poisson](https://npm.io/package/@lazy-random/df-poisson.md) ^2.0.1
- [@lazy-random/df-uniform](https://npm.io/package/@lazy-random/df-uniform.md) ^2.0.1
- [@lazy-random/df-algorithm](https://npm.io/package/@lazy-random/df-algorithm.md) ^2.0.1
- [@lazy-random/df-item-by-weight](https://npm.io/package/@lazy-random/df-item-by-weight.md) ^2.0.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2026-10-13
- 3.0.1 — 2026-10-05
- 2.0.3 — 2023-11-20
- 2.0.2 — 2023-11-19
- 1.0.8 — 2022-10-29
- 1.0.7 — 2022-01-04
- 1.0.6 — 2022-01-03
- 1.0.5 — 2021-12-21
- 1.0.3 — 2021-12-12

## README

# @lazy-random/distributions

彙整 (Re-export) `@lazy-random` 系列各種亂數分佈 (Distribution) 的聚合套件 (Aggregate Package)，一次安裝即可取得常見的機率分佈與亂數工具 API。

本套件本身不實作演算法，僅轉出各子套件的函式，並額外提供 `Distributions` 預設匯出 (Default Export) 物件。

## 特色 (Features)

- 一個套件即可取得多種機率分佈 (Probability Distribution) API
- 同時提供具名匯出 (Named Export) 與 `Distributions` 預設匯出物件
- 各函式底層皆依賴 `IRNGLike` 介面的 `next()`，可搭配任意亂數來源 (Random Number Generator)

## 匯出一覽 (Exports)

| 分類 (Category) | 函式 (Functions) | 來源套件 (Source Package) |
| --- | --- | --- |
| 連續／離散分佈 | `dfBates` `dfBernoulli` `dfBinomial` `dfExponential` `dfGeometric` `dfIrwinHall` `dfLogNormal` `dfNormal` `dfPareto` | `@lazy-random/df-algorithm` |
| 泊松分佈 | `dfPoisson` | `@lazy-random/df-poisson` |
| 均勻分佈 | `dfUniformFloat` `dfUniformInt` `dfUniformBoolean` `dfUniformByte` `dfUniformBytes` | `@lazy-random/df-uniform` |
| 陣列操作 | `dfArrayIndex` `dfArrayIndexOne` `dfArrayShuffle` `dfArrayUnique` `dfArrayFill` | `@lazy-random/df-array` |
| 權重抽樣 | `dfItemByWeight` `dfItemByWeightUnique` | `@lazy-random/df-item-by-weight` |
| 字元識別碼 | `dfCharID` | `@lazy-random/df-char-id` |
| 固定總和 | `dfRandSumFloat` `dfRandSumInt` | `@lazy-random/df-sum` |
| UUID | `dfUuidV4` | `@lazy-random/df-uuid` |

## 安裝 (Installation)

```bash
yarn add @lazy-random/distributions
yarn-tool add @lazy-random/distributions
yt add @lazy-random/distributions
```

或使用 pnpm：

```bash
pnpm add @lazy-random/distributions
```

## 使用方式 (Usage)

### 具名匯出 (Named Export)

```ts
import { dfPoisson, dfUniformInt, dfUuidV4 } from '@lazy-random/distributions';

const poisson = dfPoisson(random, 4);
const int = dfUniformInt(random, 1, 6);
const uuid = dfUuidV4(random);

console.log(poisson());
console.log(int());
console.log(uuid());
```

### 預設匯出 (Default Export)

```ts
import Distributions from '@lazy-random/distributions';

const { dfNormal, dfArrayShuffle } = Distributions;

console.log(typeof dfNormal); // "function"
console.log(typeof dfArrayShuffle); // "function"
```

## API 文件 (API Documentation)

各函式的詳細參數與回傳值請參閱對應子套件的 README：

- [df-algorithm](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-algorithm#readme)
- [df-poisson](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-poisson#readme)
- [df-uniform](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-uniform#readme)
- [df-array](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-array#readme)
- [df-item-by-weight](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-item-by-weight#readme)
- [df-char-id](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-char-id#readme)
- [df-sum](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-sum#readme)
- [df-uuid](https://github.com/bluelovers/ws-random/tree/master/packages/@lazy-random/df-uuid#readme)

## 設定 (Configuration)

本套件無設定檔，所有函式的行為皆由各自參數控制。

## 開發 (Development)

```bash
pnpm run build
```

## 變更日誌 (Changelog)

請見 [CHANGELOG.md](./CHANGELOG.md)。

## 相關資源 (Related Resources)

- [Repository](https://github.com/bluelovers/ws-random)

---
_Source: https://npm.io/package/@lazy-random/distributions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
