Hi,

I am enjoying myself with the famous Birthday paradox, looking at the probability of several persons (36 in this case) having their birthday the same day. I've managed to come so far:

**# a vector for the number of days in a year**

```
yeardays <- seq(1:365)
```

**# A vector for the number of repeated samplings (100)**

```
B <- 100
```

**# A matrix with 100 columns and 36 rows from 100 repeated samplings with 36 random samples each**

```
S <- replicate(B, {
X <- sample(yeardays, 36, replace = TRUE)
})
```

**# Sum the number of duplicates in one column**

```
sum(duplicated(S[,1]))
```

Now, what I don't get is how to get the sum of duplicates for each of the 100 columns. A loop or perhaps "apply" should do it, but I just don't get the output of 100 sums I would need. Any clue would be so great! Thanks!