add llm chapter
This commit is contained in:
parent
bd30888c3f
commit
ce17502029
@ -8,11 +8,14 @@ import matplotlib.pyplot as plt
|
|||||||
import matplotlib
|
import matplotlib
|
||||||
matplotlib.use('TkAgg')
|
matplotlib.use('TkAgg')
|
||||||
|
|
||||||
JAVA_INPUT = './data/try_Java_Jan_2022_last_revision.boa.output.txt'
|
# Input Pfade
|
||||||
PYTHON_INPUT = './data/try_Python_Feb_2022_last_revision.boa.output.txt'
|
JAVA_INPUT = './boa-output/try_Java_Jan_2022_last_revision.boa.output.txt'
|
||||||
|
PYTHON_INPUT = './boa-output/try_Python_Feb_2022_last_revision.boa.output.txt'
|
||||||
|
|
||||||
SHOW_PLOTS = False
|
# Konfiguration von read_sample
|
||||||
SEED = 3
|
SEED = 1
|
||||||
|
SHOW_PLOTS = True
|
||||||
|
SAMPLES = 1000
|
||||||
|
|
||||||
def read_sample(file_path, title='', sample_size=0, show=True):
|
def read_sample(file_path, title='', sample_size=0, show=True):
|
||||||
# filename kann auch ein URL sein: "https://..../example.csv"
|
# filename kann auch ein URL sein: "https://..../example.csv"
|
||||||
@ -50,12 +53,11 @@ def cohen_d(x, y):
|
|||||||
# Stichprobengrößen der Gruppen
|
# Stichprobengrößen der Gruppen
|
||||||
size_x, size_y = len(x), len(y)
|
size_x, size_y = len(x), len(y)
|
||||||
|
|
||||||
# Gepoolte Varianz und Standardabweichung
|
# Gepoolte Standardabweichung
|
||||||
pool_var = ((size_x - 1) * var_x + (size_y - 1) * var_y) / (size_x + size_y - 2)
|
pool_std = math.sqrt(((size_x - 1) * var_x + (size_y - 1) * var_y) / (size_x + size_y - 2))
|
||||||
pool_var = math.sqrt(pool_var)
|
|
||||||
|
|
||||||
# Cohen's d
|
# Cohen's d
|
||||||
d_val = mean_diff / pool_var
|
d_val = mean_diff / pool_std
|
||||||
return d_val
|
return d_val
|
||||||
|
|
||||||
def find_barrier(x_sample_path, y_sample_path, alpha=0.1, lower_limit=2, upper_limit=10000):
|
def find_barrier(x_sample_path, y_sample_path, alpha=0.1, lower_limit=2, upper_limit=10000):
|
||||||
@ -95,12 +97,12 @@ def main():
|
|||||||
print('Statistische Berechnungen zu Häufigkeiten (Übung 5)')
|
print('Statistische Berechnungen zu Häufigkeiten (Übung 5)')
|
||||||
|
|
||||||
print('\nEinlesen der ersten Stichprobe (Python)')
|
print('\nEinlesen der ersten Stichprobe (Python)')
|
||||||
python_sample = read_sample(PYTHON_INPUT, sample_size=1000, show=SHOW_PLOTS, title="Python")
|
python_sample = read_sample(PYTHON_INPUT, sample_size=SAMPLES, show=SHOW_PLOTS, title="Python")
|
||||||
print('Mean:' + str(python_sample['Ratio'].mean()))
|
print('Mean:' + str(python_sample['Ratio'].mean()))
|
||||||
print('Variance:' + str(python_sample['Ratio'].var()))
|
print('Variance:' + str(python_sample['Ratio'].var()))
|
||||||
|
|
||||||
print('\nEinlesen der zweiten Stichprobe (Java)')
|
print('\nEinlesen der zweiten Stichprobe (Java)')
|
||||||
java_sample = read_sample(JAVA_INPUT, sample_size=1000, show=SHOW_PLOTS, title="Java")
|
java_sample = read_sample(JAVA_INPUT, sample_size=SAMPLES, show=SHOW_PLOTS, title="Java")
|
||||||
print('Mean:' + str(java_sample['Ratio'].mean()))
|
print('Mean:' + str(java_sample['Ratio'].mean()))
|
||||||
print('Variance:' + str(java_sample['Ratio'].var()))
|
print('Variance:' + str(java_sample['Ratio'].var()))
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import random
|
|
||||||
|
|
||||||
random.seed(1)
|
|
||||||
print(random.randint(0, 10))
|
|
||||||
print(random.randint(0, 10))
|
|
||||||
print(random.randint(0, 10))
|
|
||||||
print(random.randint(0, 10))
|
|
||||||
print(random.randint(0, 10))
|
|
||||||
print(random.randint(0, 10))
|
|
@ -1,5 +1,5 @@
|
|||||||
# Java-Job: 111005
|
# Java-Job: 111839
|
||||||
# Python-Job: 111006
|
# Python-Job: 111840
|
||||||
|
|
||||||
# Includes all revisions
|
# Includes all revisions
|
||||||
p: Project = input;
|
p: Project = input;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Java-Job: 111694
|
# Java-Job: Throws empty error on the "2022 Jan/Java" dataset.
|
||||||
# Python-Job: 111439
|
# Python-Job: 111838
|
||||||
|
|
||||||
# Includes all revisions
|
# Includes all revisions
|
||||||
p: Project = input;
|
p: Project = input;
|
||||||
@ -12,7 +12,7 @@ cur_date: time;
|
|||||||
|
|
||||||
statement_counter := visitor {
|
statement_counter := visitor {
|
||||||
before node: Statement -> {
|
before node: Statement -> {
|
||||||
if (def(node.kind) and (node.kind == StatementKind.TRY or node.kind == StatementKind.WITH))
|
if (node.kind == StatementKind.TRY or node.kind == StatementKind.WITH)
|
||||||
relative_list[p.name][yearof(cur_date)] << 1;
|
relative_list[p.name][yearof(cur_date)] << 1;
|
||||||
else
|
else
|
||||||
relative_list[p.name][yearof(cur_date)] << 0;
|
relative_list[p.name][yearof(cur_date)] << 0;
|
||||||
@ -21,8 +21,8 @@ statement_counter := visitor {
|
|||||||
|
|
||||||
visit(p, visitor {
|
visit(p, visitor {
|
||||||
before node: CodeRepository -> {
|
before node: CodeRepository -> {
|
||||||
for (minus_year: int=22; minus_year >= 0; minus_year--) {
|
for (minus_year: int=19; minus_year >= 0; minus_year--) {
|
||||||
cur_date = addyear(T"Dec 31, 2022, 10:00:00 AM", -minus_year);
|
cur_date = addyear(T"Dec 31, 2019, 10:00:00 AM", -minus_year);
|
||||||
snapshot := getsnapshot(node, cur_date);
|
snapshot := getsnapshot(node, cur_date);
|
||||||
|
|
||||||
foreach (i: int; def(snapshot[i]))
|
foreach (i: int; def(snapshot[i]))
|
||||||
|
8
llm/.idea/.gitignore
vendored
Normal file
8
llm/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
12
llm/.idea/cohens-d.iml
Normal file
12
llm/.idea/cohens-d.iml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.13" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="GOOGLE" />
|
||||||
|
<option name="myDocStringFormat" value="Google" />
|
||||||
|
</component>
|
||||||
|
</module>
|
12
llm/.idea/inspectionProfiles/Project_Default.xml
Normal file
12
llm/.idea/inspectionProfiles/Project_Default.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="N802" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
6
llm/.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
llm/.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
7
llm/.idea/misc.xml
Normal file
7
llm/.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.13" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
llm/.idea/modules.xml
Normal file
8
llm/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/cohens-d.iml" filepath="$PROJECT_DIR$/.idea/cohens-d.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
llm/.idea/vcs.xml
Normal file
6
llm/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
74
llm/cohens-output/chatgpt.txt
Normal file
74
llm/cohens-output/chatgpt.txt
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
CHATGPT
|
||||||
|
|
||||||
|
Cohen's \(d\) ist ein Effektstärkemaß, das die standardisierte Differenz zwischen zwei Mittelwerten angibt. Es wird häufig verwendet, um die Größe eines Effekts zu bewerten, insbesondere in statistischen Hypothesentests.
|
||||||
|
|
||||||
|
Hier ist eine Anleitung zur Berechnung von Cohen's \(d\) in Python:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Formel für Cohen's \(d\):
|
||||||
|
\[
|
||||||
|
d = \frac{M_1 - M_2}{SD_{\text{pooled}}}
|
||||||
|
\]
|
||||||
|
- \(M_1, M_2\): Mittelwerte der beiden Gruppen
|
||||||
|
- \(SD_{\text{pooled}} = \sqrt{\frac{(n_1 - 1) \cdot SD_1^2 + (n_2 - 1) \cdot SD_2^2}{n_1 + n_2 - 2}}\): Gepoolte Standardabweichung
|
||||||
|
- \(n_1, n_2\): Stichprobengrößen der beiden Gruppen
|
||||||
|
- \(SD_1, SD_2\): Standardabweichungen der beiden Gruppen
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Python-Code:
|
||||||
|
Hier ein Beispiel, wie man Cohen's \(d\) berechnen kann:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def cohens_d(group1, group2):
|
||||||
|
# Mittelwerte der beiden Gruppen
|
||||||
|
mean1, mean2 = np.mean(group1), np.mean(group2)
|
||||||
|
|
||||||
|
# Standardabweichungen der beiden Gruppen
|
||||||
|
std1, std2 = np.std(group1, ddof=1), np.std(group2, ddof=1)
|
||||||
|
|
||||||
|
# Stichprobengrößen
|
||||||
|
n1, n2 = len(group1), len(group2)
|
||||||
|
|
||||||
|
# Gepoolte Standardabweichung
|
||||||
|
pooled_std = np.sqrt(((n1 - 1) * std1**2 + (n2 - 1) * std2**2) / (n1 + n2 - 2))
|
||||||
|
|
||||||
|
# Cohen's d
|
||||||
|
d = (mean1 - mean2) / pooled_std
|
||||||
|
return d
|
||||||
|
|
||||||
|
# Beispiel-Daten
|
||||||
|
gruppe1 = [2, 4, 6, 8, 10]
|
||||||
|
gruppe2 = [3, 5, 7, 9, 11]
|
||||||
|
|
||||||
|
# Berechnung
|
||||||
|
ergebnis = cohens_d(gruppe1, gruppe2)
|
||||||
|
print(f"Cohen's d: {ergebnis}")
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Erläuterung:
|
||||||
|
1. **Daten vorbereiten**: Die beiden Gruppen können als Listen oder numpy-Arrays übergeben werden.
|
||||||
|
2. **Standardabweichung und Mittelwert berechnen**: Mit numpy's Funktionen (`np.mean` und `np.std`).
|
||||||
|
3. **Gepoolte Standardabweichung**: Eine gewichtete Mischung der Varianzen.
|
||||||
|
4. **Berechnung von \(d\)**: Differenz der Mittelwerte geteilt durch die gepoolte Standardabweichung.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Beispiel-Ausgabe:
|
||||||
|
Angenommen, die Gruppen sind:
|
||||||
|
- Gruppe 1: [2, 4, 6, 8, 10]
|
||||||
|
- Gruppe 2: [3, 5, 7, 9, 11]
|
||||||
|
|
||||||
|
Die Ausgabe wäre:
|
||||||
|
```
|
||||||
|
Cohen's d: -0.22360679774997896
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Falls du weitere Anpassungen oder Optimierungen benötigst, lass es mich wissen!
|
54
llm/cohens-output/claude.txt
Normal file
54
llm/cohens-output/claude.txt
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
CLAUDE
|
||||||
|
|
||||||
|
Here's a Python function to calculate Cohen's d:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def cohens_d(group1, group2):
|
||||||
|
"""
|
||||||
|
Calculate Cohen's d effect size between two groups.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
group1 (array-like): First group of values
|
||||||
|
group2 (array-like): Second group of values
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
float: Cohen's d value
|
||||||
|
"""
|
||||||
|
# Convert to numpy arrays
|
||||||
|
group1 = np.array(group1)
|
||||||
|
group2 = np.array(group2)
|
||||||
|
|
||||||
|
# Calculate means
|
||||||
|
mean1 = np.mean(group1)
|
||||||
|
mean2 = np.mean(group2)
|
||||||
|
|
||||||
|
# Calculate pooled standard deviation
|
||||||
|
n1, n2 = len(group1), len(group2)
|
||||||
|
var1, var2 = np.var(group1, ddof=1), np.var(group2, ddof=1)
|
||||||
|
|
||||||
|
pooled_sd = np.sqrt(((n1 - 1) * var1 + (n2 - 1) * var2) / (n1 + n2 - 2))
|
||||||
|
|
||||||
|
# Calculate Cohen's d
|
||||||
|
d = (mean2 - mean1) / pooled_sd
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
|
# Example usage
|
||||||
|
# group1 = [1, 2, 3, 4, 5]
|
||||||
|
# group2 = [3, 4, 5, 6, 7]
|
||||||
|
# effect_size = cohens_d(group1, group2)
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Key points:
|
||||||
|
- Uses pooled standard deviation
|
||||||
|
- Works with numpy arrays
|
||||||
|
- Handles different group sizes
|
||||||
|
- Returns effect size magnitude and direction
|
||||||
|
|
||||||
|
Interpretation:
|
||||||
|
- |d| < 0.2: Small effect
|
||||||
|
- 0.2 ≤ |d| < 0.5: Medium effect
|
||||||
|
- |d| ≥ 0.5: Large effect
|
58
llm/cohens-output/deepseek.txt
Normal file
58
llm/cohens-output/deepseek.txt
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
DEEPSEEK
|
||||||
|
|
||||||
|
Cohen's d ist ein Maß für die Effektstärke und wird häufig verwendet, um die standardisierte Differenz zwischen zwei Mittelwerten zu berechnen. Um Cohen's d in Python zu berechnen, kannst du die folgende Formel verwenden:
|
||||||
|
|
||||||
|
\[ d = \frac{\bar{X}_1 - \bar{X}_2}{s} \]
|
||||||
|
|
||||||
|
wobei:
|
||||||
|
- \(\bar{X}_1\) und \(\bar{X}_2\) die Mittelwerte der beiden Gruppen sind,
|
||||||
|
- \(s\) die gepoolte Standardabweichung ist.
|
||||||
|
|
||||||
|
Die gepoolte Standardabweichung \(s\) wird wie folgt berechnet:
|
||||||
|
|
||||||
|
\[ s = \sqrt{\frac{(n_1 - 1) \cdot s_1^2 + (n_2 - 1) \cdot s_2^2}{n_1 + n_2 - 2}} \]
|
||||||
|
|
||||||
|
wobei:
|
||||||
|
- \(n_1\) und \(n_2\) die Stichprobengrößen der beiden Gruppen sind,
|
||||||
|
- \(s_1^2\) und \(s_2^2\) die Varianzen der beiden Gruppen sind.
|
||||||
|
|
||||||
|
Hier ist ein Beispiel, wie du Cohen's d in Python berechnen kannst:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def cohens_d(group1, group2):
|
||||||
|
# Mittelwerte berechnen
|
||||||
|
mean1, mean2 = np.mean(group1), np.mean(group2)
|
||||||
|
|
||||||
|
# Varianzen berechnen
|
||||||
|
var1, var2 = np.var(group1, ddof=1), np.var(group2, ddof=1)
|
||||||
|
|
||||||
|
# Stichprobengrößen
|
||||||
|
n1, n2 = len(group1), len(group2)
|
||||||
|
|
||||||
|
# Gepoolte Standardabweichung berechnen
|
||||||
|
pooled_std = np.sqrt(((n1 - 1) * var1 + (n2 - 1) * var2) / (n1 + n2 - 2))
|
||||||
|
|
||||||
|
# Cohen's d berechnen
|
||||||
|
d = (mean1 - mean2) / pooled_std
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
|
# Beispiel-Daten
|
||||||
|
group1 = [1, 2, 3, 4, 5]
|
||||||
|
group2 = [2, 3, 4, 5, 6]
|
||||||
|
|
||||||
|
# Cohen's d berechnen
|
||||||
|
d = cohens_d(group1, group2)
|
||||||
|
print(f"Cohen's d: {d}")
|
||||||
|
```
|
||||||
|
|
||||||
|
In diesem Beispiel wird die Funktion `cohens_d` verwendet, um Cohen's d für zwei Gruppen von Daten zu berechnen. Die Funktion berechnet die Mittelwerte, Varianzen und die gepoolte Standardabweichung und gibt dann Cohen's d zurück.
|
||||||
|
|
||||||
|
### Interpretation von Cohen's d:
|
||||||
|
- **d ≈ 0.2**: Kleiner Effekt
|
||||||
|
- **d ≈ 0.5**: Mittlerer Effekt
|
||||||
|
- **d ≈ 0.8**: Großer Effekt
|
||||||
|
|
||||||
|
Diese Werte sind Richtlinien und können je nach Kontext variieren.
|
93
llm/cohens-output/gemini.txt
Normal file
93
llm/cohens-output/gemini.txt
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
GEMINI
|
||||||
|
|
||||||
|
## Berechnung von Cohen's d in Python: Eine Schritt-für-Schritt-Anleitung
|
||||||
|
|
||||||
|
**Cohen's d** ist ein Maß für die Effektstärke, das häufig in der Statistik verwendet wird, um die Größe eines Unterschieds zwischen zwei Gruppen zu quantifizieren. In Python können wir diese Berechnung recht einfach mit Hilfe von Bibliotheken wie NumPy und SciPy durchführen.
|
||||||
|
|
||||||
|
### 1. Installation der notwendigen Bibliotheken
|
||||||
|
Falls du NumPy und SciPy noch nicht installiert hast, kannst du dies über pip tun:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install numpy scipy
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Importieren der Bibliotheken
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
from scipy import stats
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Berechnen von Cohen's d
|
||||||
|
Die Formel für Cohen's d lautet:
|
||||||
|
|
||||||
|
```
|
||||||
|
d = (M1 - M2) / s_pooled
|
||||||
|
```
|
||||||
|
|
||||||
|
wobei:
|
||||||
|
* M1 und M2 die Mittelwerte der beiden Gruppen sind
|
||||||
|
* s_pooled die gepoolte Standardabweichung ist
|
||||||
|
|
||||||
|
Hier ist eine Python-Funktion, die Cohen's d berechnet:
|
||||||
|
|
||||||
|
```python
|
||||||
|
def cohen_d(x, y):
|
||||||
|
"""Calculates Cohen's d for independent samples.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
x: The first sample.
|
||||||
|
y: The second sample.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Cohen's d.
|
||||||
|
"""
|
||||||
|
|
||||||
|
nx = len(x)
|
||||||
|
ny = len(y)
|
||||||
|
dof = nx + ny - 2
|
||||||
|
|
||||||
|
# Calculate the pooled standard deviation
|
||||||
|
sx = np.std(x, ddof=1)
|
||||||
|
sy = np.std(y, ddof=1)
|
||||||
|
s_pooled = np.sqrt(((nx-1)*sx**2 + (ny-1)*sy**2) / dof)
|
||||||
|
|
||||||
|
# Calculate Cohen's d
|
||||||
|
d = (np.mean(x) - np.mean(y)) / s_pooled
|
||||||
|
|
||||||
|
return d
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Beispiel
|
||||||
|
```python
|
||||||
|
# Erstelle zwei Beispiel-Datensätze
|
||||||
|
group1 = [1, 2, 3, 4, 5]
|
||||||
|
group2 = [6, 7, 8, 9, 10]
|
||||||
|
|
||||||
|
# Berechne Cohen's d
|
||||||
|
d = cohen_d(group1, group2)
|
||||||
|
print("Cohen's d:", d)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Interpretation von Cohen's d:**
|
||||||
|
* |d| < 0.2: Sehr kleiner Effekt
|
||||||
|
* 0.2 ≤ |d| < 0.5: Kleiner bis mittlerer Effekt
|
||||||
|
* 0.5 ≤ |d| < 0.8: Mittlerer bis großer Effekt
|
||||||
|
* |d| ≥ 0.8: Sehr großer Effekt
|
||||||
|
|
||||||
|
**Wichtiger Hinweis:**
|
||||||
|
* **Unabhängige Stichproben:** Die obige Funktion ist für unabhängige Stichproben konzipiert. Für abhängige Stichproben (z.B. bei wiederholten Messungen) gibt es eine leicht abgewandelte Formel.
|
||||||
|
* **Normalverteilung:** Cohen's d setzt normalerweise eine annähernd normale Verteilung der Daten voraus.
|
||||||
|
* **Ausreißer:** Ausreißer können die Berechnung von Cohen's d stark beeinflussen. Es ist ratsam, die Daten vor der Berechnung auf Ausreißer zu überprüfen.
|
||||||
|
|
||||||
|
**Zusätzliche Funktionen in Bibliotheken:**
|
||||||
|
Einige Python-Bibliotheken wie `pingouin` bieten bereits eingebaute Funktionen für die Berechnung von Effektstärken wie Cohen's d an und können zusätzliche Statistiken berechnen.
|
||||||
|
|
||||||
|
**Weitere Überlegungen:**
|
||||||
|
* **Effektgröße:** Cohen's d ist nur eine von vielen Effektstärken. Die Wahl der geeigneten Effektstärke hängt von der Forschungsfrage und den Daten ab.
|
||||||
|
* **Konfidenzintervalle:** Es ist oft hilfreich, ein Konfidenzintervall für Cohen's d zu berechnen, um die Unsicherheit der Schätzung zu quantifizieren.
|
||||||
|
|
||||||
|
**Zusammenfassung:**
|
||||||
|
|
||||||
|
Mit dieser Anleitung und dem bereitgestellten Python-Code kannst du Cohen's d effektiv berechnen und interpretieren. Denk daran, die Voraussetzungen für die Anwendung von Cohen's d zu überprüfen und gegebenenfalls Anpassungen vorzunehmen.
|
||||||
|
|
||||||
|
**Möchtest du noch mehr über Cohen's d oder andere Effektstärken erfahren?**
|
40
llm/cohens-output/github_copilot.txt
Normal file
40
llm/cohens-output/github_copilot.txt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
GITHUB COPILOT
|
||||||
|
|
||||||
|
Cohen's d ist ein Maß für die Effektstärke, das den Unterschied zwischen zwei Mittelwerten in Standardabweichungseinheiten angibt. Hier ist ein Beispiel, wie man Cohen's d in Python berechnen kann:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def cohen_d(x, y):
|
||||||
|
# Berechnung der Mittelwerte der beiden Gruppen
|
||||||
|
mean_x = np.mean(x)
|
||||||
|
mean_y = np.mean(y)
|
||||||
|
|
||||||
|
# Berechnung der Standardabweichungen der beiden Gruppen
|
||||||
|
std_x = np.std(x, ddof=1)
|
||||||
|
std_y = np.std(y, ddof=1)
|
||||||
|
|
||||||
|
# Berechnung der gepoolten Standardabweichung
|
||||||
|
pooled_std = np.sqrt(((len(x) - 1) * std_x**2 + (len(y) - 1) * std_y**2) / (len(x) + len(y) - 2))
|
||||||
|
|
||||||
|
# Berechnung von Cohen's d
|
||||||
|
d = (mean_x - mean_y) / pooled_std
|
||||||
|
|
||||||
|
return d
|
||||||
|
|
||||||
|
# Beispielwerte für zwei Gruppen
|
||||||
|
group1 = [2.3, 3.1, 4.2, 5.0, 3.8]
|
||||||
|
group2 = [3.5, 4.1, 5.2, 6.0, 4.8]
|
||||||
|
|
||||||
|
# Berechnung von Cohen's d
|
||||||
|
d_value = cohen_d(group1, group2)
|
||||||
|
print(f"Cohen's d: {d_value:.2f}")
|
||||||
|
```
|
||||||
|
|
||||||
|
In diesem Beispiel:
|
||||||
|
|
||||||
|
1. Berechnen wir die Mittelwerte und Standardabweichungen der beiden Gruppen.
|
||||||
|
2. Berechnen wir die gepoolte Standardabweichung, die eine gewichtete Kombination der Standardabweichungen der beiden Gruppen ist.
|
||||||
|
3. Berechnen wir Cohen's d, indem wir die Differenz der Mittelwerte durch die gepoolte Standardabweichung teilen.
|
||||||
|
|
||||||
|
Wenn Sie dies ausführen, erhalten Sie den Wert von Cohen's d, der die Effektstärke zwischen den beiden Gruppen angibt.
|
46
llm/cohens-output/perplexity.txt
Normal file
46
llm/cohens-output/perplexity.txt
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
PERPLEXITY
|
||||||
|
|
||||||
|
Um Cohen's d in Python zu berechnen, können Sie die folgende Funktion verwenden:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def cohens_d(group1, group2):
|
||||||
|
# Berechnung der Mittelwerte der beiden Gruppen
|
||||||
|
mean1, mean2 = np.mean(group1), np.mean(group2)
|
||||||
|
|
||||||
|
# Berechnung der gepoolten Standardabweichung
|
||||||
|
n1, n2 = len(group1), len(group2)
|
||||||
|
std1, std2 = np.std(group1, ddof=1), np.std(group2, ddof=1)
|
||||||
|
pooled_std = np.sqrt(((n1 - 1) * std1**2 + (n2 - 1) * std2**2) / (n1 + n2 - 2))
|
||||||
|
|
||||||
|
# Berechnung von Cohen's d
|
||||||
|
d = (mean1 - mean2) / pooled_std
|
||||||
|
return d
|
||||||
|
```
|
||||||
|
|
||||||
|
Diese Funktion nimmt zwei Gruppen als Eingabe und gibt den berechneten Cohen's d-Wert zurück[3]. Sie können die Funktion wie folgt verwenden:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Beispieldaten für zwei Gruppen
|
||||||
|
group1 = np.array([5, 7, 9, 11, 13])
|
||||||
|
group2 = np.array([6, 8, 10, 12, 14])
|
||||||
|
|
||||||
|
# Berechnung von Cohen's d
|
||||||
|
effect_size = cohens_d(group1, group2)
|
||||||
|
print("Cohen's d:", effect_size)
|
||||||
|
```
|
||||||
|
|
||||||
|
Die Interpretation von Cohen's d ist wie folgt:
|
||||||
|
- Kleiner Effekt: Cohen's d ≈ 0,2
|
||||||
|
- Mittlerer Effekt: Cohen's d ≈ 0,5
|
||||||
|
- Großer Effekt: Cohen's d ≈ 0,8[1]
|
||||||
|
|
||||||
|
Beachten Sie, dass diese Schwellenwerte als Richtwerte dienen und je nach Forschungsbereich variieren können[1].
|
||||||
|
|
||||||
|
Citations:
|
||||||
|
[1] https://martin-grellmann.de/cohens-d-eine-einfuehrung-in-die-effektstaerke-und-rechner
|
||||||
|
[2] https://novustat.com/statistik-blog/cohens-d-effektstaerke-berechnen.html
|
||||||
|
[3] https://www.askpython.com/python/examples/cohens-d-python
|
||||||
|
[4] https://statistikguru.de/rechner/cohens-d-gepaarter-t-test.html
|
||||||
|
[5] https://statistikguru.de/rechner/cohens-d.html
|
Loading…
Reference in New Issue
Block a user