Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except ImportError:
raise ImportError("The 'mapclassify' package is required")
def p(n, N):
""" Relative abundance """
if n == 0:
return 0
return float(n) / N
if categorical:
counts = data.value_counts().to_dict()
for c in categories:
if c not in counts.keys():
counts[c] = 0
else:
sample_bins = mc.UserDefined(data, bins)
counts = dict(zip(bins, sample_bins.counts))
N = sum(counts.values())
return sum(p(n, N) ** 2 for n in counts.values() if n != 0)
except ImportError:
raise ImportError("The 'mapclassify' package is required")
def p(n, N):
""" Relative abundance """
if n == 0:
return 0
return (float(n) / N) * ln(float(n) / N)
if categorical:
counts = data.value_counts().to_dict()
for c in categories:
if c not in counts.keys():
counts[c] = 0
else:
sample_bins = mc.UserDefined(data, bins)
counts = dict(zip(bins, sample_bins.counts))
N = sum(counts.values())
return -sum(p(n, N) for n in counts.values() if n != 0)