-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some progress, but needs a little more work. mostly whitespace and va…
…riable name changes to conform to pylint.
- Loading branch information
Alex Olivas
committed
Jun 25, 2020
1 parent
27a0c27
commit 42942fa
Showing
2 changed files
with
49 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
from math import log | ||
from scipy.special import binom | ||
''' | ||
Module contains a function object that calculates | ||
the Cramer-von-Mises test statistic between two sets. | ||
''' | ||
|
||
class CramerVonMises(object): | ||
|
||
def __call__(self, v1, v2): | ||
class CramerVonMises: | ||
''' | ||
Function object that calculates | ||
the Cramer-von-Mises test statistic between two sets. | ||
''' | ||
|
||
def __call__(self, vector1, vector2): | ||
r""" | ||
Compare sequences v1, v2 with the Cramer-von-Mises test. | ||
Compare sequences vector1, vector2 with the Cramer-von-Mises test. | ||
""" | ||
result = 0. | ||
Nu = float(sum(v1)) | ||
Nv = float(sum(v2)) | ||
if Nu == 0 and Nv == 0: | ||
return 0. | ||
if not sum(vector1) and not sum(vector2): | ||
return result | ||
|
||
Nu = float(sum(vector1)) | ||
Nv = float(sum(vector2)) | ||
|
||
for i,uv in enumerate(zip(v1, v2)): | ||
for i, uv in enumerate(zip(vector1, vector2)): | ||
u = float(uv[0]) | ||
v = float(uv[1]) | ||
v = float(uv[1]) | ||
t = u + v | ||
u_ecdf = sum([bn for bn in v1[:i]])/sum(v1) | ||
v_ecdf = sum([bn for bn in v2[:i]])/sum(v2) | ||
u_ecdf = sum([bn for bn in vector1[:i]])/sum(vector1) | ||
v_ecdf = sum([bn for bn in vector2[:i]])/sum(vector2) | ||
result += t*(u_ecdf - v_ecdf)**2 | ||
factor = Nu*Nv/(Nu+Nv)**2 | ||
T = factor * result | ||
return T | ||
result = factor * result | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters