Skip to content

Effect size calculation with small sample size gives ValueError #220

@delvendahl

Description

@delvendahl

Describe the bug
For n=3, the effect size calculation of Cohen's d or Hedge's g fail with a ValueError "The divisor is zero, indicating no variability in the data.". When running the analysis with the same data on estimationstats.com, everything works fine.

To Reproduce
Steps to reproduce the behavior:

  1. Use input dataframe with N=3 for control and test
    import numpy as np
    import pandas as pd
    import dabest

df = pd.DataFrame()
df['control'] = np.random.normal(0, 1, 3)
df['test'] = np.random.normal(0, 1, 3)

  1. Run dabest

two_groups = dabest.load(df, idx=(('control', 'test')))
print(two_groups.cohens_d)

Expected behavior
Calculation of effect size as on the homepage.

Your package version (please complete the following information):

  • python 3.12.12
  • dabest: 2025.10.20
  • pandas: 2.2.3
  • numpy: 2.1.3
  • scipy: 1.15.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions