Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

For some purpose I found myself generating and analyzing the average of the combinations of a set and when I generated the corresponding histogram I was surprised by its shape. It should be remembered that the combinations C(m, n) of a set are the number of subsets of a set of m elements taken from n in n.

The number of combinations is calculated with:

This is the very simple code to generate the combinations, calculate their mean and generate the histogram:

m <- 50 n <- 6

COMBINATIONS <- t(as.data.frame(combn(m,n)))

C_M <- apply(COMBINATIONS, 1, mean)

hist_all <-hist(C_M, breaks= length(unique(C_M)), col = “blue”)

Interesting histogram.It’s as if there are two distributions. But if we change the value of m by:

m <- 50 n <- 4

We obtain the following histogram:

Although it is a very simple math and programming exercise, the interesting thing is to interpret why histograms behave this way, so it becomes an exercise in understanding the visualization.