# About probabilities.¶

## Default probability values¶

All pre / post processing transforms: **Compose**, **PadIfNeeded**, **CenterCrop**, **RandomCrop**, **Crop**, **RandomCropNearBBox**, **RandomSizedCrop**, **RandomResizedCrop**, **RandomSizedBBoxSafeCrop**, **CropNonEmptyMaskIfExists**, **Lambda**, **Normalize**, **ToFloat**, **FromFloat**, **ToTensor**, **LongestMaxSize** have default
probability values equal to **1**. All others are equal to **0.5**

```
from albumentations import (
RandomRotate90, IAAAdditiveGaussianNoise, GaussNoise, Compose, OneOf
)
import numpy as np
def aug(p1, p2, p3):
return Compose([
RandomRotate90(p=p2),
OneOf([
IAAAdditiveGaussianNoise(p=0.9),
GaussNoise(p=0.6),
], p=p3)
], p=p1)
image = np.ones((300, 300, 3), dtype=np.uint8)
mask = np.ones((300, 300), dtype=np.uint8)
whatever_data = "my name"
augmentation = aug(p1=0.9, p2=0.7, p3=0.3)
data = {"image": image, "mask": mask, "whatever_data": whatever_data, "additional": "hello"}
augmented = augmentation(**data)
image, mask, whatever_data, additional = augmented["image"], augmented["mask"], augmented["whatever_data"], augmented["additional"]
```

In the above augmentation pipeline, we have three types of probabilities. Combination of them is the primary factor that decides how often each of them will be applied.

p1: decides if this augmentation will be applied. The most common case isp1=1means that we always apply the transformations from above.p1=0will mean that the transformation block will be ignored.p2: every augmentation has an option to be applied with some probability.p3: decide ifOneOfwill be applied.

## OneOf Block¶

To decide which augmentation within **OneOf** block is used the following rule is applied.

1. We normalize all probabilities within a block to one. After this we pick augmentation based on the normalized probabilities. In the example aboveIAAAdditiveGaussianNoisehas probability0.9andGaussNoiseprobability0.6. After normalization, they become0.6and0.4. Which means that we decide if we should useIAAAdditiveGaussianNoisewith probability0.6andGaussNoiseotherwise. 2. If we picked to considerGaussNoisethe next step we callGaussNoisewith flagforce_apply=True.

## Example calculations¶

Thus, each augmentation in the example above will be applied with the probability:

RandomRotate90: p1 * p2IAAAdditiveGaussianNoise: p1 * p3 * (0.9 / (0.9 + 0.6))GaussianNoise: p1 * p3 * (0.6 / (0.9 + 0.6))