find finverse of cumtrapz()

조회 수: 11 (최근 30일)
Aishwarya Radhakrishnan
Aishwarya Radhakrishnan 2019년 9월 22일
댓글: Star Strider 2019년 9월 22일
Hi,
I have to invert the function that calculates cumtrapz of an equation as follows:
mu = 0;
var = 1;
%x = -9:0.01:9;
syms x
f(x) = cumtrapz((2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v))))
i = finverse(f)
fplot(i)
But this gives me :
f(x) =
0
Warning: Unable to find functional inverse.
> In symengine
In sym/privBinaryOp (line 1032)
In sym/finverse (line 40)
In inverse_cdf (line 7)
i(x) =
Empty sym: 0-by-1
However the cumtrapz function does work:
mu = 0;
var = 1;
x = -9:0.01:9;
y = (2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v)));
i = cumtrapz(y);
plot(i)
what can i do to invert this function

채택된 답변

Star Strider
Star Strider 2019년 9월 22일
편집: Star Strider 2019년 9월 22일
Since ‘f’:
mu = 0;
v = 1;
syms x
f(x) = int((2*pi*(v))^(-0.5)* exp(-((x-mu).^2)/(2*(v))))
evaluates to:
f(x) =
(7186705221432913*2^(1/2)*pi^(1/2)*erf((2^(1/2)*x)/2))/36028797018963968
you will need to use the erfinv function to calculate the inverse.
  댓글 수: 3
Aishwarya Radhakrishnan
Aishwarya Radhakrishnan 2019년 9월 22일
편집: Aishwarya Radhakrishnan 2019년 9월 22일
the cumtrapz calculates the cumulative pdf, but with the inverse function of the cdf, i want to get x in terms of y,
eg, y = F(x)
then x = Finverse(y)
like in figure:
but on using finverse(), im getting error as output
Star Strider
Star Strider 2019년 9월 22일
If you want to use cumtrapz, the interp1 function is likely the best option:
mu = 0;
v = 1;
x = -7:0.01:7;
fx = cumtrapz(1/sqrt(2*pi*(v)) * exp(-((x-mu).^2)/(2*(v))));
y = [5 25 50 75 95];
fi = interp1(fx, x, y, 'linear','extrap')
figure
plot(x, fx)
hold on
plot(fi, y, '+')
hold off
grid
This plots ‘+’ markers at the appropriate values of the ‘y’ vector. I call the inverse ‘fi’. I had to restrict your original ‘x’ vector because with the original vector, the ‘fx’ points were not unique, as interp1 defines that.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by