add llm chapter
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user