Commit 182cb212 authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Remove unused function.

parent 79f1425e
......@@ -278,45 +278,3 @@ def complete_obs_table(obs_table, used_columns, filter_list, tolerance, lim_flag
default_error,
systematic_deviation)
return obs_table
def bin_evenly(values, max_bins):
"""Divide some values in evenly populated bins
Given a list of values and a desired number of bins, this method computes
the bins boundaries to have bins with the same number of elements in each
one and digitises the value list with these boundaries.
Parameters
----------
values: list of floats
List of values to be binned.
max_bins: integer
Maximum number of bins. If there are less distinct value, every value
is in it's own bin.
Returns
-------
boundaries: array of floats
The value of the boundaries of the bins.
bins_digits: numpy array of integers
Array of the same length as the value list giving for each value the
bin number (between 1 and nb_of_bins) it belongs to.
"""
if max_bins > len(values):
max_bins = len(values)
# The bin boundaries are the nb_of_bins + 1 quantiles.
quantiles = np.linspace(0, 1, max_bins + 1)
boundaries = stats.mstats.mquantiles(values, quantiles)
# Because of the way np.digitize works, we must have the last boundary
# higher than the value maximum to have this maximum belong to the last
# bin.
digitize_boundaries = np.copy(boundaries)
digitize_boundaries[-1] += 1
bin_digits = np.digitize(values, digitize_boundaries)
return boundaries, bin_digits
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment