find finverse of cumtrapz()

9 ビュー (過去 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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by