Created
March 30, 2024 18:23
-
-
Save zinzinzibidi/ceed1009e7dab78c1e22da0dd93c0f57 to your computer and use it in GitHub Desktop.
Python ile Hipotez Testi
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
from scipy.stats import t | |
def t_test(sample_mean, population_mean, std_dev, n): | |
# t değerini hesaplama | |
t_score = (sample_mean - population_mean) / (std_dev / (n ** 0.5)) | |
# p-değeri hesaplamak için t'nin iki taraflı testini kullanma | |
p_value = t.sf(abs(t_score), df=n - 1) * 2 # df = serbestlik derecesi | |
# Sonuçları yazdırma | |
print(f"t skoru: {t_score}") | |
print(f"p-değeri: {p_value}") | |
# Sıfır hipotezinin kabul edilip edilmediğini kontrol etme | |
if p_value < 0.05: | |
print("Sıfır hipotezi reddedildi: Fırında üretilen tüm ekmeklerin ağırlığı 200 gramdan farklıdır.") | |
else: | |
print( | |
"Sıfır hipotezi kabul edildi: Fırında üretilen tüm ekmeklerin ağırlığı istatistiksel olarak anlamlı bir şekilde 200 gramdan farklı değildir.") | |
# Fonksiyonu verilen değerlerle çağırma | |
t_test(196, 200, 8, 24) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment