<!--
{
  "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:shape:batchSize:)-5a2p2",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:So21BNNSNDArrayDescriptora10AccelerateE8allocate8randomIn5shape9batchSizeABSNyxG_AC4BNNSO5ShapeOSitAC10BNNSScalarRzs17FixedWidthIntegerRzlFZ"
  },
  "title" : "allocate(randomIn:shape:batchSize:)"
}
-->

# allocate(randomIn:shape:batchSize:)

Returns a new n-dimensional array descriptor that’s initialized with random values within the specified range.

```
static func allocate<Scalar>(randomIn range: ClosedRange<Scalar>, shape: BNNS.Shape, batchSize: Int = 1) -> BNNSNDArrayDescriptor where Scalar : BNNSScalar, Scalar : FixedWidthInteger
```

## Parameters

`range`

The range in which to create 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)