<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ApplyRandomly",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents13ApplyRandomlyV"
  },
  "title" : "ApplyRandomly"
}
-->

# ApplyRandomly

Randomly applies the transformer with the given probability.

```
struct ApplyRandomly<RandomTransformer> where RandomTransformer : RandomTransformer, RandomTransformer.Input == RandomTransformer.Output
```

## Topics

### Creating an augmentation

[`init<Input>(probability: Double, () -> RandomTransformer)`](/documentation/CreateMLComponents/ApplyRandomly/init(probability:_:))

Creates an apply randomly augmentation.

### Getting the probability

[`let probability: Double`](/documentation/CreateMLComponents/ApplyRandomly/probability)

The probability of applying the transformer. Default value is 0.5.

### Applying transformers

[`func applied(to: RandomTransformer.Input, generator: inout some RandomNumberGenerator, eventHandler: EventHandler?) async throws -> RandomTransformer.Output`](/documentation/CreateMLComponents/ApplyRandomly/applied(to:generator:eventHandler:))

Randomly applies a transformer on an input.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`RandomTransformer`](/documentation/CreateMLComponents/RandomTransformer)

---

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)