Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Notebook 3: Credibility dynamics (toy stock)

from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt

plt.style.use("dark_background")

cred = 0.5
claim = 0.6
proof = 0.55
hist = []
for t in range(60):
    # overclaim hurts; proof helps; mean reversion
    delta = 0.05 * (proof - claim) + 0.01 * (0.5 - cred)
    cred = float(np.clip(cred + delta, 0.0, 1.0))
    hist.append((t, cred))

# shock: scandal at t=40
cred2 = 0.5
hist2 = []
for t in range(60):
    if t == 40:
        cred2 *= 0.4
    delta = 0.05 * (proof - claim) + 0.01 * (0.5 - cred2)
    cred2 = float(np.clip(cred2 + delta, 0.0, 1.0))
    hist2.append((t, cred2))

fig, ax = plt.subplots()
ax.plot([h[0] for h in hist], [h[1] for h in hist], label="baseline")
ax.plot([h[0] for h in hist2], [h[1] for h in hist2], label="shock at t=40")
ax.legend()
ax.set_xlabel("day")
ax.set_ylabel("credibility")
plt.show()