Skip to content

Instantly share code, notes, and snippets.

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 zinzinzibidi/211604cea82efb254cf797fc5cc910e8 to your computer and use it in GitHub Desktop.
Save zinzinzibidi/211604cea82efb254cf797fc5cc910e8 to your computer and use it in GitHub Desktop.
Python ile Standart Normal Dağılım Grafiği
# Kütüphaneleri import ediyoruz.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
# Veri setimizi okutuyoruz ve sütun başlığını "boy-uzunluklari" olarak belirliyoruz.
data = pd.read_csv('boy-uzunluklari.csv', header=None, names=['boy-uzunluklari'])
# Veriyi standartize ediyoruz.
mean = data['boy-uzunluklari'].mean()
std = data['boy-uzunluklari'].std()
data['standardized'] = (data['boy-uzunluklari'] - mean) / std
# Standart normal dağılım grafiğini çiziyoruz.
plt.figure(figsize=(10, 6))
count, bins, ignored = plt.hist(data['standardized'], bins=30, density=True, alpha=0.6, color='#0A64A0', edgecolor='black')
# Grafiği en uygun hâle getiriyoruz.
xmin, xmax = plt.xlim()
x = np.linspace(xmin, xmax, 100)
p = norm.pdf(x, 0, 1) # ortalama = 0, sp = 1
plt.plot(x, p, 'k', linewidth=2)
# Başlıkları ve eksen adlarını belirliyoruz.
title = "Boy Uzunlukları (Standart Normal Dağılım Grafiği)"
plt.title(title)
plt.xlabel('Standartize Edilmiş Boy Uzunlukları')
plt.ylabel('Yoğunluk')
# Grafiğin çıktısını alıyoruz.
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment