# ml-xsadd

> JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator

Latest version **3.0.1** (published 2024-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install ml-xsadd
pnpm add ml-xsadd
yarn add ml-xsadd
bun add ml-xsadd
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2024-10-18 |
| First published | 2015-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Michaël Zasso |
| Maintainers | stropitek, targos, lpatiny, mljs-bot |
| Keywords | xsadd, xorshift, add, pseudo, random, number, generator, machine, learning |

## Links

- npm: https://www.npmjs.com/package/ml-xsadd
- Repository: https://github.com/mljs/xsadd
- Homepage: https://github.com/mljs/xsadd#readme
- Issues: https://github.com/mljs/xsadd/issues
- npm.io page: https://npm.io/package/ml-xsadd

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2024-10-18
- 3.0.0 — 2024-10-17
- 2.0.0 — 2018-08-11
- 1.0.0 — 2015-07-23

## README

# ml-xsadd

<h3 align="center">
  
  <a href="https://www.zakodium.com">
   <img src="https://www.zakodium.com/brand/zakodium-logo-white.svg" width="50" alt="Zakodium logo" />
  </a>
  
  <p>
    Maintained by <a href="https://www.zakodium.com">Zakodium</a>
  </p>
  
  [![NPM version][npm-image]][npm-url]
  [![build status][ci-image]][ci-url]
  [![npm download][download-image]][download-url]
  
</h3>

JavaScript implementation of the XORSHIFT-ADD (XSadd) pseudo random number generator.

Based on the C code from https://github.com/MersenneTwister-Lab/XSadd.

## Installation

`$ npm install ml-xsadd`

## API

```js
const { XSadd } = require("ml-xsadd");

const gen = new XSadd();
const number = gen.getFloat();
```

### new XSadd([seed])

Creates a new XSadd instance. Seed is an optional integer that defaults to `Date.now()`.

### getUint32()

Returns a 32-bit integer r (0 <= r < 2^32).

### getFloat()

Returns a floating point number r (0.0 <= r < 1.0).

### random()

Like `getFloat()` but dynamically bound to the `XSadd` instance.  
You can use this function externally, like `Math.random`:

```js
const xsadd = new XSadd();
const random = xsadd.random;
const number = random();
```

### init(seed)

Reinitialize the generator with a new seed.

## LICENSE

[MIT](./LICENSE)

[npm-image]: https://img.shields.io/npm/v/ml-xsadd.svg?style=flat-square
[npm-url]: https://npmjs.org/package/ml-xsadd
[ci-image]: https://github.com/mljs/xsadd/workflows/Node.js%20CI/badge.svg?branch=main
[ci-url]: https://github.com/mljs/xsadd/actions?query=workflow%3A%22Node.js+CI%22
[download-image]: https://img.shields.io/npm/dm/ml-xsadd.svg?style=flat-square
[download-url]: https://npmjs.org/package/ml-xsadd

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