summaryrefslogtreecommitdiff
path: root/ot/utils.py
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2016-10-28 12:50:54 +0200
committerRémi Flamary <remi.flamary@gmail.com>2016-10-28 12:50:54 +0200
commit9523b1e95ed7c117554ff673532d150841092137 (patch)
tree1ed5b5060b3b59e79ca2e286058162cdd51c3b75 /ot/utils.py
parentf33087d2b1790dac773782bb0d91bcfe7ce6a079 (diff)
doc datasets.py
Diffstat (limited to 'ot/utils.py')
-rw-r--r--ot/utils.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/ot/utils.py b/ot/utils.py
index e5ec864..2110c01 100644
--- a/ot/utils.py
+++ b/ot/utils.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""
Various function that can be usefull
"""
@@ -6,7 +7,21 @@ from scipy.spatial.distance import cdist
def unif(n):
- """ return a uniform histogram of length n (simplex) """
+ """ return a uniform histogram of length n (simplex)
+
+ Parameters
+ ----------
+
+ n : int
+ number of bins in the histogram
+
+ Returns
+ -------
+ h : np.array (n,)
+ histogram of length n such that h_i=1/n for all i
+
+
+ """
return np.ones((n,))/n
@@ -22,9 +37,9 @@ def dist(x1,x2=None,metric='sqeuclidean'):
matrix with n2 samples of size d (if None then x2=x1)
metric : str, fun, optional
name of the metric to be computed (full list in the doc of scipy), If a string,
- the distance function can be ‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’,
+ the distance function can be ‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’,
‘correlation’, ‘cosine’, ‘dice’, ‘euclidean’, ‘hamming’, ‘jaccard’, ‘kulsinski’,
- ‘mahalanobis’, ‘matching’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’,
+ ‘mahalanobis’, ‘matching’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’,
‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘wminkowski’, ‘yule’.
@@ -68,5 +83,5 @@ def dist0(n,method='lin_square'):
def dots(*args):
- """ Stupid but nice dots function for multiple matrix multiply """
+ """ dots function for multiple matrix multiply """
return reduce(np.dot,args) \ No newline at end of file