Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Creating Gaussian Plot Function
- def gaussianPlotter(vector):
- """
- Calculates and plots a Gaussian Probability Density Function (PDF)
- Parameters
- ----------
- vector : array-like, shape (n_samples, n_features)
- Returns
- -------
- output : matplotlib plt.plot()
- """
- mean = vector.mean()
- std_dev = vector.std()
- normal_pdf = (1/np.sqrt(2*np.pi*std_dev**2))*np.exp(-((vector.sort_values() - mean)**2)/(2*std_dev**2))
- plt.plot(vector.sort_values(), normal_pdf, color= 'red', label= 'Normal PDF')
- # Creates the figure, title, and labels
- # Plots a Frequency distribution along w/ a Kernel Density Estimate
- plt.figure(figsize= (10,5))
- ## Gaussian Kernel is used to estimate a Gaussian PDF
- sns.distplot(features_DSH, bins= 10, kde= True, color= '#1f77b4',
- kde_kws= {'kernel': 'gau', 'label': 'KDE: Estimated PDF',
- 'color': 'black', 'lw': 3})
- ## Gaussian PDF plotting function
- gaussianPlotter(features_DSH)
- ## Plot Labels
- plt.title('Frequency & Probability Distribution of Study Times');
- plt.ylabel('Kernel Density Estimate');
- plt.xlim(25, 71)
- plt.legend(loc= 'best')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement