shuffle Questions

8

Solved

I have this issue where I would like to shuffle a list, but only do so slightly. Say, I want only a small number of elements to be moved. Is there a simple way to get this done? Right now the best...
Gettysburg asked 17/6, 2020 at 18:51

7

I have the following letter sequence: "MGGGRYSGTK" I wish to keep all the Gs in the same spot, but shuffle the remaining letters. The code I have so far is as follows. I need help on how ...
Raama asked 7/5, 2024 at 8:42

4

Solved

I am writing a program compatible with both Python 2.7 and 3.5. Some parts of it rely on stochastic process. My unit tests use an arbitrary seed, which leads to the same results across executions a...
Thier asked 14/8, 2016 at 14:9

15

Solved

I have the following DataFrame: Col1 Col2 Col3 Type 0 1 2 3 1 1 4 5 6 1 ... 20 7 8 9 2 21 10 11 12 2 ... 45 13 14 15 3 46 16 17 18 3 ... The DataFrame is read from a CSV file. All rows which have...
Haldas asked 11/4, 2015 at 9:47

58

Solved

I have an array like this: var arr1 = ["a", "b", "c", "d"]; How can I randomize / shuffle it?
Whatsoever asked 15/3, 2010 at 22:37

3

Solved

I'm trying to write a TypeScript function to shuffle an array. By default, I want the shuffle order to be random (but subject to a seed). (I already have access to this function: function random(se...
Respondent asked 21/10, 2023 at 19:5

4

The code below works for a normal array but not with an array with object does anybody knows how to do this? const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; function shuffle(array) { for (...
Procopius asked 29/3, 2018 at 11:48

8

Solved

I have a file with ~2 billion lines of text (~200gigs). I want to produce a new file containing the same text lines, but shuffled randomly by line. I can't hold all the data in memory. Is there a g...
Askins asked 30/6, 2014 at 14:22

2

Now I use following function for shuffling from tensorflow.contrib import data def input_pipeline(filenames, batch_size): # Define a `tf.contrib.data.Dataset` for iterating over one epoch of the ...
Clovis asked 28/6, 2017 at 2:37

4

Solved

I have a list which I shuffle with the Python built in shuffle function (random.shuffle) However, the Python reference states: Note that for even rather small len(x), the total number of permut...
Ebro asked 17/6, 2010 at 14:48

2

Solved

I am looking to shuffle an array in parallel. I have found that doing an algorithm similar to bitonic sort but with a random (50/50) re-order results in an equal distribution but only if the array ...

5

Solved

I have a problem analog to: We have 20 balls each ball is unique and identified by a number from 1 to 20. The balls numbered from 1 to 5 are yellow, from 6 to 10 green, from 10 to 15 red and from 1...
Epididymis asked 23/5, 2023 at 10:3

1

Solved

Is there a way where we can shuffle a list in python and reverse it if we needed for eg a = [1,2,3,4,'a','b','D','#'] and make it as 4aD#1b23 random which can be later reversed as it was in the lis...
Mattern asked 24/4, 2023 at 8:35

3

Solved

What's the best way to efficiently permute the contents of each column in a numpy array? What I have is something like: >>> arr = np.arange(16).reshape((4, 4)) >>> arr array([[ ...
Junoesque asked 15/12, 2014 at 14:51

26

Solved

How do I shuffle a list of objects? I tried random.shuffle: import random b = [object(), object()] print(random.shuffle(b)) But it outputs: None
Gutow asked 10/6, 2009 at 16:56

6

Solved

I have an array like: var names: String = [ "Peter", "Steve", "Max", "Sandra", "Roman", "Julia" ] I would like to get 3 random elements from that array. I'm coming from C# but in swift I'm unsur...
Kneehole asked 2/12, 2014 at 21:30

4

Solved

l have two numpy arrays the first one contains data and the second one contains labels. l want to shuffle the data with respect to their labels. In other way, how can l shuffle my labels and data i...
Norvell asked 5/4, 2017 at 10:50

13

Solved

I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible. Any ideas? Currently, I am doing something like this: bool[] bIndexSet = new bool[iItemCount]; for (int ...
Gaming asked 17/12, 2008 at 17:34

6

Solved

I have the following array: import numpy as np a = np.array([[ 1, 2, 3], [ 1, 2, 3], [ 1, 2, 3]]) I understand that np.random.shuffle(a.T) will shuffle the array along the row, but what I need ...
Guarneri asked 28/3, 2016 at 23:37

9

For learning purposes, what is this called? Is the object being created an array or a hash? stack_of_cards = [] This is how I'm filling it: stack_of_cards << Card.new("A", "Spades", 1) st...
Pahoehoe asked 20/2, 2011 at 22:52

13

Solved

I was helping somebody out with his JavaScript code and my eyes were caught by a section that looked like that: function randOrd(){ return (Math.round(Math.random())-0.5); } coords.sort(randOrd);...
Middlings asked 7/6, 2009 at 20:56

6

Solved

I have the following code to pick $n elements from an array $array in PHP: shuffle($array); $result = array_splice($array, 0, $n); Given a large array but only a few elements (for example 5 out ...
Two asked 16/8, 2015 at 13:27

17

Solved

How do I shuffle the characters in a string (e.g. hello could be ehlol or lleoh or ...). I don't want to use the Collections.shuffle(...) method, is there anything simpler?
Wedurn asked 23/7, 2010 at 8:50

3

I was using StratifiedKFold from scikit-learn, but now I need to watch also for "groups". There is nice function GroupKFold, but my data are very time dependent. So similary as in help, ie number o...
Reception asked 26/11, 2016 at 14:52

4

Solved

So lets say i have a list of tuples l=[(1,2),(3,4),(5,6),(7,8),(9,10)] I want to shuffle the values after a specific rule, so that after i shuffle the list i can unshuffle it back using th...
Cash asked 16/2, 2019 at 14:56

© 2022 - 2025 — McMap. All rights reserved.