5,322 questions
0
votes
0
answers
17
views
Significance analysis of microarrays (SAM) on OMIQ gives q-value of exactly 0 [closed]
I am analyzing a set of flow cytometry data in the online environment of OMIQ. OMIQ has a feature to analyze the data with the Significance analysis of microarrays (SAM) algorithm (https://www.pnas....
3
votes
2
answers
162
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
2
answers
380
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
232
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
182
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
44
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
117
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
374
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
163
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
129
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
60
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
138
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
65
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
107
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
176
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
157
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
76
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
145
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 ...
-11
votes
3
answers
309
views
Fastest way to find all permutations of 0, 1 of width n without itertools in pure Python?
What is an efficient way to get the same result as list(product((0, 1), repeat=n)) without using itertools and any imports?
For example, given n=3, the output be: [(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, ...
-1
votes
1
answer
40
views
What function calculates the value of an identity index on n items in base n?
Given an increasing identity index on n items [ 0, 1, ..., n-1 ], a value can be calculated by considering each entry as a number in base n and with place value corresponding to it's location (powers ...
-4
votes
1
answer
85
views
Get all possible ways to put variable list of items into N bins [closed]
I have a list of items which can be any length (but will never contain duplicates of the same item), and a set of N bins which can each hold zero or one item. What's the easiest way to get all ...
7
votes
0
answers
215
views
Sorting by cyclic shift and swap of 1,2 positions - is optimal NP-hard ? What are the best suboptimal algorithms?
Assume we need to sort using only three operations - left cyclic shift, right cyclic shift, and swap (transposition) of positions 1 and 2. Shifts are only by 1 positions, so shifts by k - counts as &...
1
vote
1
answer
138
views
Efficiently count lists with certain properties
My purpose is to count permutations with certain properties. I first generate the permutations and then remove those that do not satisfy the desired properties. How could I improve the code to be able ...
-3
votes
1
answer
82
views
Get all tuple permutations between two lists
Given two lists of length n, I've been trying to find a pythonic way to return a list of a list of n-tuples where each list of tuples is a distinct permutation of the possible values between the two ...
0
votes
0
answers
81
views
How can I print all possible x-letter words in python using loops? [duplicate]
How can I print all possible words of a user-specified length "x" in python? I already know how to do it for a specific number of characters like all possible 3 letter words by using for ...
0
votes
1
answer
99
views
Determining a combination of selections from a list of sets that would yield the maximum number of unique numbers
Determining a combination of selections from a list of sets that would yield the maximum number of unique numbers
Consider an array of sets, with each set containing an arbitrary number of integers.
A ...
1
vote
3
answers
113
views
Manually calculate all coin flip probabilities from real data
I have this coin flip data:
library(dplyr)
library(knitr)
library(kableExtra)
set.seed(123)
n_flips <- 100
flips <- sample(c("H", "T"), n_flips, replace = TRUE)
I manually ...
0
votes
2
answers
162
views
Using next_permutation on arrays of ints
Given some arrays, I'd like to loop over every possible permutation of these arrays:
Here's a minimal example:
#include <array>
#include <iostream>
//#include <random>
#include <...
2
votes
1
answer
47
views
Incrementing an extra step in MATLAB loop yields incorrect values?
I'm encountering some very weird behaviour in some MATLAB code I've written, and can't quite tell why. If I increment the loop from 0.01 in steps of 0.01 to 0.09, all values are correct. However, if I ...
3
votes
2
answers
184
views
How to permute array elements by shifting and then undoing?
#include <iostream>
using namespace std;
void permute(int arr[],int len){
//if(len==1) cout << arr[fixed];
for(int i=0; i<len; i++){
cout << arr[i] << "...
1
vote
1
answer
70
views
Dafny array membership before and after permutation
After sorting an array, Dafny cannot verify an item in the old array exists in the sorted array. The sorted array is a permutation of the old array. What is missing here?
var a := new int[][100,2,3,4,...
0
votes
1
answer
138
views
tuples of integers with fixed sums up to permutations
I'm stuck with the following problem which I need to speed up a piece of code I have written in the past. I am programming in python, but this question is more about the algorithm than about the ...
1
vote
1
answer
258
views
What is int** returnColumnSizes in leetcode problem 46 (language: c)
This question is based around leetcode problem 46: Permutations.
copy of the question for convenience:
Given an array nums of distinct integers, return all the possible permutations. You can return ...
1
vote
0
answers
114
views
Algorithm to Count Permutations Without Adjacent Repeating Characters and Find the Inverse
I would appreciate the help of this great community in finding an algorithm (in any programming language, though I have it in Visual Basic) to solve two related problems:
Counting permutations with ...
3
votes
2
answers
120
views
Create all Combination from a vector with repeating elements - R
I would like to know if there is a simple solution to finding all combination of a vector with repeating elements. The practical application is in combinatorics math. For example:
There is an urn with ...
0
votes
2
answers
88
views
Add text to combinations and permutations
I am new at codding.I have a question.How do I add text to combinations and permutations I've created? Also, is there a way to delete repetitive states in a repetitive permutation, that is, to print ...
0
votes
1
answer
170
views
finding the number of possible k non-attacking rooks in an NxM chessboard with forbidden tiles?
I have an NxM incomplete chessboard (meaning an NxM chessboard with some tiles missing) and a number k (which is the number of non-attacking rooks I need to place on the board)
the inputs of this ...
1
vote
2
answers
144
views
Ruby - all permutations with any number of elements
I want to transform the array [3, 4, 8] → [3, 4, 8, 34, 38, 48, 43, 83, 84, 348, 384, 834, 843, 438, 483]
I tried array.permutation but this only returns [348, 384, 834, 843, 438, 483]. Is there a ...
0
votes
1
answer
116
views
Why is graph in Networkx pointing arrows in the wrong direction?
I have a pandas data frame with two columns: source and sink. In a simplified form, there are just 5 users (source column) that can owe money to any other user (sink column).
I thought the following ...
1
vote
1
answer
183
views
Can function how() in package permute support unbalanced data in the context of defining permutation restrictions for vegan::adonis2()?
I'm conducting a study comparing insect communities in forest canopy gaps and closed-canopy forest in three distinct forested areas. My experimental design is hierarchical and unbalanced.
Simplified ...
0
votes
1
answer
42
views
Efficient algorithm for finding the non-overlapping set of two very large sets of strings generated by permutation
I am looking for the most efficient algorithm for comparing large set of strings that are representing possible amino acid substitutions at various positions of a 9mer peptide.
As a toy example, the ...
0
votes
1
answer
49
views
Listing all sets of 5 teams that has one element of each rank
This will be used for a fairly-ranked team-picking (each team must have exactly one element of each rank). One example of elegibe players would be:
Rank 1:'Liam', 'Emma', 'Noah', 'Olivia', 'Ava'
Rank ...
-1
votes
1
answer
82
views
Reversing function to obtain the lexicographic index of a given permutation
I'm working on a Python3 code challenge where a message is encoded on or decoded from the shuffling order of a 52-card standard playing deck. I have already found how to encode the message, but I am ...
-1
votes
3
answers
219
views
How to generate permutations with constraints
I want to generate all possible lists of ["x","y","z",1,2,3] that are ordered in ascending order. "x", "y" and "z" can be any real numbers ...
0
votes
1
answer
59
views
using ranksum test within permutation test
I am a bit confused with the definition of the permutation_test function provided by scipy.
the following is what I wrote to calculate the p and null distribution
x = disease['Theta']
y = nodisease['...
0
votes
2
answers
49
views
Apply sample() across columns of a multidimensional array
Given the following array in R:
x <- 1:24
dim(x) <- c(2, 4, 3)
Which gives:
> x
, , 1
[,1] [,2] [,3] [,4]
[1,] 1 3 5 7
[2,] 2 4 6 8
, , 2
[,1] [,2] [,3] [...
3
votes
0
answers
65
views
Write Matlab code which selects a "cluster" of rows satisfying a given requirement
Consider the following Matlab code:
clear
rng default
A= nchoosek(1:1:10,2);
A(:,3)=randn(size(A,1), 1);
sA=size(A,1);
The first two columns of A list all possible unordered pairs of integers between ...
1
vote
1
answer
51
views
Calculate all combinations of adding (1+1) up X number of columns where one column is always constant
Lets say i have a data table that looks like this:
for each combination of index level1 & 2 - a customer could be allocated a price that see's them get the value base column + the addition of any ...
6
votes
3
answers
485
views
Convert matrix to block matrix by permuting rows and columns
I have a rectangular matrix with n rows and m column. All entries of the matrix are natural numbers (including 0).
Among the m columns, I'm given some index, j (< m). I'd like the matrix to become ...
1
vote
1
answer
62
views
Zero-inflated negbin regression warnings after permutation of data
I am applying a zeroinfl negbin regression to my data. Specifically, my dependent variable is a count variable (centrality measure), while my independent/controls are both binary and continous.
I've ...