Created
November 30, 2023 13:25
-
-
Save neelabalan/309f2669175c3490440af2758246333b to your computer and use it in GitHub Desktop.
Post log transformation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# Generating a right-skewed data distribution | |
data = np.random.exponential(scale=2, size=1000) | |
# Performing log transformation | |
log_transformed_data = np.log(data + 1) # Adding 1 to avoid log(0) issue | |
# Plotting both distributions for comparison | |
plt.figure(figsize=(12, 6)) | |
# Original data plot | |
plt.subplot(1, 2, 1) | |
sns.histplot(data, kde=True) | |
plt.title('Original Right-Skewed Data') | |
# Log-transformed data plot | |
plt.subplot(1, 2, 2) | |
sns.histplot(log_transformed_data, kde=True, color='orange') | |
plt.title('Log-Transformed Data') | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment