Kursinhalt
Grundlagen der Wahrscheinlichkeitstheorie
Grundlagen der Wahrscheinlichkeitstheorie
1. Grundlagen der Wahrscheinlichkeitstheorie
2. Wahrscheinlichkeit Komplexer Ereignisse
4. Häufig Verwendete Kontinuierliche Verteilungen
5. Kovarianz und Korrelation
Was Ist Korrelation?
Korrelation ist ein statistisches Maß, das die Beziehung zwischen zwei Variablen quantifiziert. Es wird als skalierte Kovariation bestimmt und aufgrund dieser Skalierung können wir die Stärke der Abhängigkeiten zusätzlich zu ihrer Richtung ermitteln.
Die Korrelation liegt im Bereich von -1
bis 1
, wobei:
- Wenn die Korrelation
+1
beträgt, haben die Werte eine perfekte positive lineare Beziehung. Wenn eine Variable zunimmt, nimmt die andere proportional zu; - Wenn die Korrelation
-1
beträgt, haben die Werte eine perfekte negative lineare Beziehung. Wenn eine Variable zunimmt, nimmt die andere proportional ab; - Wenn der Korrelationskoeffizient nahe
0
liegt, besteht keine lineare Beziehung zwischen den Variablen.
Um die Korrelation zu berechnen, können wir die gleichen Schritte wie bei der Berechnung der Kovarianz anwenden und np.corrcoef(x, y)[0, 1]
verwenden.
import matplotlib.pyplot as plt import numpy as np # Create a figure with three subplots fig, axes = plt.subplots(1, 3) fig.set_size_inches(10, 5) # Positive linear dependence x = np.random.rand(100) * 10 # Generate random x values y = x + np.random.randn(100) # Generate y values with added noise axes[0].scatter(x, y) # Scatter plot of x and y axes[0].set_title('Correlation is '+ str(round(np.corrcoef(x, y)[0, 1], 3) )) # Set title with correlation coefficient # Negative linear dependence x = np.random.rand(100) * 10 # Generate random x values y = -x + np.random.randn(100) # Generate y values with added noise axes[1].scatter(x, y) # Scatter plot of x and y axes[1].set_title('Correlation is '+ str(round(np.corrcoef(x, y)[0, 1], 3) )) # Set title with correlation coefficient # Independent np.random.seed(0) # Set random seed for reproducibility x = np.random.rand(200) # Generate random x values y = np.random.rand(200) # Generate random y values axes[2].scatter(x, y) # Scatter plot of x and y axes[2].set_title('Correlation is '+ str(round(np.corrcoef(x, y)[0, 1], 3) )) # Set title with correlation coefficient plt.show() # Display the plot
War alles klar?
Danke für Ihr Feedback!
Abschnitt 5. Kapitel 2