RileyLazarou / medium

Code for medium articles
MIT License
47 stars 13 forks source link

How to know the probability distribution method of own real data. #2

Closed Minxiangliu closed 4 years ago

Minxiangliu commented 4 years ago

How to know the probability distribution method of own real data, such as https://github.com/ConorLazarou/medium/blob/3fae4b997d1faca25e0b7395d5a71da3c2019b03/12020/visualizing_gan_uni2norm/1_uniform_to_normal_1D.py#L123-L124

How to know the value of line 123? Is there any description here? Thank you.

RileyLazarou commented 4 years ago

Check out the functions generate_noise and uniform_to_normal.

generate_noise produces independent, uniformly-distributed values in the range [-1, 1] with shape (n, 2) (ie, independent pairs of random numbers). It is a random function.

uniform_to_normal is a deterministic function that takes a number in the range [-1, 1] and returns a number in the range (-∞, ∞). This is done using inverse transform sampling. First, the number in [-1, 1] is rescaled to [0, 1]. Then, it's passed through scipy's percentage point function "ppf" for the normal distribution. These two functions combined is equivalent to sampling from the normal distribution.