I was trying to solve some exercises on Matlab in order to improve my skills and I stumbled upon this question:
For the (theoretical) Negative Binomial distribution with parameters r = 5, p = 0.4, use Matlab to find the mean, μ, and variance, $\sigma^2$.
I have found the answers to be μ = 7.500 and $\sigma^2$ = 18.7500. Now, the second part of the question is a bit tough for me:
For each sample size n = 1, 5, 10:
1) Generate 1,000 random samples from this distribution (as a 1000 x n or an n x 1000 matrix) 2) Find the 1,000 sample means (Hint: store them for further calculation) 3) Compute the mean and variance of the 1,000 sample means.
I have tried to use the function RND = nbinrnd(R,P,m,n), where R = 5, P = 0.4, m = 1000, and n = 1. If that's correct, I assume that would be for the sample size 1? How can I adjust this in order to calculate for size 5 and 10? I have tried to find an answer on the web, but I've had no luck so far.
From the MATLAB documentation:
Short version: try it and find out.
Long version, $m$ and $n$ give you an $m$ by $n$ matrix. So if $m = 5$ and $n = 1$, then you get a 5 by 1 matrix of negative binomial random variables.
If $m = 5$ and $n = 10$, you get a 5 by 10 matrix.
If you just need to generate $N$ samples, set $m = 1$ and $n = N$, or vice versa.