5,321 questions
3
votes
2
answers
174
views
Recursive C function for creating number permutations
I do understand I have mistakes in this code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int diziyi_yazdır(int dizi[], int dizi_uzunluğu)
{
for (int i ...
9
votes
3
answers
611
views
Finding a maximum "score" of a permutation
Consider an array of a permutation P of length n (n > 2), namely some order of the integers 1 through n.
Example of P with length n = 7,
[6,5,2,3,7,1,4]
A "score" of a permutation is ...
-2
votes
2
answers
241
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
185
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
70
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
119
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 ...
9
votes
3
answers
411
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
208
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
136
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
66
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
142
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
67
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
118
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
177
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
158
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 ...