I think the only thing i'm missing is the mean of the means (not very difficult but I am feeling lazy after working on this all day)
and the histogram displaying correctly at the moment I'm not sure it would display with the randomly generated values I think it should be simple to input I'm just new to MATLAB.. Thank you 🙂
Specifications for program below:
1. Generate 100 samples of size 225 random numbers from U(-3,6). For each of these 100 samples calculate the mean.
a) Find the simulated probability that the mean is between 1 and 2.
b) Find the mean of the means.
c) Find the standard deviation of the means.
d) Draw the histogram of the means.
nsamples=100;samplenum = 1:nsamples; %setting number of samples and the sample amt. i.e. here there
%is only 1 sample of number 100
n = 225; %sample size 225
a = 1; %setting first mean value of 1
b = 2; %setting second mean value of 2
theProbability = sum(nsamples > a & nsamples < b) / n; %finding the probability that the mean is between a and b
a + (b-a)*rand() %gives uniform random values in the interval [a,b]
data = a + (b-a)*rand(1, nsamples); %setting data values
cMean = mean(data) %calculating mean of data
cStdDev = std(data) %calculating standard deviation of data
z = normrnd(-3,6,n,1); %setting distribution of random numbers U(-3,6) (n)=(U) here
hist(z,-9.75:.5:9.75); %setting histogram values for x-axis (labeled here as z)
xlim([-10 10]); %setting x-axis coordinates
title('Generating 100 Samples of Size 225 Simulated U(-3,6) Random Numbers Histogram Question 1 Part d)'); %title of histogram
xlabel('Z'); %labeling x-axis
ylabel('Frequency'); %labeling y-axis
Best Answer