# Simulating distributions

I am working on a Capacity Planning assignment and I have read some books. This is specifically about distributions. I use R.

1. What is the recommended approach to identify what my data distribution is ? Are there statistical methods to identify it ?

I have this diagram.

1. What are simulations approaches available using R ? Here I want to generate data for a certain distribution like exponential. Is r-java the right approach if I want to integrate it with Java ?

2. Is there a way to predict what distribution the effect( CPU usage etc. ) will have when I pipe data for a particular distribution ? What are the different effects of sending certain distributions of data ?

Please consider these as beginner's questions. Are there books or material that deal with these types of simulations ?

## Notes

THe diagram is from the end of the paper http://people.stern.nyu.edu/adamodar/pdfiles/papers/probabilistic.pdf.

### Goodness of fit techniques I have come across

Assessment of goodness-of-fit

1. Chi-squared
2. Kolmogorov-Smirnov,
3. Anderson-Darling statistics density, cdf, P-P and Q-Q plots

I am not sure what the interpretation or next steps should be if I find that my distribution is normal or exponential etc. What does it allow me to do? Prediction? Hope this question is clear.

Exponential delays will induce queue fluctuatuions as per my Capacity Planning book by Neil Gunther. So I know that one point.

• If you think your diagram is important, then you should try to improve the quality of the picture... – ocram Jun 21 '12 at 9:24
• I appreciate the care it takes to make a nice question. In my opinion your point 2. (which should be 3 I guess) needs clarification, or you could even move it to Stack Overflow. – gui11aume Jun 21 '12 at 10:06
• I think my last question belongs here. Let's say I identify my data distribution. Is it that I predict that future distributions will follow this probability ? I am missing data analysis part here. I know that a box-whisker plot easily shows quartiles which I understand. I don't get the utility of a distribution. May there are properties of this distribution I need to investigate for prediction. – Mohan Radhakrishnan Jun 21 '12 at 10:32
• @ocram If the quality is poor, magnify the page in your browser: the detail is there. BTW, these images must be from some of the Crystal Ball documentation. – whuber Jun 21 '12 at 15:44
• @whuber: Indeed, I did not even try! Sorry for the comment. – ocram Jun 21 '12 at 15:48

I will answer your point about simulations with R because this is the only one I am familiar with. R has a lot of builtin distributions which you can simulate. The logics of naming is that to simulate a distribution called dis the name will be rdis.

Below are the ones I use most often

# Some continuous distributions.
?rnorm
?runif
?rgamma
?rlnorm
?rweibull
?rexp
?rt
# Some discrete distributions.
?rpoiss
?rbinom
?rnbinom
?rgeom
?rhyper


You can find some complements in Fitting distributions with R.

Addition: thanks to @jthetzel for providing a link with a comprehensive list of distributions and the packages they belong to.

But wait, there's more: OK, following @whuber's comment I'll try to address the other points. Regarding point 1, I never go by a goodness-of-fit approach. Instead I always think about the origin of the signal, like what causes the phenomenon, is there some natural symmetries in what produces it etc. You need several book's chapters to cover it so I'll just give two examples.

1. If the data are counts and there is no upper limit, I try a Poisson. Poisson variables can be interpreted as the counts of successive independent during a time window, which is a very general framework. I fit the distribution and see (often visually) whether the variance is well described. Quite often, the variance of the sample is much higher, in which case I use a Negative Binomial. Negative Binomial can be interpreted as a mix of Poisson with different variables, which is even more general, so this usually fits very well to the sample.

2. If I think that the data is symmetric around the mean, i.e. that deviations are equally likely to be positive or negative, I try to fit a Gaussian. I then check (again visually) whether there is a lot of outliers, i.e data points very far away from the mean. If there are, I use a Student's t instead. The Student's t distribution can be interpreted as a mixture of Gaussian with different variances, which is again very general.

In those examples, when I say visually, I mean that I use a Q-Q plot

Point 3, also deserves several book's chapters. The effects of using a distribution instead of another are limitless. So instead of going through it all, I will continue the two examples above.

1. In my early days, I did not know that Negative Binomial can have a meaningful interpretation so I used Poisson all the time (because I like to be able to interpret the parameters in human terms). Very often, when you use a Poisson, you fit the mean nicely, but you underestimate the variance. This means that you are unable to reproduce extreme values of your sample and you will consider such values as outliers (data points that do not have the same distribution as the other points) while they are actually not.

2. Again in my early days, I did not know that Student's t also has a meaningful interpretation and I would use the Gaussian all the time. A similar thing happened. I would fit the mean and the variance well, but I would still not capture the outliers because almost all data points are supposed to be within 3 standard deviations of the mean. The same thing happened, I concluded that some points were "extraordinary", while actually they were not.

• A note to add to gui11aume's answer: There is a "d, p, q, r" syntax for distribution related functions in R. For example, dnorm, pnorm, qnorm, and rnorm are the density, cumulative distribution function (CDF), inverse CDF, and random variate generator functions for the Normal distribution, respectively. See the probability distribution task view for a comprehensive list of available distributions. – jthetzel Jun 21 '12 at 14:37
• Yep, thanks very much (+1). I was looking for such a list for a long time. I put it in the answer so that it is more visible. – gui11aume Jun 21 '12 at 16:05
• I couldn't even tell you what a third of those distributions are. So much more to learn... . +1, but let's not forget the rest of the question, which is fundamental (but maybe a little too broad): what effects do choices of distribution have in a simulation? How should one go about making these choices? – whuber Jun 21 '12 at 17:01
• @whuber I added the effect of exponential distribution of delays on queue fluctuations. Refer. books on CP or queueing. – Mohan Radhakrishnan Jun 22 '12 at 6:02
• I have read Fitting distributions with R and also used Q-Q plot once. Maximum likelihood estimation begins with the mathematical expression known as a likelihood function of the sample data.. Loosely speaking, the likelihood of a set of data is the probability of obtaining that particular set of data given the chosen probability model. Does this mean that there is a way to calculate that the distribution can occur again ? How many measurements are required to prove this ? – Mohan Radhakrishnan Jun 22 '12 at 8:18