Skip to content
fullerjamesrPublic

About

Python implementation of the z-dip test for multimodality

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pzdip

A Python implementation of the Z-Dip statistic: a sample size-independent standardisation of Hartigan's Dip Test for detecting multimodality.

This package is a Python port of the method and reference implementation described in:

The lookup table in pzdip/data/null_table.npz is a copy of the lookup table provided with that R package.

The authors mentioned above deserve the entirety of the credit for the methods implemented here.

Installation

pip install pzdip

Usage

Basic usage:

import numpy as np
import pzdip

RNG = np.random.default_rng(0)

def normal(n, loc=0, scale=1):
    return RNG.normal(loc, scale, n)

def bimodal(n):
    half = n // 2
    return np.concatenate([RNG.normal(-3, 0.5, half), RNG.normal(3, 0.5, n - half)])

result_unimodal = pzdip.zdip(normal(100))
print(result_unimodal)
# ZDipResult(zdip=-0.7204, dip=0.031006, n=100, multimodal=False)
result_bimodal = pzdip.zdip(bimodal(100))
print(result_bimodal)
#ZDipResult(zdip=16.8099, dip=0.169151, n=100, multimodal=True)

License

MIT, see LICENSE. This is an independent Python reimplementation; credit to Edoardo Di Martino and coauthors for the original method and R package.

About

Python implementation of the z-dip test for multimodality

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages