initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
mu = 3.5
|
||||
sigmas = [0.1, 0.3]
|
||||
size = 100000
|
||||
rng = np.random.default_rng(42)
|
||||
|
||||
fig, axes = plt.subplots(1, 2, figsize=(16, 6))
|
||||
|
||||
for sigma in sigmas:
|
||||
samples = rng.lognormal(mean=mu, sigma=sigma, size=size)
|
||||
|
||||
# lognormal → normal 변환
|
||||
log_samples = np.log(samples)
|
||||
|
||||
# Lognormal 플롯
|
||||
axes[0].hist(samples, bins=200, density=True, alpha=0.5, label=f"sigma={sigma}")
|
||||
axes[0].set_xlim(0, 200)
|
||||
axes[0].set_title("Lognormal Distribution")
|
||||
axes[0].set_xlabel("Weight")
|
||||
axes[0].set_ylabel("Density")
|
||||
axes[0].legend()
|
||||
|
||||
# Normal 플롯
|
||||
axes[1].hist(log_samples, bins=200, density=True, alpha=0.5, label=f"sigma={sigma}")
|
||||
axes[1].set_title("log(samples) → Normal Distribution")
|
||||
axes[1].set_xlabel("log(Weight)")
|
||||
axes[1].set_ylabel("Density")
|
||||
axes[1].legend()
|
||||
|
||||
plt.suptitle("Lognormal vs Normal (μ fixed)")
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user