728x90
A lone wanderer stands at the center of a vast, nocturnal plain. Its contours are hidden by a silent darkness, except for the vague impression that it might be slightly elevated around the center—an unproven presumption whispered in the void. You venture forward, stumble upon a single cryptic marker, and measure its height with an unreliable device. The reading is shrouded in uncertainty, like a faint echo lost in a howling wind. Yet from these fragments—a shaky prior faith in gentle symmetry and a single uncertain clue—you forge a new conviction about the nighted expanse, refining the shapes lurking beyond your lantern’s glow.
Tasks:
1. Sketch the Prior
Visualize a smooth, ominous dome centered in the darkness.
2. Incorporate the Observation
Mark the lone measurement at some point in the gloom, acknowledging the device’s unsteady trustworthiness.
3. Form the Posterior
Merge your original assumption with this ambiguous scrap of evidence, sharpening (or barely shifting) your vision of the unseen land.
4. Reflect on Uncertainty (sigma)
Show how the confidence of your instrument (or lack thereof) distorts or clarifies the newly formed picture.
python code
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-10, 10, 1000)
prior_mean = 0
prior_sigma = 3
prior = (1 / (np.sqrt(2 * np.pi) * prior_sigma)) * np.exp(-(x - prior_mean)**2 / (2 * prior_sigma**2))
obs_mean = 2
obs_sigma = 2
likelihood = (1 / (np.sqrt(2 * np.pi) * obs_sigma)) * np.exp(-(x - obs_mean)**2 / (2 * obs_sigma**2))
posterior = prior * likelihood
posterior /= np.trapz(posterior, x)
plt.figure(figsize=(12, 8))
plt.subplot(3, 1, 1)
plt.plot(x, prior, label="Prior (Smooth Dome)", color="blue")
plt.title("Prior: Initial Assumption")
plt.xlabel("Position")
plt.ylabel("Probability Density")
plt.legend()
plt.subplot(3, 1, 2)
plt.plot(x, likelihood, label="Likelihood (Observation with Uncertainty)", color="orange")
plt.title("Likelihood: Measurement with Instrument Uncertainty")
plt.xlabel("Position")
plt.ylabel("Probability Density")
plt.legend()
plt.subplot(3, 1, 3)
plt.plot(x, posterior, label="Posterior (Updated Belief)", color="green")
plt.title("Posterior: Combined Belief After Observation")
plt.xlabel("Position")
plt.ylabel("Probability Density")
plt.legend()
plt.tight_layout()
plt.show()
728x90
'수학(Curiosity)' 카테고리의 다른 글
The Magic of e^x: A Function That Is Its Own Derivative (0) | 2025.01.11 |
---|---|
gan Nash equilibrium (0) | 2025.01.08 |
Math Problem Navigating the Celestial Labyrinth (1) | 2025.01.05 |
testing testing (0) | 2025.01.05 |
풀다가 너무 재미있어서 가져온 문제 냥 (0) | 2025.01.04 |