<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSNDArrayDescriptor/allocate(randomIn:using:shape:batchSize:)-3w6ig",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:So21BNNSNDArrayDescriptora10AccelerateE8allocate8randomIn5using5shape9batchSizeABSNyxG_q_zAC4BNNSO5ShapeOSitAC10BNNSScalarRzs17FixedWidthIntegerRzSGR_r0_lFZ"
  },
  "title" : "allocate(randomIn:using:shape:batchSize:)"
}
-->

# allocate(randomIn:using:shape:batchSize:)

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 range: ClosedRange<Scalar>, using generator: inout Generator, shape: BNNS.Shape, batchSize: Int = 1) -> BNNSNDArrayDescriptor where Scalar : BNNSScalar, Scalar : FixedWidthInteger, Generator : RandomNumberGenerator
```

## Parameters

`range`

The range in which to create random values.

`generator`

The random number generator to use when creating the new random values.

`shape`

The shape of n-dimensional array descriptor.

`batchSize`

The number of batches of data.

---

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)