Class

# Random

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to generate <span class="title-ref">Random</span> numbers.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                | Type                             | Read-Only | Shared |
|---------------------|----------------------------------|-----------|--------|
| `Seed<random.seed>` | `Double</api/data_types/double>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                  | Parameters                                                                             | Returns                            | Shared |
|---------------------------------------|----------------------------------------------------------------------------------------|------------------------------------|--------|
| `Gaussian<random.gaussian>`           |                                                                                        | `Double</api/data_types/double>`   |        |
| `InRange<random.inrange>`             | minR As `Integer</api/data_types/integer>`, maxR As `Integer</api/data_types/integer>` | `Integer</api/data_types/integer>` |        |
| `LessThan<random.lessthan>`           | Range As `Integer</api/data_types/integer>`                                            | `Integer</api/data_types/integer>` |        |
| `Number<random.number>`               |                                                                                        | `Double</api/data_types/double>`   |        |
| `RandomizeSeed<random.randomizeseed>` |                                                                                        |                                    |        |
| `UUID<random.uuid>`                   | useHyphens As `Boolean</api/data_types/boolean>` = `True</api/language/true>`          | `String</api/data_types/string>`   |        |

## Property descriptions

<div id="random.seed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.Seed

**Seed** As `Double</api/data_types/double>`

> Gets or sets the seed used by the <span class="title-ref">Random</span> number generator.
>
> Use the Seed to initialize the pseudo-<span class="title-ref">Random</span> number generator's algorithm so that you can always get the same stream of numbers from the same seed. However, this is not an endian-independent operation. If you set the seed on a big-endian machine to the same value that you used on a little-endian machine, you will get two different streams of pseudo-<span class="title-ref">Random</span> numbers.
>
> This example initializes the seed for to global <span class="title-ref">Random</span> to a new value:
>
> ``` xojo
> System.Random.Seed = 17327
> ```

## Method descriptions

<div id="random.gaussian">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.Gaussian

**Gaussian** As `Double</api/data_types/double>`

> Returns a <span class="title-ref">Random</span> number drawn from a Gaussian (a.k.a. Normal) distribution rather than from a uniform distribution.
>
> The Gaussian distribution has a mean of zero and a standard deviation of 1.
>
> This example generates a <span class="title-ref">Random</span> number from a Normal distribution.
>
> ``` xojo
> Var d As Double = System.Random.Gaussian
> ```

<div id="random.inrange">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.InRange

**InRange**(minRange As `Integer</api/data_types/integer>`, maxRange As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> Returns a <span class="title-ref">Random</span> number as an `Integer</api/data_types/integer>` in the range from *minRange* to *maxRange*, inclusive.
>
> The following example generates a <span class="title-ref">Random</span> integer in the range from 0 to 1,000.
>
> ``` xojo
> Label1.Text = System.Random.InRange(0, 1000).ToString
> ```

<div id="random.lessthan">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.LessThan

**LessThan**(range As `Integer</api/data_types/integer>`) As `Integer</api/data_types/integer>`

> Returns a <span class="title-ref">Random</span> number as an `Integer</api/data_types/integer>` in the range greater than or equal to 0 and less than *range* (value \>= 0 And value \< *range*).
>
> This example generates a <span class="title-ref">Random</span> integer from 0 to 99:
>
> ``` xojo
> Label1.Text = System.Random.LessThan(100).ToString
> ```

<div id="random.number">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.Number

**Number** As `Double</api/data_types/double>`

> Returns a <span class="title-ref">Random</span> number as a `Double</api/data_types/double>` in the range greater than or equal to 0 and less than 1.
>
> This example generates a <span class="title-ref">Random</span> number in the interval \>= 0 and \< 1.
>
> ``` xojo
> Var d As Double
> d = System.Random.Number
> Label1.Text = d.ToString
> ```

<div id="random.randomizeseed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.RandomizeSeed

**RandomizeSeed**

> Changes the <span class="title-ref">Random</span> object's seed value to start a new sequence of pseudo <span class="title-ref">Random</span> numbers.
>
> You might use this when you want to re-initialize a <span class="title-ref">Random</span> object but don't want to create an entirely new one. If you are creating multiple sequences, this helps to make the sequences unrelated to one another.
>
> This example assumes that the method created a sequence from an earlier seed.
>
> ``` xojo
> ' create other sequences from another seed here..
> System.Random.RandomizeSeed
> Label1.Text = System.Random.Gaussian.ToString
> ```

<div id="random.uuid">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Random.UUID

**UUID**(useHyphens As `Boolean</api/data_types/boolean>` = `True</api/language/true>`) As `String</api/data_types/string>`

> Returns a <span class="title-ref">random</span> version 4 UUID as a `String</api/data_types/string>`.
>
> ``` xojo
> Var result, result2 As String
>
> result = System.Random.UUID ' e.g. C9DBB257-5D6A-46D6-B57C-0C18AF2FDF48
> result2 = System.Random.UUID(False) ' e.g. C9DBB2575D6A46D6B57C0C18AF2FDF48
> ```

## Notes

Use `System.Random<system.random>` to create an instance of this class.

The <span class="title-ref">Random</span> class supersedes the `Rnd</api/math/rnd>` function. It performs the same functions and more.

A custom <span class="title-ref">Random</span> number generator is used. For best results, you should only create a single instance of <span class="title-ref">Random</span> per app.

The <span class="title-ref">Random</span> class's seed is used to initialize the pseudo-<span class="title-ref">Random</span> number generator's algorithm so that you can always get the same stream of numbers from the same seed. However, this is not an endian-independent operation. If you set the seed on a big-endian machine to the same value that you used on a little-endian machine, you will get two different streams of pseudo-<span class="title-ref">Random</span> numbers.

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Rnd</api/math/rnd>`, `System.Random<system.random>` functions

</div>
