[From the Stan Manual](https://mc-stan.org/docs/2_25/reference-manual/change-of-variables-section.html#multivariate-changes-of-variables):

> Suppose $X$ is a $K$-dimensional random variable with probability density function $p_X(x)$. A new random variable $Y = f ( X )$ may be defined by transforming $X$ with a suitably well-behaved function $f $. It suffices for what follows to note that if $f$ is one-to-one and its inverse $f ^ {− 1}$ has a well-defined Jacobian, then the density of $Y$ is 
$$
p_Y ( y ) = p_X ( f ^ {− 1} ( y ) ) ∣ det J _ {f ^{ − 1}} ( y ) |
$$

Here we have $p_X(a, b) \sim \text{Uniform}$, with $a = \frac{\alpha}{\alpha + \beta}, b = (\alpha + \beta)^{-1/2}$


```python
from sympy import symbols, Matrix, simplify, solve, Eq, Abs, log
```


```python
alpha, beta = symbols('alpha, beta', positive=True)
a, b = symbols('a b')
f = solve((Eq(alpha / (alpha + beta), a),
           Eq((alpha + beta)**(-1/2), b)),
          alpha, beta)
f
```




    {alpha: a/b**2, beta: (1.0 - a)/b**2}




```python
f_inv = solve((Eq(alpha / (alpha + beta), a),
               Eq((alpha + beta)**(-1/2), b)),
              a, b)
f_inv
```




    {b: 1/sqrt(alpha + beta), a: alpha/(alpha + beta)}




```python
X = Matrix([f_inv[a], f_inv[b]])
Y = Matrix([alpha, beta])
det = X.jacobian(Y).det()
det = det.subs([
    (alpha, f[alpha]),
    (beta, f[beta])]).subs(b, (alpha + beta)**(-1/2))
p_a_b = simplify(Abs(det))
p_a_b
```




$\displaystyle \frac{0.5}{\left(\alpha + \beta\right)^{2.5}}$




```python
x, y = symbols('x y')
rewrited = solve((Eq(x, log(alpha / beta)),
                  Eq(y, log(alpha + beta))),
                 alpha, beta)
```


```python
rewrited
```




    {beta: exp(y)/(exp(x) + 1), alpha: exp(x + y)/(exp(x) + 1)}




```python
X = Matrix([rewrited[alpha], rewrited[beta]])
Y = Matrix([x, y])
det = X.jacobian(Y).det().subs([
  (x, log(alpha / beta)),
  (y, log(alpha + beta))])
simplify(Abs(det)) * p_a_b
```




$\displaystyle \frac{0.5 \alpha \beta}{\left(\alpha + \beta\right)^{2.5}}$




```python

```

f7c12bb0e6dd7b92757c5f25bfb66925b023a347
ipynb
Jupyter Notebook
PyMC3QnA/discourse_6331.ipynb
junpenglao/Planet_Sakaar_Data_Science
73d9605b91b774a56d18c193538691521f679f16
MIT
2018-04-08T19:53:15.000Z
2021-11-24T21:08:25.000Z
PyMC3QnA/discourse_6331.ipynb
junpenglao/Planet_Sakaar_Data_Science
73d9605b91b774a56d18c193538691521f679f16
MIT
2018-05-29T20:50:37.000Z
2020-09-12T07:14:08.000Z
PyMC3QnA/discourse_6331.ipynb
junpenglao/Planet_Sakaar_Data_Science
73d9605b91b774a56d18c193538691521f679f16
MIT
2018-07-21T09:53:10.000Z
2021-06-07T19:06:26.000Z
Qwen/Qwen-72B
1. YES
2. YES