<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNS/RandomGenerator",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate4BNNSO15RandomGeneratorC"
  },
  "title" : "BNNS.RandomGenerator"
}
-->

# BNNS.RandomGenerator

A random number generator.

```
class RandomGenerator
```

## Topics

### Creating a Random Number Generator

[`init?(method: BNNS.RandomGeneratorMethod, seed: UInt64?, filterParameters: BNNSFilterParameters?)`](/documentation/Accelerate/BNNS/RandomGenerator/init(method:seed:filterParameters:))

Returns a new random number generator.

[`enum RandomGeneratorMethod`](/documentation/Accelerate/BNNS/RandomGeneratorMethod)

Constants that describe random number generation methods.

### Saving and Restoring a Randon Generator’s State

[`var state: BNNS.RandomGeneratorState`](/documentation/Accelerate/BNNS/RandomGenerator/state)

The state of the random number generator.

[`class RandomGeneratorState`](/documentation/Accelerate/BNNS/RandomGeneratorState)

An opaque object that contains the state of a random number generator.

## See Also

[`static func allocate<Scalar, Generator>(randomIn: ClosedRange<Scalar>, using: inout Generator, shape: BNNS.Shape, batchSize: Int) -> BNNSNDArrayDescriptor`](/documentation/Accelerate/BNNSNDArrayDescriptor/allocate(randomIn:using:shape:batchSize:)-3w6ig)

Returns a new array descriptor that’s initialized with random values within the specified range, using the given generator as a source for randomness.

[`static func allocate<Scalar, Generator>(randomIn: ClosedRange<Scalar>, using: inout Generator, shape: BNNS.Shape, batchSize: Int) -> BNNSNDArrayDescriptor`](/documentation/Accelerate/BNNSNDArrayDescriptor/allocate(randomIn:using:shape:batchSize:)-5kbi8)

Returns a new array descriptor that’s initialized with random values within the specified range, using the given generator as a source for randomness.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)