<jupyter_start><jupyter_text>**Visualizing Linear and Non-Linear Transformations**<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import random
#
# Random 2D gaussian distribution in a plane
#

plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
npoints=1000
c=np.arange(npoints)
x = np.random.normal(size=[npoints, 2])
plt.scatter(x[:,0],x[:,1], label='Normal Distribution', c=c, cmap = 'plasma')
plt.show()
plt.close()
#plt.savefig("name")
print("X=",x)
print(" ")
print(" ")



#
# Linear Transformation of the distribution acording to T ( stretching along X and compressing along Y)
#
s1=1000
s4=0.00001
T=np.array([[s1,0],[0,s4]])
print("Matrix T=",T)
print(" ")
print(" ")

y=np.tensordot(x,T,axes=1)
print("Y=",y)
plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
x = np.random.normal(size=[npoints, 2])
plt.scatter(y[:,0],y[:,1], c=c, cmap = 'plasma', label='Transformed Normal Distribution')
plt.show()
plt.close()
#
#
# Linear Transformation of the distribution acording to T ( compressing along X and stretching along Y)
#
s1=0.00001
s4=1000.
T=np.array([[s1,0],[0,s4]])
print("Matrix T=",T)
print(" ")
print(" ")

y=np.tensordot(x,T,axes=1)
print("Y=",y)
plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
plt.scatter(y[:,0],y[:,1], c=c, cmap = 'plasma', label='Transformed Normal Distribution')
plt.show()
plt.close()
#
#
# Linear Transformation of the distribution acording to T ( compressing along X and stretching along Y and rotating )
#
s1=0.00001
s2=0
s3=-1
s4=1000.
T=np.array([[s1,s2],[s3,s4]])
print("Matrix T=",T)
print(" ")
print(" ")

y=np.tensordot(x,T,axes=1)
print("Y=",y)
plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
plt.scatter(y[:,0],y[:,1], c=c, cmap = 'plasma', label='Transformed Normal Distribution')
plt.show()
plt.close()
#
#
# Non-Linear transform the distribution ( TANH stretches the gaussian distribution to a square region )
#
y=np.tanh(x)
print("Y=",y)
plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
plt.scatter(y[:,0],y[:,1], c=c, cmap = 'plasma', label='Transformed Normal Distribution')
plt.show()
plt.close()
#
#
# Non-Linear transform the distribution ( TANH stretches distribution to a square and zom factor squezes to the edges )
#
zoom=3.5
y=np.tanh(zoom*x)
print("Y=",y)
plt.figure(figsize=(5,5),dpi=100)
plt.xlabel("X1")
plt.ylabel("X2")
plt.scatter(y[:,0],y[:,1], c=c, cmap = 'plasma', label='Transformed Normal Distribution')
plt.show()
plt.close()
#<jupyter_output>Y= [[-0.999043   -0.81205197]
 [-0.39895711 -0.97233971]
 [ 0.95306512 -0.96585363]
 ...
 [ 0.99999997 -0.44743427]
 [ 0.99991238 -0.99999244]
 [-0.90706783  0.00467337]]
{'fraction_non_alphanumeric': 0.2105068442471328, 'fraction_numerical': 0.0828708842027377, 'mean_word_length': 6.1534391534391535, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '232767', 'license': 'MIT', 'n_tokens_mistral': 1282, 'n_tokens_neox': 1145, 'n_words': 228, 'path': 'ParteI_Estatistica/Visualizing_transformations.ipynb', 'repo_name': 'UERJ-FISICA/ML4PPGF_UERJ', 'size': '2703'}