Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to statistics.py #47

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Documented get_bins function.
tlarock committed Mar 7, 2019
commit 1b2fb3878b51e9be2e06dd28ed6a80d11bb91c54
19 changes: 18 additions & 1 deletion pathpy/algorithms/statistics.py
Original file line number Diff line number Diff line change
@@ -203,7 +203,24 @@ def molloy_reed_fraction(network, degree='degree'):
return degree_moment(network, k=2, degree=degree)/degree_moment(network, k=1, degree=degree)


def get_bins(values, num_bins, log_bins):
def get_bins(values, num_bins, log_bins=False):
'''
Compute (linear or logarithmic) bins for values.
Parameters
---------
values: np.array
values to be binned
num_bins: int
number of bins to use
log_bins: logical
If True, use logarithmic bins. Default is linear bins.
Returns
-------
bins: np.array
edges of num_bins bins
'''
min_val = values.min()
max_val = values.max()