Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

function for permutation sampling

def permutation_sample(data1, data2):
    """Generate a permutation sample from two data sets."""

    # Concatenate the data sets: data
    data = np.concatenate((data1, data2))

    # Permute the concatenated array: permuted_data
    permuted_data = np.random.permutation(data)

    # Split the permuted array into two: perm_sample_1, perm_sample_2
    perm_sample_1 = permuted_data[:len(data1)]
    perm_sample_2 = permuted_data[len(data1):]

    return perm_sample_1, perm_sample_2
Comment

function for permutation sampling and test statistic from a specified operation

def draw_perm_reps(data_1, data_2, func, size=1):
    """Generate multiple permutation replicates."""

    # Initialize array of replicates: perm_replicates
    perm_replicates = np.empty(size)

    for i in range(size):
        # Generate permutation sample
        perm_sample_1, perm_sample_2 = permutation_sample(data_1, data_2)

        # Compute the test statistic
        perm_replicates[i] = func(perm_sample_1, perm_sample_2)

    return perm_replicates
Comment

PREVIOUS NEXT
Code Example
Python :: Pillow opencv convert RGB to BRG or RGB to BRG 
Python :: Resource stopwords not found 
Python :: python build a string using reduce and concatenate 
Python :: form field required in django views 
Python :: Code Example of Hashmap in Python 
Python :: Python Sort Lists 
Python :: python os 
Python :: unpacking in python 
Python :: how to check system has internet using python 
Python :: check file existtnece python 
Python :: change background create_text tkinter 
Python :: increment dic with for loop 
Python :: flask tutorial 
Python :: list of list to numpy array 
Python :: recorrer lista desde el final python 
Python :: Getting the string and the regex of the matched object 
Python :: generate a random np image array with shape 
Python :: class python __call__ 
Python :: python should i use getters and setters 
Python :: change state enabled tkinter 
Python :: objects and classes in python 
Python :: py environment variables register in flask 
Python :: # add keys to existing dictionary 
Python :: how to loop through every character in a string 
Python :: Sqlalchemy Define class from existing table 
Python :: numpy sort multidimensional array 
Python :: numpy subtract 
Python :: sum() python 
Python :: numpy filter based on value 
Python :: get image data cv2 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =