Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

permutation test python

# This is a possible implementation of permutation test using monte-carlo method:
def exact_mc_perm_test(xs, ys, nmc):
    n, k = len(xs), 0
    diff = np.abs(np.mean(xs) - np.mean(ys))
    zs = np.concatenate([xs, ys])
    for j in range(nmc):
        np.random.shuffle(zs)
        k += diff < np.abs(np.mean(zs[:n]) - np.mean(zs[n:]))
    return k / nmc

Example:
>>> xs = np.array([12.6, 11.4, 13.2, 11.2, 9.4, 12.0])
>>> ys = np.array([16.4, 14.1, 13.4, 15.4, 14.0, 11.3])
>>> exact_mc_perm_test(xs, ys, 30000)
0.019466666666666667
Comment

PREVIOUS NEXT
Code Example
Python :: find factorial of a number in python 
Python :: list data structure in python 
Python :: Iterate over several iterables in parallel 
Python :: import all files on the same directory python 
Python :: ENCAPSUALTION 
Python :: threading pass keyword args example 
Python :: python os path join list 
Python :: axios post to django rest return fobidden 403 
Python :: python any( in list FOR LOOP 
Python :: how to get each word in a string in python 
Python :: difference() Function of sets in python 
Python :: Move Mouse Every Minute Using Python 3 & PyAutoGUI 
Python :: Unable to locate package python-obexftp 
Python :: Create An Empty List(Array) In Python 
Python :: python async await function await expression 
Python :: run c code in python 
Python :: how to set notepad ++ for run python 
Python :: packing a tuple 
Python :: round to 0 decimal 
Python :: how to classify numbers in python 
Python :: what is self in python constructor 
Python :: Source code: Matrix Addition using Nested Loop 
Python :: check if variable is iterable python 
Python :: how to minimisze python console 
Python :: isat in panadas datframe 
Python :: pytesseract.image_to_data into pandas dataframe 
Python :: truc python 
Python :: 218922995834555169026 
Python :: PN generator 
Python :: wait until you press escape 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =