I'm a new starter in metropolis-hastings algorithm, having a problem in understanding its implementation of acceptance step:

```
  min{1, f(Y)/f(x)}

```

I understand when acceptance rate is larger than 1, the value is always accepted. But when the ratio is less than one, all the R code I have see is to compare with a uniform density value by

```
if(runif(1)<f(Y)/f(x))

```

Why are we supposed to compare with one uniform density value here? Is any specific reason for that?