<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/distribution-of-mean-of-the-combinations-of-a-set/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://feedproxy.google.com/~r/DataRValue/~3/56dpvRkIfnQ/distribution-of-means-of-combinations.html"> Data R Value</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><span><span lang="en"><span>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.</span></span></span><br><span><span lang="en"><span><br></span></span></span><span><span lang="en"><span>It should be remembered that the combinations C(<span>m</span>, <span>n</span>) of a set are the number of subsets of a set of <span>m</span> elements taken from <span>n</span> in <span>n</span>.</span></span></span></p>
<p><span><span lang="en"><span><span lang="en"><span>The number of combinations is calculated with:</span></span></span></span></span></p>
<div><a target="_blank" rel="nofollow" href="https://i0.wp.com/4.bp.blogspot.com/-UgjCo57nzz8/WIeKqbVY-sI/AAAAAAAACtA/_jzReJbLmfguE8JXg8fdSs6YcA8joJG1gCLcB/s1600/combs.png?ssl=1"><img src="https://i2.wp.com/4.bp.blogspot.com/-UgjCo57nzz8/WIeKqbVY-sI/AAAAAAAACtA/_jzReJbLmfguE8JXg8fdSs6YcA8joJG1gCLcB/s200/combs.png?resize=200%2C62&ssl=1" border="0" data-recalc-dims="1"></a></div>
<p><span><span lang="en"><span></span></span></span><br><span><span lang="en"><span>This is the very simple code to generate the combinations, calculate their mean and generate the histogram:</span></span></span></p>
<p><span><span lang="en"><span><b><span>m</span> &lt;- 50<br><span>n</span> &lt;- 6<br> </b></span></span></span><br><span><span lang="en"><span><b>COMBINATIONS &lt;- t(as.data.frame(combn(<span>m</span>,<span>n</span>)))
<p>C_M &lt;- apply(COMBINATIONS, 1, mean)</p>
<p>hist_all &lt;-hist(C_M, breaks<span> </span>= length(unique(C_M)), col = “blue”)<br><span><span lang="en"><span><br></span></span></span>
<div><a target="_blank" rel="nofollow" href="https://i1.wp.com/3.bp.blogspot.com/-TFk1PGRZ9iQ/WIePZi3NPjI/AAAAAAAACtU/rvRj4v3pycgv47jwWi-SEDFSLqEfuajAACLcB/s1600/Hist50-6.png?ssl=1"><img src="https://i1.wp.com/3.bp.blogspot.com/-TFk1PGRZ9iQ/WIePZi3NPjI/AAAAAAAACtU/rvRj4v3pycgv47jwWi-SEDFSLqEfuajAACLcB/s400/Hist50-6.png?resize=400%2C319&ssl=1" border="0" data-recalc-dims="1"></a></div></b>
<p><span><span lang="en"><span>Interesting histogram.</span> <span>It’s as if there are two distributions.</span></span></span><br><span><span lang="en"><span></span></span><span lang="en"><span>But if we change the value of m by:</span></span></span></p>
<p><span lang="en"><span></span></span><span><span lang="en"><span><b><span>m</span> &lt;- 50<br><span>n</span> &lt;- 4</b></span></span></span></p>
<p><span><span lang="en"><span>We obtain the following histogram:</span></span></span></p>
<div><a target="_blank" rel="nofollow" href="https://i2.wp.com/3.bp.blogspot.com/-_7Uy0Kr8GGc/WIeQRbWW3WI/AAAAAAAACtc/xLzMijXK3EAn8jqL2N3gHcpxSPC2IqCgwCLcB/s1600/Hist50-4.png?ssl=1"><img src="https://i1.wp.com/3.bp.blogspot.com/-_7Uy0Kr8GGc/WIeQRbWW3WI/AAAAAAAACtc/xLzMijXK3EAn8jqL2N3gHcpxSPC2IqCgwCLcB/s400/Hist50-4.png?resize=400%2C317&ssl=1" border="0" data-recalc-dims="1"></a></div>
<p><span><span lang="en"><span>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.</span></span></span></p>
<p><span><span lang="en"><span> <a target="_blank" rel="nofollow" href="https://github.com/pakinja/Data-R-Value/tree/master/Mean_Distribution_Combinations">https://github.com/pakinja/Data-R-Value</a></span></span></span></p>
<p><img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/DataRValue/~4/56dpvRkIfnQ"></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://feedproxy.google.com/~r/DataRValue/~3/56dpvRkIfnQ/distribution-of-means-of-combinations.html"> Data R Value</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/7CgIPpTNEQY"></a></div></span></span></span>