예제 #1
0
    def test_random_orderings(self):
        arrs = random_orderings([[0]], [[0]], 10)
        self.assertEquals(list(arrs), [ [ 0 ] ])

        arrs = random_orderings([[0], [1]], [[0, 1]], 10)
        self.assertEquals(list(arrs), [[0, 1], [1, 0]])

        arrs = random_orderings([[0, 1], [2, 3]], [[0, 1, 2, 3]], 10)
        self.assertEquals(list(arrs),
                           [[0, 1, 2, 3], 
                            [0, 2, 1, 3],
                            [0, 3, 1, 2],
                            [1, 2, 0, 3],
                            [1, 3, 0, 2],
                            [2, 3, 0, 1]])

        arrs = random_orderings([[0, 1], [2, 3]], [[0, 1, 2, 3]], 3)
        arrs = list(arrs)

        # Make sure we got three orderings
        self.assertEquals(len(arrs), 3)

        # And make sure they're all unique
        arrs = set(map(tuple, arrs))
        self.assertEquals(len(arrs), 3)
예제 #2
0
def pairedOrderings(n, R):
    idxs = np.arange(2 * n)

    cond_layout = [ range(0, 2 * n, 2),
                    range(1, 2 * n, 2) ]
    
    reduced_layout = idxs.reshape((n, 2))
    return list(random_orderings(cond_layout, reduced_layout, 100))
예제 #3
0
파일: analysis.py 프로젝트: itmat/pade
def new_sample_indexes(job):

    """Create array of sample indexes."""

    R  = job.settings.num_samples

    if job.settings.sample_with_replacement:
        if job.settings.sample_from_residuals:
            logging.debug("Bootstrapping using samples constructed from " +
                         "residuals, not using groups")
            layout = [ sorted(job.schema.sample_name_index.values()) ]
        else:
            logging.debug("Bootstrapping raw values, within groups defined by" + 
                         "'" + str(job.settings.block_variables) + "'")
            layout = job.block_layout
        return random_indexes(layout, R)

    else:
        logging.debug("Creating max of {0} random permutations".format(R))
        logging.debug("Condition layout is " + str(job.condition_layout))
        logging.debug("Block layout is " + str(job.block_layout))
        return list(random_orderings(job.condition_layout, job.block_layout, R))
예제 #4
0
def new_sample_indexes(job):
    """Create array of sample indexes."""

    R = job.settings.num_samples

    if job.settings.sample_with_replacement:
        if job.settings.sample_from_residuals:
            logging.debug("Bootstrapping using samples constructed from " +
                          "residuals, not using groups")
            layout = [sorted(job.schema.sample_name_index.values())]
        else:
            logging.debug(
                "Bootstrapping raw values, within groups defined by" + "'" +
                str(job.settings.block_variables) + "'")
            layout = job.block_layout
        return random_indexes(layout, R)

    else:
        logging.debug("Creating max of {0} random permutations".format(R))
        logging.debug("Condition layout is " + str(job.condition_layout))
        logging.debug("Block layout is " + str(job.block_layout))
        return list(random_orderings(job.condition_layout, job.block_layout,
                                     R))