### Exercises/Play

- Find out the discrete uniform DU(K), (continuous) uniform (0,1), U(0,1) related R commands.
- Prepare a 2×2 window for the following graphs of X, a discrete uniform (10) random variable.
- Plot pmf. cdf of X
- Plot a histogram of 10 sample from X. Compute the sample mean () and sample variance
- Plot a histogram of 100 sample. Compute the sample mean and sample variance.
- Plot a histogram of 1000 sample. Compute the sample mean and sample variance.

- Keep the plotted window, open another window and redo the steps in 2. Compare the results.
**What do you observe? Does this make sense to you?**

- Take K=400, 2000 and redo Exercise 2.
**What do you observe? Does this make sense to you?** - Take the random variable X to be U(0,1), redo exercise 2 (except for the first dot, you will be plotting a pdf instead of a pmf of X).
**R code**from class/history: g5class.r

### A prelude to ggplot2

- Data Visualization with ggplot2
- Cheatsheet (also available from your Rstudio help)
- ggplot2.org

Advertisements
(function(g,$){if("undefined"!=typeof g.__ATA){
g.__ATA.initAd({collapseEmpty:'after', sectionId:26942, width:300, height:250});
g.__ATA.initAd({collapseEmpty:'after', sectionId:114160, width:300, height:250});
}})(window,jQuery);
var o = document.getElementById('crt-573475992');
if ("undefined"!=typeof Criteo) {
var p = o.parentNode;
p.style.setProperty('display', 'inline-block', 'important');
o.style.setProperty('display', 'block', 'important');
Criteo.DisplayAcceptableAdIfAdblocked({zoneid:388248,containerid:"crt-573475992",collapseContainerIfNotAdblocked:true,"callifnotadblocked": function () {var o = document.getElementById('crt-573475992'); o.style.setProperty('display','none','important');o.style.setProperty('visbility','hidden','important'); } });
} else {
o.style.setProperty('display', 'none', 'important');
o.style.setProperty('visibility', 'hidden', 'important');
}
var o = document.getElementById('crt-1247771793');
if ("undefined"!=typeof Criteo) {
var p = o.parentNode;
p.style.setProperty('display', 'inline-block', 'important');
o.style.setProperty('display', 'block', 'important');
Criteo.DisplayAcceptableAdIfAdblocked({zoneid:837497,containerid:"crt-1247771793",collapseContainerIfNotAdblocked:true,"callifnotadblocked": function () {var o = document.getElementById('crt-1247771793'); o.style.setProperty('display','none','important');o.style.setProperty('visbility','hidden','important'); } });
} else {
o.style.setProperty('display', 'none', 'important');
o.style.setProperty('visibility', 'hidden', 'important');
}