How can I calculate with distributions?

4 次查看(过去 30 天)
I have two data sets (couloumn vektors 86x1) and used the Distribution Fitter App to generate the best fit. Then I saved the fits to workspace as exepted as prob.LognormalDistribution and prob.NormalDistribution types. The variables are named: CDF_Zahnfreischlifflnge and ICDF_Zahnfreischlifflnge.
I want to generate a mathematic function: phi= cdf*icdf Related to my variables:
Here is the code I tried in command window with error messages:
phi=CDF_Zahnfreischlifflnge * ICDF_Zahnfreischlifflnge;
error massage: Undefined operator '*' for Input Arguments of type 'prob.NormalDistribution'.
phi=('CDF_Zahnfreischlifflnge' * 'ICDF_Zahnfreischlifflnge');
error massage: Inner Matrix dimensions must agree.
phi=(sum('CDF_Zahnfreischlifflnge' , 'ICDF_Zahnfreischlifflnge'));
error massage: Error using sum. Invalid Option. Option must be double, native, default, omitnan or inculdenan.
Using the option "times" insted of "sum" I get the error massage with "Inner Matrix dimensions must agree.".
Has someone an idea how to convert my variables CDF_Zahnfreischlifflnge and ICDF_Zahnfreischlifflnge in a way I can calculate with them?

回答(2 个)

KL
KL 2017-10-23
If I understand you correctly, those two are column vectors and you want to perform element-wise multiplication, right? In that case,
phi=CDF_Zahnfreischlifflnge .* ICDF_Zahnfreischlifflnge;
should work.
  1 个评论
Carina Groes
Carina Groes 2017-10-24
No, those two are 1x1 NormalDistribution types wich I generated with the Distribution Fitter Toolbox. I try to take the mathematic functions of the CDF and inverse CDF and want to generate the sum of them (also a function). The main question is: How can I get the mathematic function from these Distribution objekts to multiplicate them? Or wich type should I generate (and how) to multiplicate with these functions? Maybe I can transform a distribution type to a function... I tried your code and it didnt worked: Error code "Undefined operator '.*' for input arguments of type 'prob.NormalDistribution'."

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2017-10-24
You appear to be attempting to do theoretical calculations with Statistics Toolbox probability distribution objects. Those objects are not designed for that purpose. The implementation of the formulas for each distribution is buried down several objects.
pdf() of a log normal distribution object eventually ends up calling lognpdf() with the parameters appropriate for that object. If you needed the theoretical formula, then you might start thinking about passing a symbolic x into lognpdf() to get out the formula. Unfortunately, that code contains
x(x <= 0) = Inf
and even if you
syms x positive
then it does not know that x <= 0 is to be false, and considers it unprovable, and generates an error message. Therefore you would have to go in to functions like that one and find the formula and extract it by hand to create the general symbolic form that you could then manipulate further.
  2 个评论
Carina Groes
Carina Groes 2017-10-25
It worked very well by generating general functions, thanks! Except in the place where I want to create the inverse of the generated functions.
Messwert_sym=sym('Messwert')
Index_Zahnfreischlifflnge_sym=sym('Index_Zahnfreischlifflnge')
I filled the two symbolic variables with data I saved in couloumn vektors.
inner_Integral_CDF_Zahnfreischlifflnge=symfun(exp(0.5*(Index_Zahnfreischlifflnge_sym^2)), Index_Zahnfreischlifflnge_sym)
Then I generated a symbolic function to create a mathematic function I can integrate later. After this step I created another symbolic function to integrate the function above with boundarys negative infinity and the one coulumnvektor.
CDF_Zahnfreischlifflnge=symfun((1/sqrt(2*pi))*int(inner_Integral_CDF_Zahnfreischlifflnge, -Inf, Messwert_sym),Index_Zahnfreischlifflnge_sym)
All these steps work until I try to get the inversion of CDF_Zahnfreischlifflnge.
ICDF_Zahnfreischlifflnge=finverse(CDF_Zahnfreischlifflnge)
Warning: Unable to find functional inverse.
> In symengine
In sym/privBinaryOp (line 1013)
In sym/finverse (line 40)
ICDF_Zahnfreischlifflnge(Index_Zahnfreischlifflnge) =
Empty sym: 0-by-1
Why is this empty?
Walter Roberson
Walter Roberson 2017-10-25
I will probably need your code to test with.

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by