Lineare Regression
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import os
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
df = pd.read_csv('/home/pi/Documents/Code/Python/ProgrammierungUndDatenanalyse/Sonstiges/STAT2/vl3-standardfehler.csv')
|
||||
# location will help to open files in the same directory as the py-script
|
||||
__location__ = os.path.realpath(
|
||||
os.path.join(os.getcwd(), os.path.dirname(__file__)))
|
||||
|
||||
df = pd.read_csv(os.path.join(__location__, 'vl3-standardfehler.csv'))
|
||||
|
||||
# Dataframe
|
||||
print(df)
|
||||
@@ -27,14 +32,28 @@ for index, row in df.iterrows():
|
||||
summeQuadrierteAbweichungen = summeQuadrierteAbweichungen + (row.freq * (row.x - mean)**2)
|
||||
print(row['x'], row['freq'], 'summe²abweichungen: ', summeQuadrierteAbweichungen)
|
||||
variance = variancePart1 * summeQuadrierteAbweichungen
|
||||
print("variance: ", variance)
|
||||
print("pop variance: ", variance)
|
||||
|
||||
# √(^σ²)
|
||||
standardDev = variance**(1/2) # √n = n^1/2
|
||||
print("Standardabweichung: ", standardDev)
|
||||
print("pop Standardabweichung: ", standardDev)
|
||||
|
||||
# √(ŝd / freq)
|
||||
standardfehler = standardDev / sums.freq**(1/2) # √n = n^1/2
|
||||
print("Standardfehler des Mittelwerts: ", standardfehler)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# "Bonus":
|
||||
|
||||
# Mittelwertsverteilung bei 2 Würfeln
|
||||
print()
|
||||
import random
|
||||
|
||||
Reference in New Issue
Block a user