File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -203,9 +203,22 @@ We need to repeatetly get the eucledian distances of one centroid against all ge
203203Implement a `` dist_to_centroid (centroid, mat ) `` function.
204204
205205
206- ??? example "Again only peak after you finished yours"
206+ ??? example "Peak only after you finished yours"
207207
208208 ```python
209+ ## I am sure yours performs way better!
210+ def dist( vec_a, vec_b ):
211+ """
212+ Calculates the distance between two numpy arrays
213+ """
214+ if len(vec_a) != len(vec_b):
215+ raise ValueError("Vectors must have the same length.")
216+
217+ sum = 0.0
218+ for (a,b) in vec_a.zip(vec_b):
219+ sum += (a -b) ** 2
220+ return (sum ** 0.5)
221+
209222 def dist_to_centroid (centroid, mat ):
210223 """
211224 Calculates eucledian distance between one centroid and a matrix of genes
You can’t perform that action at this time.
0 commit comments