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 :: binning continuous values in pyspark 
Python :: django filter form view 
Python :: poisson random data 
Python :: parsing date columns when reading csv 
Python :: genrate requirments.txt pytohn 
Python :: Book.__init__() missing 5 required positional arguments 
Python :: wap in python to print the sum of the series 1 + 1/2! + 1/3! 
Python :: sorting list of strings by length python 
Python :: python list example 
Python :: auto clicker 
Python :: time, date 
Python :: Implementing the hashing trick 
Python :: sanic ip whitelist 
Python :: For_else 
Python :: python concurrent.futures.ProcessPoolExecutor multiple arguments 
Python :: what will be the output of the following python code? x = 123 for i in x: print(i) 
Python :: how to make a value 0 if its negatice 
Python :: Donut chart graphing funciton 
Python :: python google translator 
Python :: matrix of matrices python grepper 
Python :: python copy file create intermediate directories 
Python :: accessing element from csv file in python 
Python :: iptc text classification example 
Python :: python lxml get parent 
Python :: most valuable features in pandas model 
Python :: django datepicker mindate and maxdate 
Python :: python sha256 crypt decrypt 
Python :: FilePathField 
Python :: arrotondamento python 
Python :: how to upgrade python from 2.7 to 2.9 on ubuntu 14.04 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =