Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this just a permutation function? #12

Closed
amichuda opened this issue Oct 12, 2022 · 1 comment · Fixed by #13 · May be fixed by #7
Closed

Is this just a permutation function? #12

amichuda opened this issue Oct 12, 2022 · 1 comment · Fixed by #13 · May be fixed by #7
Milestone

Comments

@amichuda
Copy link
Collaborator

amichuda commented Oct 12, 2022

        #TODO: Is this just a permutation function?
        permutations(
            n = 2,
            r = N_G_bootcluster,
            v = c(1, -1),
            repeats.allowed = TRUE
        )
This was linked to pull requests Oct 12, 2022
@amichuda amichuda added this to the v0.1 milestone Oct 12, 2022
@s3alfisc
Copy link
Member

Yes, this is indeed just a permutation function, as taken from the gtools package: i.e. for G = 3 clusters, there are only 2^3 unique combinations of rademacher draws: ((1,1,1), (1, -1, -1), (1,-1,1),...,(-1,-1,-1)) and the function gets you all of these:

library(gtools)

N <- 100
G <- 3
bootcluster <- sample(1:G, N, TRUE)
bootcluster[1:5]
# [1] 1 4 3 1 4
N_G_bootcluster <- length(unique(bootcluster))
v <- permutations(
  n = 2,
  r = N_G_bootcluster,
  v = c(1, -1),
  repeats.allowed = TRUE
)

t(v)
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
# [1,]   -1   -1   -1   -1    1    1    1    1
# [2,]   -1   -1    1    1   -1   -1    1    1
# [3,]   -1    1   -1    1   -1    1   -1    1

This is low priority for a first implementation, we can just start with calling np.random.sample([-1,1], N_G_bootcluster * B) for a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants