ReMoDe (Recursive Mode Detection) is a Python library designed for robust mode detection in ordinal data distributions. By default it uses a bootstrap significance test (with binomial and Fisher alternatives) to determine whether a candidate maximum is a true local mode.
Are you an R user? Please find the R version here: https://cran.r-project.org/web/packages/remode/index.html
- Mode Detection: Identifies all potential local maxima in the dataset.
- Statistical Tests: Implements bootstrap (default), Fisher's exact, and binomial tests to validate modes.
- Mode Statistics: Returns per-mode p-values and approximate Bayes factors.
- Modality Definition: Supports
shape_based(default) andpeak_baseddefinitions. - Data Formatting: Converts raw data into histogram format for analysis.
- Stability Analysis: Includes functionality to assess the stability of detected modes using jackknife resampling.
- Visualization: Provides methods to plot the histogram of data along with identified modes.
pip install remodeHere is a simple example of how to use the ReMode library:
from remode import ReMoDe
# Sample data (histogram counts)
xt_count = [8, 20, 5, 2, 6, 2, 30]
# Create an instance of ReMoDe
detector = ReMoDe() # defaults: bootstrap test, descriptive_peaks correction, shape_based definition
# Fit model
results = detector.fit(xt_count)
# results contains:
# - nr_of_modes
# - modes
# - p_values
# - approx_bayes_factors
# Plot the results
detector.plot_maxima()
# Perform stability analysis
stability_info = detector.remode_stability(percentage_steps=50)See also the tutorial here.
Please cite the following paper:
Hoffstadt, M., Waldorp, L., Garcia‐Bernardo, J., & van der Maas, H. (2026). ReMoDe–Recursive modality detection in distributions of ordinal data. British Journal of Mathematical and Statistical Psychology.
and the following software
Garcia-Bernardo, J., Hoffstadt, M., Waldorp, L., & van der Maas, H. L. J. (2026). ReMoDe: a Python library for efficient mode detection in ordinal data distributions. Zenodo. https://doi.org/10.5281/zenodo.18743126
Contributions are what make the open source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Please refer to the CONTRIBUTING file for more information on issues and pull requests.
This project is licensed under the GNU GPLv3. This allows you to do almost anything they want with this project, except distributing closed source versions.
This project is a port of the R version of ReMoDe. It is maintained by the ODISSEI Social Data
Science (SoDa) team.
Do you have questions, suggestions, or remarks? File an issue in the issue tracker!
