5,319 questions
-2
votes
2
answers
214
views
Permutation of list in python with one or multiple fixed items
I have a list of a = [5,6,7,9] I want all the possible permutations, with one or more entry fixed.
e.g. If I want to fix third element 7, then in all permutations I want to see 7 in the third place of ...
4
votes
2
answers
173
views
C How to generate an arbitrary permutation within range [i,j]? [closed]
Does C standard library provide any function that generate a random permutation of consecutive numbers within a range?
How to make a function that efficiently does it? I'm thinking of making a random ...
0
votes
1
answer
36
views
Multi-Head Self Attention in Transformer is permutation-invariant or equivariant how to see it in practice?
I read that a function f is equivariant if f(P(x)) = P(f(x)) where P is a permutation
So to check what means equivariant and permutation invariant I wrote the following code
import torch
import torch....
-3
votes
1
answer
113
views
Can two equivalent JavaScript generators be derived from each other?
I have two JavaScript generator functions for permutations. They both provide Heap's enumeration.
Question: I would like to know whether one implementation can be derived from the other by some ...
8
votes
3
answers
342
views
How do I turn a permutation into an index (and back) in a context where there is a fixed amount of each permutable elements?
The problem
Let's say you have 4 red balls, 2 blue balls and 1 green ball. That is 7 balls, and considering a ball can't be distinguished from another if it has the exact same color, this makes for a ...
0
votes
0
answers
116
views
adonis2() and pairwise.adonis2() how to include structure from the permutation package?
I am fairly confident (maybe I should not be) that I have structured my data correctly for PERMANOVA analysis in the vegan package using the adonis2() function.
For my study design, I placed paired ...
5
votes
2
answers
128
views
Translate permutation algorithm by Sedgewick from Pseudocode into JavaScript
In his classical paper Permutation Generation Methods, Computing Surveys 1977, Robert Sedgewick presents his "Algorithm 1" on page 140 like this:
procedure permutations(N);
begin
...
1
vote
0
answers
55
views
how to calculate the number of permutations in a nested permanova
I'm trying to check my understanding of how to determine the appropriate permutation restrictions for a two way anova where one of the variables is nested in the other, and making sure I understand ...
4
votes
3
answers
127
views
Obtaining random sample from all permutations
I have a vector of length 100 and I want to get a sample of certain size like 50, from all permutations of length 20 from elements of my original vector
My attempt so far is to first to get all ...
0
votes
1
answer
59
views
Recursive Permutations JavaScript problem returning empty array
A permutations problem (LeetCode), which finds the permutations of an array [1,2,3], is returning an empty array through a backtracking recursive function. The console prints out the following:
Input
...
1
vote
2
answers
105
views
Generating all length-N combinations of all length-M sublists of a list, without repetitions
I have a long input list, and I want to generate combinations of 3 elements. But each combination's elements should be drawn from a length-5 sublist of the original list, rather than drawing elements ...
5
votes
5
answers
163
views
How Do We Use numpy to Create a Matrix of all permutations of three separate value ranges?
I want to make a pandas dataframe with three columns, such that the rows contain all permutations of three columns, each with its own range of values are included. In addition, I want to sort them asc ...
1
vote
1
answer
152
views
Permutations problem on python I can't understand where I am wrong
Hi I have made this code. Τhe code generates all binary permutations of a string with a given number of zeros and ones, checks for adjacency based on a specific homogeneity condition (differing by ...
0
votes
1
answer
72
views
Backtracking confusion
Concerning Javascript, I've been trying to understand backtracking lately and it's really confusing. Specifically, I've been trying to understand the permutation problem, which when given an array, we ...
3
votes
2
answers
134
views
Efficiently Filter List of Permutations
I would like to efficiently generate a list of "valid" permutations from a given list.
By way of simple example, suppose I would like to generate the permutations of [1,2,3] where 3 is in ...