Skip to content

Instantly share code, notes, and snippets.

@momijiame
Created January 3, 2017 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save momijiame/c4be9601430c267d4dae9b9f8b0418d6 to your computer and use it in GitHub Desktop.
Save momijiame/c4be9601430c267d4dae9b9f8b0418d6 to your computer and use it in GitHub Desktop.
t 分布
#!/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