Exercise

# Drawing from conditional distribution

Simply calling `predict()`

on a model will always return the same value for the same values of the predictors. This results in a small variability in imputed data. In order to increase it, so that the imputation replicates the variability from the original data, we can draw from the conditional distribution. What this means is that instead of always predicting 1 whenever the model outputs a probability larger than 0.5, we can draw the prediction from a binomial distribution described by the probability returned by the model.

You will work on the code you have written in the previous exercise. The following line was removed:

```
preds <- ifelse(preds >= 0.5, 1, 0)
```

Your task is to fill its place with drawing from a binomial distribution. That's just one line of code!

Instructions

**100 XP**

- Overwrite
`preds`

by sampling from a binomial distribution. - Pass the length of
`preds`

as the first argument. - Set size to 1.
- Set
`prob`

to the probabilities returned by the model.