How to properly walk from PDF to quantile using symbolic representations?

2 views (last 30 days)
I like to start with the PDF and symbolically reach the quantile of the normal distribution. I discover two unexpected behaviors: 1. My symbolic representation is simplified in an unexpected manner 2. The finverse function fails in the CDF.
Can I stop the simplification and run the functional inverse?
Here is what I am trying:
syms x mu sd;
n_x = (1/sqrt(2*pi*sd^2)) * (1/exp( (x-mu)^2/(2*sd^2) ));
pretty(n_x)
Resulting in:
1/2
2
---------------------------------
/ 2 \
1/2 | (mu - x) | 2 1/2
2 pi exp| --------- | (sd )
| 2 |
\ 2 sd /
Equivalent, but not what I have typed. How can I make Matlab maintain the common notation, rather then the "simplified" one?
It becomes even more strange when integrating and then running the function inverse:
int_n_x = int(n_x);
pretty(int_n_x);
Resulting in:
/ 1/2 / 1 \1/2 \
| 2 (mu - x) | --- | |
| | 2 | |
| \ sd / |
erf| ------------------------ |
\ 2 /
- -------------------------------
/ 1 \1/2 2 1/2
2 | --- | (sd )
| 2 |
\ sd /
Because I can see that this unlikely to match to an inverse function I substitute some simple values and try finverse:
int_n_subs_x= subs(int_n_x, {mu, sd}, {0,1});
pretty(int_n_subs_x);
/ 1/2 \
| 2 x |
erf| ------ |
\ 2 /
-------------
2
finverse(int_n_subs_x)
Warning: Functional inverse cannot be found.
Why does it fail if Matlab knows about icdf and erfinv?

Answers (0)

Community Treasure Hunt

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

Start Hunting!