Skip to content

Instantly share code, notes, and snippets.

@Wizmann
Created March 10, 2013 15:10
Show Gist options
  • Save Wizmann/5128933 to your computer and use it in GitHub Desktop.
Save Wizmann/5128933 to your computer and use it in GitHub Desktop.
KDE with ``numpy``, ``scipy`` und ``matplotlib``
#coding=utf-8
import sys,re,os
import numpy as np
from scipy import stats
import matplotlib.pylab as plt
def draw_kde(grade):
gkde = stats.kde.gaussian_kde(grade)
ind = np.arange(0.,100.,0.01)
plt.plot(ind, gkde(ind), label='Gods\' Grade', color="g")
plt.title('Kernel Density Estimation')
plt.legend()
plt.show()
if __name__ == '__main__':
with open("grade.txt") as grade_list:
grade = [float(line.split("\t")[1]) for line in grade_list]
draw_kde(grade)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment