Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Need help with a problem

1 visualización (últimos 30 días)
Gaëtan Poirier
Gaëtan Poirier el 2 de Oct. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
There is a program I have one part I have to modify, could anyone help with this?
function y = run (lambda, n_mea, n_smpls_per_mea)
global xacc hist bin_range bin_size n_bins bin_size_inv midpt bin
% define parameters and procedures for histogram:
bin_range = 6.0 * lambda %NOTE: prefactor can be changed
bin_size = 0.1 * lambda %NOTE: prefactor can be changed
n_bins = floor(bin_range/bin_size)+1
bin_size_inv = 1.0/bin_size
% bin is a function: bin(x) provides the bin number for x:
bin =@(x)(min(floor(x*bin_size_inv)+1,n_bins))
% hist accumulates the number of entries in each bin:
hist = zeros(1,n_bins)
xacc = [n_mea]
for m=1:n_mea
xacc(m)=0
for n=1:n_smpls_per_mea
% unifrnd(0,1) gives a random uniform on (0,1)
ranxi = unifrnd(0,1)
% ranexp gives exponential distribution
ranexp = ranxi
% *^^^^^^^^^ <-- MODIFY -- fill in correct form**
xacc(m) = xacc(m) + ranexp
bi = bin(ranexp)
hist(bi) = hist(bi) +1
end
xacc(m) = xacc(m)/n_smpls_per_mea
end
midpt = 0.5*bin_size:bin_size:(n_bins-0.5)*bin_size
end
  8 comentarios
Gaëtan Poirier
Gaëtan Poirier el 2 de Oct. de 2017
Error in mkhist (line 13) exact_pdf = exp(-x/lambda)/lambda;
Walter Roberson
Walter Roberson el 2 de Oct. de 2017
mkhist is not called from the code that you posted.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by