0

Let's say I have a column x with uniform distributed values. To these values, I applied a cdf-function.

Now I want to calculate the Gaussian Copula, but I can't find the function in python. I read already, that Gaussian Copula is something like the "inverse of the cdf function".

The reason why I'm doing it comes from this paragraph:

A visual depiction of applying the Gaussian Copula process to normalize an observation by applying = Phi^-1(()). Calculating () yields a value ∈ [0, 1] representing the proportion of shaded area at the left. Then Phi^−1() yields a value by matching the shaded area in a Gaussian distribution.

I need your help, does everyone has an idea how to calculate that?

I have 2 ideas so far:

1) gauss = 1/(sqrt(2*pi)*s)*e**(-0.5*(float(x-m)/s)**2) --> so transform all the values with this to a new value

2) norm.ppf(array,loc,scale) --> So give the ppf function the mean and the std and the array and it will calculate me the inverse of the CDF... But I doubt #2

The thing is

n.cdf(n.ppf(0.95))

Is not what I want. The idea why I'm doing it, is transforming a not normal/gaussian distribution to a normal distribution.

Like here:

Transform from a non gaussian distribution to a gaussian distribution with Gaussian Copula

Any other ideas or tipps?

Thank you very much :)

EDIT:

I found 2 links which are quite usefull: 1. https://stats.stackexchange.com/questions/197283/how-to-transform-an-arcsine-distribution-to-a-normal-distribution 2. https://stats.stackexchange.com/questions/125648/transformation-chi-squared-to-normal-distribution/125653#125653

In this posts its said that you have to

All the details are in the answer already - you take your random variable, and transform it by its own cdf ..... yielding a uniform result.

Thats true for me. If I take a random distirbution and apply the norm.cdf(data, mean,std) function, I get a uniform distributed cdf

Compare: import pandas as pd data = [1.5]*7 + [2.5]*2 + [3.5]*8 + [4.5]*3 + [5.5]*1 + [6.5]*8 cdf=n.cdf(data, n.mean(data),n.std(data)) print cdf

But How can I do the

You then transform again, applying the quantile function (inverse cdf) of the desired distribution (in this case by the standard normal quantile function /inverse of the normal cdf, producing a variable with a standard normal distribution).

Because when I use f.e. the norm.ppf function, the values are not reasonable

  • Do a google search for "python gaussian formula". You will get several useful hits. – jira Nov 17 '17 at 11:31
  • Thank you for your quick help, but I couldn't find any helpful hits. Only this one: https://stackoverflow.com/questions/20626994/how-to-calculate-the-inverse-of-the-normal-cumulative-distribution-function-in-p You think I can apply this to my problem? Just norm.ppf()?? – peterlustig Nov 17 '17 at 11:40
  • So is it correct, that I can just apply the norm.ppf() function, add my mean and my std to it, and then I "transform" my f.e. uniform distribution to a normal distribution? – peterlustig Nov 17 '17 at 11:45
  • You need https://en.wikipedia.org/wiki/Probability_integral_transform IIRC – jira Nov 17 '17 at 12:48
  • Could you explain a bit please? As you can see, I don't have a lot of knowledge about that. So the Probability Integral Transformation is the same as the inverse of cdf / Gaussian Copula? Because the result of your link is to transform it into uniform distribution, but I want normal distribution :) What are the dependencies? Thank you :) – peterlustig Nov 17 '17 at 13:33
  • These 2 links are (at least I think) helpfull, but I have no idea how to build that in python: 1. https://stats.stackexchange.com/questions/197283/how-to-transform-an-arcsine-distribution-to-a-normal-distribution 2. https://stats.stackexchange.com/questions/125648/transformation-chi-squared-to-normal-distribution/125653#125653 Any help? – peterlustig Nov 18 '17 at 11:09

0 Answers0