Last active
March 3, 2024 13:10
-
-
Save zinzinzibidi/211604cea82efb254cf797fc5cc910e8 to your computer and use it in GitHub Desktop.
Python ile Standart Normal Dağılım Grafiği
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
# 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