Created
January 3, 2017 11:39
-
-
Save momijiame/c4be9601430c267d4dae9b9f8b0418d6 to your computer and use it in GitHub Desktop.
t 分布
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
from scipy import stats | |
from matplotlib import pyplot as plt | |
def main(): | |
x = np.arange(-4, 4.1, 0.1) | |
# 標準正規分布 | |
y = np.exp(-x ** 2 / 2) / np.sqrt(2 * np.pi) | |
plt.plot(x, y, label='N(0,1)') | |
# 自由度 1, 2 の t 分布 | |
for df in range(1, 2 + 1): | |
y = stats.t.pdf(x, df) | |
plt.plot(x, y, label='t({})'.format(df)) | |
plt.ylim(0, 0.5) | |
plt.xlim(-4, 4) | |
plt.legend() | |
plt.show() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment