randn

Functions
randn
Complete List of ArrayFire FunctionsComplete List of ArrayFire Functions ArrayFire Functions by Category » Functions to create and modify Arrays » | Functions to create arrays. » | Random Number Generation

Create a random array sampled from normal distribution. More...

## Functions
AFAPI array | randn (const dim4 &dims, const dtype ty, randomEngine &r)
AFAPI array | randn (const dim4 &dims, const dtype ty=f32)
AFAPI array | randn (const dim_t d0, const dtype ty=f32)
AFAPI array | randn (const dim_t d0, const dim_t d1, const dtype ty=f32)
AFAPI array | randn (const dim_t d0, const dim_t d1, const dim_t d2, const dtype ty=f32)
AFAPI array | randn (const dim_t d0, const dim_t d1, const dim_t d2, const dim_t d3, const dtype ty=f32)
AFAPI af_err | af_random_normal (af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type, af_random_engine engine)
| C Interface for creating an array of normal numbers using a random engine. More...
AFAPI af_err | af_randn (af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)

## Detailed Description

Create a random array sampled from normal distribution.

The type of engine used is defined by af::randomEngine.

The data is centered around 0.

## Function Documentation

## ◆ af_randn()

AFAPI af_err af_randn | ( | af_array * | out,
|  | const unsigned | ndims,
|  | const dim_t *const | dims,
|  | const af_dtype | type
| ) |  |

Parameters

  [out] | out | The generated array
  [in] | ndims | Size of dimension array `dims`
  [in] | dims | The array containing sizes of the dimension
  [in] | type | The type of array to generate

## ◆ af_random_normal()

AFAPI af_err af_random_normal | ( | af_array * | out,
|  | const unsigned | ndims,
|  | const dim_t *const | dims,
|  | const af_dtype | type,
|  | af_random_engine | engine
| ) |  |

C Interface for creating an array of normal numbers using a random engine.

Parameters

  [out] | out | The pointer to the returned object.
  [in] | ndims | The number of dimensions read from the `dims` parameter
  [in] | dims | A C pointer with `ndims` elements. Each value represents the size of that dimension
  [in] | type | The type of the af_array object
  [in] | engine | The random engine object

Returns
  AF_SUCCESS if the execution completes properly

## ◆ randn() [1/6]

AFAPI array af::randn | ( | const dim4 & | dims,
|  | const dtype | ty,
|  | randomEngine & | r
| ) |  |

Parameters

  [in] | dims | The dimensions of the array to be generated
  [in] | ty | The type of the array
  [in] | r | The random engine object

Returns
  array of size `dims`

Examples:
  financial/heston_model.cpp, financial/monte_carlo_options.cpp, graphics/gravity_sim.cpp, and graphics/plot2d.cpp.

## ◆ randn() [2/6]

AFAPI array af::randn | ( | const dim4 & | dims,
|  | const dtype | ty = `f32`
| ) |  |

Parameters

  [in] | dims | The dimensions of the array to be generated
  [in] | ty | The type of the array

Returns
  array of size `dims`

## ◆ randn() [3/6]

AFAPI array af::randn | ( | const dim_t | d0,
|  | const dtype | ty = `f32`
| ) |  |

Parameters

  [in] | d0 | The size of the first dimension
  [in] | ty | The type of the array

Returns
  array of size `d0`

## ◆ randn() [4/6]

AFAPI array af::randn | ( | const dim_t | d0,
|  | const dim_t | d1,
|  | const dtype | ty = `f32`
| ) |  |

Parameters

  [in] | d0 | The size of the first dimension
  [in] | d1 | The size of the second dimension
  [in] | ty | The type of the array

Returns
  array of size `d0` x `d1`

## ◆ randn() [5/6]

AFAPI array af::randn | ( | const dim_t | d0,
|  | const dim_t | d1,
|  | const dim_t | d2,
|  | const dtype | ty = `f32`
| ) |  |

Parameters

  [in] | d0 | The size of the first dimension
  [in] | d1 | The size of the second dimension
  [in] | d2 | The size of the third dimension
  [in] | ty | The type of the array

Returns
  array of size `d0` x `d1` x `d2`

## ◆ randn() [6/6]

AFAPI array af::randn | ( | const dim_t | d0,
|  | const dim_t | d1,
|  | const dim_t | d2,
|  | const dim_t | d3,
|  | const dtype | ty = `f32`
| ) |  |

Parameters

  [in] | d0 | The size of the first dimension
  [in] | d1 | The size of the second dimension
  [in] | d2 | The size of the third dimension
  [in] | d3 | The size of the fourth dimension
  [in] | ty | The type of the array

Returns
  array of size `d0` x `d1` x `d2` x `d3`