---
title: "BNNSRandomFillNormalFloat(_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/bnnsrandomfillnormalfloat(_:_:_:_:)"
---

# BNNSRandomFillNormalFloat(_:_:_:_:)

Fills the specified tensor with random floating-point values mapped to a normal distribution.

## Declaration

```swift
func BNNSRandomFillNormalFloat(_ generator: BNNSRandomGenerator?, _ desc: UnsafeMutablePointer<BNNSNDArrayDescriptor>, _ mean: Float, _ stddev: Float) -> Int32
```

## Parameters

- `generator`: The random number generator.
- `desc`: The descriptor of the destination.
- `mean`: The mean of the distribution.
- `stddev`: The standard deviation of the distribution.

## Discussion

Discussion Use this function to fill an array descriptor with random values mapped to a normal distribution. If you use the same generator on multiple threads, note that this function serializes the generator through an internal lock. To eliminate this contention, use different generators for each thread. The following code populates a descriptor with random floating-point values: let width = 1024 let height = 1024

var descriptor = BNNSNDArrayDescriptor.allocateUninitialized(     scalarType: Float.self,     shape: .matrixRowMajor(width,                            height))

let randomNumberGenerator = BNNSCreateRandomGenerator(     BNNSRandomGeneratorMethodAES_CTR,     nil)

BNNSRandomFillNormalFloat(randomNumberGenerator,                           &descriptor,                           0,                           2) The graph below shows the distribution of values in descriptor.

## See Also

### Random number generation

- [BNNS.RandomGenerator](accelerate/bnns/randomgenerator.md)
- [BNNSCreateRandomGenerator(_:_:)](accelerate/bnnscreaterandomgenerator(_:_:).md)
- [BNNSCreateRandomGeneratorWithSeed(_:_:_:)](accelerate/bnnscreaterandomgeneratorwithseed(_:_:_:).md)
- [BNNSRandomGeneratorMethod](accelerate/bnnsrandomgeneratormethod.md)
- [BNNSRandomGenerator](accelerate/bnnsrandomgenerator.md)
- [BNNSRandomFillUniformInt(_:_:_:_:)](accelerate/bnnsrandomfilluniformint(_:_:_:_:).md)
- [BNNSRandomFillUniformFloat(_:_:_:_:)](accelerate/bnnsrandomfilluniformfloat(_:_:_:_:).md)
- [BNNSRandomFillCategoricalFloat(_:_:_:_:)](accelerate/bnnsrandomfillcategoricalfloat(_:_:_:_:).md)
- [BNNSRandomGeneratorStateSize(_:)](accelerate/bnnsrandomgeneratorstatesize(_:).md)
- [BNNSRandomGeneratorGetState(_:_:_:)](accelerate/bnnsrandomgeneratorgetstate(_:_:_:).md)
- [BNNSRandomGeneratorSetState(_:_:_:)](accelerate/bnnsrandomgeneratorsetstate(_:_:_:).md)
- [BNNSDestroyRandomGenerator(_:)](accelerate/bnnsdestroyrandomgenerator(_:).md)
