# tf.random.Algorithm

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/stateless_random_ops.py#L52-L76) |

A random-number-generation (RNG) algorithm.

#### View aliases


**Main aliases**

[`tf.random.experimental.Algorithm`](https://www.tensorflow.org/api_docs/python/tf/random/Algorithm)
**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.random.Algorithm`](https://www.tensorflow.org/api_docs/python/tf/random/Algorithm), [`tf.compat.v1.random.experimental.Algorithm`](https://www.tensorflow.org/api_docs/python/tf/random/Algorithm)

<br />

Many random-number generators (e.g. the `alg` argument of
[`tf.random.Generator`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/random/Generator) and [`tf.random.stateless_uniform`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/random/stateless_uniform)) in TF allow
you to choose the algorithm used to generate the (pseudo-)random
numbers. You can set the algorithm to be one of the options below.

- `PHILOX`: The Philox algorithm introduced in the paper ["Parallel
  Random Numbers: As Easy as 1, 2,
  3"](https://www.thesalmons.org/john/random123/papers/random123sc11.pdf).
- `THREEFRY`: The ThreeFry algorithm introduced in the paper ["Parallel Random Numbers: As Easy as 1, 2,
  3"](https://www.thesalmons.org/john/random123/papers/random123sc11.pdf).
- `AUTO_SELECT`: Allow TF to automatically select the algorithm depending on the accelerator device. Note that with this option, running the same TF program on different devices may result in different random numbers. Also note that TF may select an algorithm that is different from `PHILOX` and `THREEFRY`.

<br />

<br />

<br />

| ## Class Variables ||
|---|---|
| AUTO_SELECT | `<Algorithm.AUTO_SELECT: 3>` |
| PHILOX | `<Algorithm.PHILOX: 1>` |
| THREEFRY | `<Algorithm.THREEFRY: 2>` |

<br />