avoid imaginary numbers in probabilistic calculation

조회 수: 4 (최근 30일)
Aikaterini
Aikaterini 2014년 10월 8일
댓글: Star Strider 2014년 10월 8일
Hello everyone,
I am trying to do create a number given its probability dencity function. So, for example I have h=expinv(mu), where expinv is the inverse exponential function and I get imaginary values of h. How can I avoid them?
Thanks in advance
Katerina
  댓글 수: 1
Aikaterini
Aikaterini 2014년 10월 8일
Dear all,
i am trying to run a Monte Carlo (MC) analysis in Matlab, so it is supposed that the probability is being provided automatically from the MC code that matlab has. What someone has to do at first is to determine the probability density functions of each parameter in order to get a sample of values from MC. In this point I have negative and even imaginary values which are undesirable. Do you know what to do in this case? Does anyone know aboout MC simulation in Matlab?
Regards, Katerina

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

답변 (2개)

Mike Hosea
Mike Hosea 2014년 10월 8일
You haven't told me how you got them, so I can't tell you how to avoid them. Most likely your calculations before calling expinv are returning complex numbers. Note that the first argument to expinv is a probability value, not the mean. The mean is the optional second input.

Star Strider
Star Strider 2014년 10월 8일
You have to provide both a probability value (0,1) and a value for mu for expinv. You are only giving it one parameter.
  댓글 수: 5
Mike Hosea
Mike Hosea 2014년 10월 8일
편집: Mike Hosea 2014년 10월 8일
OK, I can definitely see how you got the idea now. In fact I don't think this default is very useful, which could explain why it isn't advertised that well, but it has been an explicit part of the implementation from function's inception, and the fact that mu=1 is the default has been documented in the "help expinv" text since a line to that effect was added in 2003. If you type "help expinv" you get
>> help expinv
expinv Inverse of the exponential cumulative distribution function.
X = expinv(P,MU) returns the inverse cdf of the exponential
distribution with mean parameter MU, evaluated at the values in P.
The size of X is the common size of the input arguments. A scalar input
functions as a constant matrix of the same size as the other input.
The default value for MU is 1.
[snip]
I agree that this is an oblique way of saying that you can get away with supplying only one input.
Returning to the OP's question, however, it doesn't matter how much code is in-between; Something the user is doing or not doing is causing complex inputs to be generated, and I still don't see how we have enough information to figure out what.
Star Strider
Star Strider 2014년 10월 8일
I haven’t used help since the Help browser appeared a few releases ago. It never occurred to me to look at help.
I agree with the rest.

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

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by