gregversteeg / gaussianize Goto Github PK
View Code? Open in Web Editor NEWTransforms univariate data into normally distributed data
License: MIT License
Transforms univariate data into normally distributed data
License: MIT License
I tried to transform my data to gaussian distribution and the output of the transform function is the same as the original data. I created this script to run some tests.
Thank you in advance.
Test script:
import gaussianize as g
import numpy as np
x_uni = np.random.uniform(size=(1000,1))
out_uni = g.Gaussianize()
out_uni.fit(x_uni)
print("out_uni coefficients:", out_uni.coefs_, "\n")
y_uni = out_uni.transform(x_uni)
print("sum of transform minus original uniform:", sum(y_uni-x_uni), "\n")
x_norm = np.random.normal(size=(1000,1))
out_norm = g.Gaussianize()
out_norm.fit(x_norm)
print("out_norm coefficients:", out_norm.coefs_, "\n")
y_norm = out_norm.transform(x_norm)
print("sum of transform minus original normal:", sum(y_norm-x_norm), "\n")
import scipy.io as scio
import os
midep1 = scio.loadmat(os.path.join("D:\\", "Shared", "Data - sLorTimeseries", "LorTimeSeries_2_EC_MID_001_ep1.mat"))["LoretaTimeSeries"]
x = midep1[0, :]
x.shape = (4001, 1)
out= g.Gaussianize()
out.fit(x)
print("my data coefficients:", out.coefs_, "\n")
y = out.transform(x)
print("tranform minus original of my data:")
print(y-x, "\n")
print("sum of transform minus original:", sum(y-x), `"\n")
Output:
out_uni coefficients: [(0.4964280888006252, 0.2880773918099591, 0.0)]
sum of transform minus original uniform: [-8.04911693e-16]
out_norm coefficients: [(-0.013567057474285795, 0.9626024748274751, 0.013488)]
sum of transform minus original normal: [-0.15229739]
my data coefficients: [(2.8030224, 1.3002187, 0.0)]
tranform minus original of my data:
[[ 0.0000000e+00]
[ 0.0000000e+00]
[-1.3737008e-08]
...
[ 0.0000000e+00]
[ 0.0000000e+00]
[ 0.0000000e+00]]
sum of transform minus original: [1.0423828e-06] `
The fit of x_uni has different coefficients compared to x_norm but y_uni and y_norm are equal to x_uni and x_norm respectively. In my understanding the transformed signal should scale to resemple a gaussian distribution. Am I missing something or not running the transforms correctly?
Just pseudorandomly sign flip the data (and or randomly permute it) and run it through an (nlog(n)) Walsh Hadamard transform and the data takes on the Gaussian distribution.
If the data is very sparse you might have to apply that idea twice to get to the Gaussian.
https://randomprojectionai.blogspot.com/
Hi,
What is the license of this code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.