---
title: "randomSplit(by:using:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/randomsplit(by:using:)-9i5e5"
---

# randomSplit(by:using:)

Generates two AnnotatedFeatures by randomly splitting the elements of the sequence, at the same proportion within each unique Annotation.

## Declaration

```swift
func randomSplit<Feature, Annotation, Generator>(by proportion: Double, using generator: inout Generator) -> ([AnnotatedFeature<Feature, Annotation>], [AnnotatedFeature<Feature, Annotation>]) where Annotation : Hashable, Generator : RandomNumberGenerator, Self.Element == AnnotatedFeature<Feature, Annotation>
```

## Parameters

- `proportion`: A proportion in the range [0.0, 1.0].
- `generator`: A random-number generator.

## Return Value

Return Value A tuple of arrays.
