Friends, I tried to write algorithm to compute U-series (expansion of random variables with respect to polynomial in Uniform variable) but I had little luck in devising any algorithm that works all the time. Therefore I decided to look for alternative ways to find U-series of arbitrary random variables. And I have some good ideas. If you can find expansions of your data in terms of a polynomial with variable with respect to any density, you can convert it to a polynomial with respect to (our version of) standard Uniform(also called a U-series). For example, if you have fitted first few moments to a Z-series (polynomial with respect to standard normal), you can directly convert your Z-series into a U-series. However describing an normal density variable (that sits on a squared exponential density) in terms of a polynomial in standard Uniform variable might take a (U-series) polynomial of far greater degree than the original Z-series expansion.

Once we have found the U-series, we can easily convert it into a series in Legendre polynomials with very simple algebra. For example if the U-series is of 8h order, we need to divide it once with respect to eighth order Legendre polynomial. This division will in general only eliminate the 8th power of U-series. The quotient will be the coefficient of 8th degree Legendre polynomial. Since we have matched the eighth power and eliminated it, the remainder will in general be a seventh degree polynomial in standard uniform variable( seventh order U-series). Now we will divide this seventh degree polynomial with seventh order Legendre polynomial to eliminate the seventh power of polynomial in uniform variable. The quotient of this division by seventh order Legendre polynomial would be coefficient of seventh order Legendre polynomial. And remainder will in general be sixth degree polynomial from which we will find coefficient of sixth degree Legendre polynomial after division and so on until we are left with a simple coefficient that will be the coefficient of zeroth degree Legendre polynomial. In fact, we can represent any ordinary polynomial in terms of coefficients of (any of the popular and common) orthogonal polynomials using this method. In polynomial space of same order of polynomials, they are all equivalent.

To give friends some ideas about how to convert a standard normal variable (or any other density with continuous derivatives) into (our version of) standard uniform, I want friends to read some preliminaries including few older posts where I have mentioned how to do this.

Below I am directly copying the contents of this post so it is easier to read. Here is the original post 1637:

https://forum.wilmott.com/viewtopic.php?f=4&t=99702&start=1635#p873552
I will copy contents of the above post below and then explain how a Z-series can be converted directly into a U-series in the next post. This means that if we are given a polynomial representation of our data in terms of polynomial in powers of standard normal, we can describe the same data by a polynomial in standard uniform. Preliminaries first and then I give the details in next post.

The idea is to expand standard normal and its powers as a Taylor series in (our version of) standard Uniform variable. The derivatives of Z with respect to U of all orders required for this Taylor expansion are found by simple analytics related to change of density derivative of standard normal density with respect to standard uniform density. Please read the copied post below and I explain the ideas in more details in next post in the context of conversion of Z-series in U-series.

Below is the copy of post 1637.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Friends, I had tried this idea earlier when I was finding Z-series of density from its moments in posts 1491 and 1492. But there I had tried to generate a base density from solution of linear equations applied to match the moments of the random variable. The idea of expanding any random variable with analytic density at its median and finding its derivatives with respect to standard normal random variable to from a Z-series of random variable was perfectly sound but the whole thing did not work as moments calculated from linear equations were totally rubbish.

https://forum.wilmott.com/viewtopic.php?f=4&t=99702&start=1485#p871047
https://forum.wilmott.com/viewtopic.php?f=4&t=99702&start=1485#p871049
Here I copy relevant parts of those above posts.

From post 1491:

Friends, we have earlier learnt when we want to represent a stochastic random variable X, in the form of a Z-series, the form of equation for X is given as

[$]X(Z)=a_0 \,+ a_1 \, Z + a_2 \, Z^2 + a_3 \, Z^3 + a_4 \, Z^4 +\, ... [$]

The first, second and third derivatives of w(t) w.r.t Z are given as

[$]\frac{\partial X}{\partial Z}= a_1 \, + 2 \,a_2 \, Z +3 \, a_3 \, Z^2 +4 \, a_4 \, Z^3 +\, ... [$]

[$]\frac{\partial^2 X}{\partial Z^2}= 2 \,a_2 \, +6 \, a_3 \, Z +12 \, a_4 \, Z^2 +\, ... [$]

[$]\frac{\partial^3 X}{\partial Z^3}= 6 \, a_3 \, +24 \, a_4 \, Z \,+60 \, a_5 \, Z^2 +\, ... [$]

IF we do all the calculations of series evolution equation at median where Z=0. here all the derivatives are given only by leading coefficient associated with zeroth power of Z. So at Z=0,

[$]w(t)=a_0 \,[$]

[$]\frac{\partial X}{\partial Z}= a_1 \, [$]

[$]\frac{\partial^2 X}{\partial Z^2}= 2 \,a_2 \, [$]

[$]\frac{\partial^3 X}{\partial Z^3}= 6 \, a_3 \, [$]

[$]\frac{\partial^4 X}{\partial Z^4}= 24 \, a_4 \, [$]

So we have that

[$]X(Z)=a_0 \,+ a_1 \, Z + a_2 \, Z^2 + a_3 \, Z^3 + a_4 \, Z^4 +\, ... [$]

[$]X(Z)=a_0 \,+ \frac{\partial X}{\partial Z} \, Z + 1/2 \, \frac{\partial^2 X}{\partial Z^2} \, Z^2 +1/6 \, \frac{\partial^3 X}{\partial Z^3} \, Z^3 +1/24 \, \frac{\partial^4 X}{\partial Z^4} \, Z^4 +\, ... [$]

So basically our power series is the same as Taylor series where derivatives between the two random variables, the stochastic variable X and standard Gaussian Z, are calculated at the median. ( You could do these calculations at other points in the density as well but those calculations would be much more involved and if correct should yield the exact same final result if the density is based on continuous derivatives)

If we could just find the median of density of our random variable X and its derivatives [$]\frac{\partial X}{\partial Z}\, [$], [$]\frac{\partial^2 X}{\partial Z^2} [$] and other higher derivatives with respect to Z, we can find coefficients of our power series representation of our random variable X in terms of powers of standard Gaussian.

Again the above derivatives would have to be calculated at median of densities of both random variables, X and Z.

From Post 1492:

As we learnt in the previous post, In order to construct the Z-series of a particular stochastic random variable X, we have to find its various derivatives with respect to standard Gaussian at the median(of both densities). So our first step towards construction of a Z-series representation would be to find median of the stochastic random variable X in question. I suppose that we have constructed analytical density of X using one of the methods described in previous post. We would have to find median mostly through Newton-Raphson as there are usually no simple formulas for median of a density.

After finding median, we can fix first coefficient of Z_Series as

[$] c_0 \, = \, Median [$]

Both our density for random variable X and the standard gaussian density are related through change of variable formula for two densities as

[$]p_Z(Z) \, = \, p_X(X(Z)) \, \frac{dX}{dZ} \, [$] Eq(1)

So we can find [$]\, \frac{dX}{dZ} \, [$] at median from the ratio of densities of respective variables at median as

[$]\, \frac{dX}{dZ} \, = \, \frac{p_Z(Z=0)}{p_X(X(Z)=c_0)}= \, \frac{p_Z(0)}{p_X(c_0)}[$]

In order to find higher derivatives of X with respect to Z at median, we differentiate Eq(1) on both sides w.r.t Z as

[$]p'_Z(Z) \, = \, p'_X(X(Z)) \, {(\frac{dX}{dZ})}^2 + \, p_X(X(Z)) \, \frac{d^2X}{dZ^2}\, [$] Eq(2)

In above equation and similar subsequent equations, we know the derivatives of gaussian density at Z=0 analytically. And we can easily find all first few nth derivatives of density of random variable X at its median [$]\frac{dp^n_X}{dX^n}(X(Z)) = \, \frac{dp^n_X}{dX^n}(c_0) [$] from the analytic density as we have constructed in the previous post. So we know values of all variables in Eq(2) other than [$]\, \frac{d^2X}{dZ^2}\, [$] whose value we back out from Eq(2)

The third derivative equation would be

[$]p''_Z(Z) \, = \, p''_X(X(Z)) \, {(\frac{dX}{dZ})}^3 + \, 3\, p'_X(X(Z)) \, {\frac{dX}{dZ}} \, {\frac{d^2X}{dZ^2}} + \, p_X(X(Z)) \, \frac{d^3X}{dZ^3}\, [$] Eq(3)

which can be used to back out [$] \, \frac{d^3X}{dZ^3}\,[$]

Similarly we can continue to differentiate Eq(2) and keep finding value of next higher derivative of X w.r.t Z at median.

After finding first few derivatives of X w.r.t Z at median, we can construct the Z_series of X as

[$]X(Z)=a_0 \,+ \frac{\partial X}{\partial Z} \, Z + 1/2 \, \frac{\partial^2 X}{\partial Z^2} \, Z^2 +1/6 \, \frac{\partial^3 X}{\partial Z^3} \, Z^3 +1/24 \, \frac{\partial^4 X}{\partial Z^4} \, Z^4 +\, ... [$]

In a similar spirit, I think we can take the base density as a different density (could be gamma density) and represent some stochastic variable as a series in Gamma density variable by equating the equations of two densities through change of density derivative at their median.

You think life is a secret, Life is only love of flying, It has seen many ups and downs, But it likes travel more than the destination. Allama Iqbal