halton
Version:
Generate n points of the Halton sequence in n-dimensions.
85 lines (57 loc) • 3.77 kB
Markdown
# halton
[](https://www.npmjs.com/package/halton)
[](https://www.npmjs.com/package/halton)
[](https://bundlephobia.com/package/halton)
[](https://github.com/dmnsgn/halton/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/halton/blob/main/LICENSE.md)
Generate n points of the Halton sequence in n-dimensions.
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)

## Installation
```bash
npm install halton
```
## Usage
```js
import halton from "halton";
const points = halton(pointsCount);
// =>
// 0: [0, 0]
// 1: [0.5, 0.3333333333333333]
// 2: [0.25, 0.6666666666666666]
// 3: [0.75, 0.1111111111111111]
```
## API
<!-- api-start -->
<a name="module_halton"></a>
## halton
- [halton](#module_halton)
- [.haltonSequence(index, base)](#module_halton.haltonSequence) ⇒ <code>number</code>
- [.default(count, [bases])](#module_halton.default) ⇒ <code>Array.<Array.<number>></code>
<a name="module_halton.haltonSequence"></a>
### halton.haltonSequence(index, base) ⇒ <code>number</code>
The Halton sequence algorithm.
**Kind**: static method of [<code>halton</code>](#module_halton)
**See**: [Wikipedia Halton_sequence](https://en.wikipedia.org/wiki/Halton_sequence#Implementation)
| Param | Type | Description |
| ----- | ------------------- | ------------------------------------ |
| index | <code>number</code> | Index in the sequence. |
| base | <code>number</code> | An integer, preferably prime number. |
<a name="module_halton.default"></a>
### halton.default(count, [bases]) ⇒ <code>Array.<Array.<number>></code>
Generate n points of the Halton sequence in n-dimensions.
The "bases" parameter defines how many dimensions.
**Kind**: static method of [<code>halton</code>](#module_halton)
| Param | Type | Default | Description |
| ------- | --------------------------------- | ------------------- | ------------------------------------------------------------------------------------ |
| count | <code>number</code> | | Number of points in the sequence to generate. |
| [bases] | <code>Array.<number></code> | <code>[2, 3]</code> | The bases for the Van der Corput operation. Best results with small coprime numbers. |
<!-- api-end -->
## License
MIT. See [license file](https://github.com/dmnsgn/halton/blob/main/LICENSE.md).