필터 지우기
필터 지우기

How can I truncate a random generated exponentail distribution?

조회 수: 2 (최근 30일)
Carolina Scandellari
Carolina Scandellari 2019년 11월 5일
댓글: Star Strider 2019년 11월 5일
Hi, I'm trying to truncate an exponential distribution generated with the random function:
for mu_curr=1:100;
mu_exp=linspace(0.002,1,100);
x=1:desired_length;
mu_curr_exp=mu_exp(curr_distr);
%% generating ISI
ISI_exp=((random('Exponential',mu_curr_exp,length(x),1)));
%% concatenating in a matrix
Y_EXP(curr_distr,1:length(x))=ISI_exp';
end
I am using this loop because I have to change the mu value 100 times. I have to truncate this so number don't go below 1e-6 and above 0.2. Do you have any ideas? I tried to use the distribution object but I don't know how to use it to perform calculations on the results. Thank you,
Carolina

답변 (3개)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 5일
I leave you an idea that can be useful, in R numbers are generated with an exponential distribution in the range you want :
n=20;%amount of values to generate
mu=0.1;%mu
R = mapminmax(exprnd(mu,1,n),1e-6,0.2)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 5일
편집: KALYAN ACHARJYA 2019년 11월 5일
I have to truncate this so number don't go below 1e-6 and above 0.2. Do you have any ideas?
Is this?
I am expecting the number is Y_EXP, if else, please replace Y_EXP with respective number.
Y_EXP(Y_EXP<1e-6 | Y_EXP>0.2)=0;

Star Strider
Star Strider 2019년 11월 5일
Use the truncate function (introduced in R2013a).
See the documentation section on pd to use it with different distributions.
  댓글 수: 2
Carolina Scandellari
Carolina Scandellari 2019년 11월 5일
Yes you can use truncate but you will create an object, and I can't perform any calculations on objects. Thank you anyway
Star Strider
Star Strider 2019년 11월 5일
My pleasure.
However, I disagree!
pd = makedist('Normal')
t = truncate(pd,0,inf)
y = pdf(t, (0:5:10))
produces:
y =
0.797884560802865 2.9734390294686e-06 1.53891972534128e-22
What ‘calculations’ do you want to perform with it?
See: Working with Probability Distributions and specifically Probability Distribution Objects for an extended discussion of their capabilities.

댓글을 달려면 로그인하십시오.

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by