avoid imaginary numbers in probabilistic calculation

4 Ansichten (letzte 30 Tage)
Aikaterini
Aikaterini am 8 Okt. 2014
Kommentiert: Star Strider am 8 Okt. 2014
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 Kommentar
Aikaterini
Aikaterini am 8 Okt. 2014
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

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Mike Hosea
Mike Hosea am 8 Okt. 2014
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 am 8 Okt. 2014
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 Kommentare
Mike Hosea
Mike Hosea am 8 Okt. 2014
Bearbeitet: Mike Hosea am 8 Okt. 2014
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 am 8 Okt. 2014
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by