Before you can create your random number generator, you need to specify the distribution from which it should extract. You only partially did it: i.e. You indicated that it extracts from integers in [1.9] and that it has the average value that you want to specify. This still leaves an infinity of distributions to choose from. What other properties do you want in your distribution?
Change the following comment: The average of any final sample from the probability distribution β the so-called sample mean β will only approximate the average of the distribution. There is no such thing.
As was said, the simplest (in the sense of maximum entropy) distribution over integers in the region [1,9] is the exponential distribution: i.e.
p = @(n,x)(exp(-x*n)./sum(exp(-x*(1:9))));
The parameter x determines the average value of the distribution. Corresponding cumulative distribution
c = cumsum(p(1:9,x));
To extract p from the distribution, you can draw a random number from [0,1] and find which sub-interval in c it falls into: ie,
samp = arrayfun(@(y)find(y<c,1),rand(n,m));
returns an array of [n,m] integers taken from p .
source share