Cohen's d

Python

cohensd_1samp


Calculate cohen’s d for 1 sample. See Using_cohens_d.ipynb for a notebook of given examples.

Syntax


 import cohens_d as cD

d = cD.cohensd_1samp(data)

d = cD.cohensd_1samp(data, Name=Value)

Description


A

d = cD.cohensd_1samp(data) returns cohen’s d for 1 sample comparing to mu=0. example

B

d = cD.cohensd_1samp(data, Name=Value) returns cohen’s d for 1 sample with additional options specified by one name-value pair arguments. For example, you can compare to a mean of 15 (mu=15). example

Examples


Example 1

Generate some random data and find cohen’s d.

import numpy as np 

data = np.random.normal(0, 1, size=(100,))
d = cD.cohensd_1samp(data)

d = 0.058009400346186867

Example 2

Generate some random data and find cohen’s d when comparing to mean of 15.

import numpy as np 

data = np.random.normal(0, 1, size=(100,))
d = cD.cohensd_1samp(data, mu=15)

d = 15.881558105056795

Input Arguments


data

Data vector.

Vector of data to calculate 1 sample cohen’s d.

Data Types: (numeric)

Name-Value Arguments

Specified optional pairs of Name=Value arguments. Name is the is the argument name and Value is the corresponding value. You can specify several name and value pair arguments in any order as Name1=Value1,...,NameN=ValueN.

Example: mu=15 specifies comparison to a mean of 15.

mu

Mean to compare against (default=0)

Value to subtract from mean of data.

Data Types: (scalar, float, numeric)

Output


d

Effect size.

Cohen’s d effect size for 1 sample test.

Data Types: (scalar, float, numeric)

More About


Lecture

I refrained from outputting size of effect (e.g., ‘small’, ‘medium’, ‘large’) because these are arbitrary and should be thought of as such.

Tips


Issues and Discussion


Issues and Discussion.

If you don’t know how to use github (or don’t want to), just send me an email.