{"id":9647,"library":"dcor","title":"dcor: Distance Correlation and Energy Statistics","description":"dcor is a Python library that provides efficient implementations of distance correlation and energy statistics, powerful tools for measuring dependence and performing two-sample tests. It supports various statistical tests including independence testing and two-sample testing. Currently at version 0.7, it is actively maintained with regular updates and a focus on numerical stability and performance.","status":"active","version":"0.7","language":"python","source_language":"en","source_url":"https://github.com/vnmabus/dcor","tags":["statistics","distance correlation","energy statistics","non-parametric","hypothesis testing","dependence measure"],"install":[{"cmd":"pip install dcor","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for numerical operations and array handling.","package":"numpy","optional":false},{"reason":"Required for statistical functions and scientific computing.","package":"scipy","optional":false}],"imports":[{"note":"The function was renamed in a previous major version for clarity.","wrong":"from dcor import get_distance_correlation","symbol":"distance_correlation","correct":"from dcor import distance_correlation"},{"symbol":"energy_distance","correct":"from dcor import energy_distance"},{"symbol":"independence_test","correct":"from dcor import independence_test"}],"quickstart":{"code":"import numpy as np\nimport dcor\n\n# Example data\nx = np.array([1, 2, 3, 4, 5])\ny = np.array([1, 2, 3, 4, 5])\nz = np.array([5, 4, 3, 2, 1])\nw = np.array([1, 2, 3, 4, 6]) # Slightly different for energy_distance\n\n# Calculate distance correlation\ndc_xy = dcor.distance_correlation(x, y)\ndc_xz = dcor.distance_correlation(x, z)\nprint(f\"Distance correlation (x, y): {dc_xy:.4f}\")\nprint(f\"Distance correlation (x, z): {dc_xz:.4f}\")\n\n# Calculate energy distance\ned_xw = dcor.energy_distance(x, w)\nprint(f\"Energy distance (x, w): {ed_xw:.4f}\")\n\n# Perform independence test (requires bootstrapping)\n# Note: n_bootstraps should be sufficiently large for real analysis\nindependence_p_value = dcor.independence_test(x, y, n_bootstraps=100).p_value\nprint(f\"P-value for independence test (x, y): {independence_p_value:.4f}\")","lang":"python","description":"This quickstart demonstrates how to calculate distance correlation, energy distance, and perform an independence test using dcor. It initializes sample NumPy arrays and applies the main functions, printing their results."},"warnings":[{"fix":"Update your code to use `dcor.distance_correlation`.","message":"The function `dcor.get_distance_correlation` was renamed to `dcor.distance_correlation` in version 0.4.0. Using the old name will result in an AttributeError.","severity":"breaking","affected_versions":"<0.4.0"},{"fix":"Ensure your input data is converted to `numpy.ndarray` before passing it to dcor functions (e.g., `np.array(my_list)`).","message":"Input data for all dcor functions (e.g., `distance_correlation`, `energy_distance`) must be NumPy arrays or objects convertible to them. Passing raw Python lists will lead to TypeError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always provide a sufficiently large `n_bootstraps` argument (e.g., 1000 or more for production) to `independence_test`.","message":"When performing statistical tests like `dcor.independence_test`, the `n_bootstraps` parameter is mandatory and determines the number of bootstrap samples used for p-value calculation. A too small value can lead to unreliable results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Reshape or filter your data to ensure `x.shape[0] == y.shape[0]` before computing statistics like distance correlation or energy distance.","message":"The input arrays `x` and `y` must have the same number of observations (rows). If they represent samples, they must be from the same number of experimental units.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.7':49 'activ':52 'correl':3,18,67 'current':46 'dcor':1,7 'depend':26,75 'distanc':2,17,66 'effici':14 'energi':5,20,68 'focus':59 'hypothesi':73 'implement':15 'includ':38 'independ':39 'librari':11 'maintain':53 'measur':25,76 'non':71 'non-parametr':70 'numer':61 'parametr':72 'perform':28,64 'power':22 'provid':13 'python':10 'regular':55 'sampl':31,44 'stabil':62 'statist':6,21,36,65,69 'support':34 'test':32,37,40,45,74 'tool':23 'two':30,43 'two-sampl':29,42 'updat':56 'various':35 'version':48","created_at":"2026-04-17T01:20:00.021590+00:00","updated_at":"2026-04-17T01:20:00.021590+00:00","problems":{"verify_error":"import timed out after 15s"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.7","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/vnmabus/dcor","docs":"https://dcor.readthedocs.io","changelog":null,"pypi":"https://pypi.org/project/dcor/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","testing","ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"timeout","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}