A Few Key Concepts to Take From One Complete Program and Apply to Another Very Similar Second Computer Program from an Exponential Distribution with Lambda Function Applied..

1 visualización (últimos 30 días)
Hello, this may take a few minutes, be warned hehe.. but really shouldn't be too bad at all!
Here is first program:
nsamples=100; % number of samples
n = 225; % sample size 225
a = 1;
b = 2;
data = -3+9*rand(nsamples, n); % random 100x225 data sample from a uniform (0,1) distribution
cMean = mean(data, 2); % mean of each sample
answer_a = sum(cMean > a & cMean < b)/nsamples; % how many data means are between a and b
answer_b = mean(cMean);
answer_c = std(cMean, 1);
hist(cMean);
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
Here are the specifications for the first program:
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.
Here are the specifications for the second program with few differences from the first program to a second from an Exponential Distribution with Lambda function:
2. Generate 400 samples of size 625 random numbers from an Exponential distribution with lambda = 0.2. For each of these 400 samples calculate the mean.
a) Find the simulated probability that the mean is between 3 and 5.
b) Find the simulated mean of the means.
c) Find the simulated standard deviation of the means.
d) Draw the histogram of the means.
Thank you, Happy Holidays!

Respuesta aceptada

James Tursa
James Tursa el 1 de Dic. de 2016
I think your question is how to generate exponential(lambda) random numbers. If so, you can get them from uniform(0,1) numbers with the following:
T = -log(U)/lambda
Where U are the uniform numbers and T are the exponential numbers.
  4 comentarios
James Tursa
James Tursa el 1 de Dic. de 2016
Editada: James Tursa el 1 de Dic. de 2016
Almost. E.g., this for data given the other inputs:
data = -log(rand(nsamples, n)) / lambda;
HrMmz
HrMmz el 1 de Dic. de 2016
Editada: HrMmz el 1 de Dic. de 2016
Oh wow.. I feel dumb sometimes that felt so basic thanks, good to be humbled.
So just
data=-log(rand(nsamples, n))/lambda
and then changing the other specs.. I hope I'm not missing something now that I know how easy that one was haha I'll have to post again when I change it later tonight

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by