shuffle

How to show entries of a shuffled array in VBA / Excel

亡梦爱人 提交于 2019-12-13 07:19:44
问题 I've been trying to shuffle an 11-integer array and paste the shuffled array into excel. I've found some code that almost does what I want, but instead of returning the shuffled entries of the array it shows the shuffled row numbers (Col A) and the random numbers used for sorting (Col B). I'm new to VBA and can't figure out to return the entry of the array that corresponds to the shuffled row number in Col A, if that makes sense? I only want to see the shuffled entries and not the row numbers

How to shuffle an array in PHP while still knowing the original index?

不羁的心 提交于 2019-12-13 07:16:28
问题 How do you shuffle a PHP array while still knowing the original index? I have a simple array in PHP (e.g. ["a", "b", "c", [5, 10]] ). The shuffle() function allows you to shuffle the elements. However I still wish know what the original index was. How can I do this? 回答1: See shuffle doc 2nd example: <?php function shuffle_assoc(&$array) { $keys = array_keys($array); shuffle($keys); foreach($keys as $key) { $new[$key] = $array[$key]; } $array = $new; return true; } 回答2: Do you mean shuffle the

Shuffling php array without same value before or after

家住魔仙堡 提交于 2019-12-13 00:37:10
问题 To shuffle an array in php is easy but my problem is when i try to shuffle it without getting the same result before of after that key. Example: Array ( 0 => 1, 1 => 2, 2 => 3, 3 => 3 ) I must have a result without 3 coming together. Example of some array i want: Array ( 0 => 2, 1 => 3, 2 => 1, 3 => 3 ) I've tryed to check each item of the array, if that happens i shuffle it again, and check another time. But that seems to be waste both on time and process. EDIT: Here is the code i use: do {

Character Shuffler

梦想与她 提交于 2019-12-12 16:27:20
问题 I was just wondering if there's a way (using ASP.NET C#) to "shuffle" up the contents of a string, but still be able to click another button and "UNshuffle" it back to its original content withOUT saving the original content? Thank you :) Example: "This is not shuffled." "isuo .tffsnl iTh shed" ...And then I click the "UNShuffle" button and it becomes normal again: "This is not shuffled." 回答1: Well, you'd need to save something . One simple idea: Use a random number generator to generate a

Shuffle random picture from resources on button click

隐身守侯 提交于 2019-12-12 09:50:26
问题 I have 1 picture box, named studPic . What I want to get is, when I click "shuffle" button, to get random image from resources. private void button2_Click(object sender, EventArgs e) { ... } After research I've found following http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/38d36fa4-1f5f-43e9-80f6-3c9a4edc7705/ I'm newbie to C#.. Is there easier way to achieve this result? For example, without adding picture names? UPDATE List<string> pictureNames = new List<string>();

tensorflow dataset_ops shuffle()方法 (随机重新排列此数据集的元素)

五迷三道 提交于 2019-12-12 09:19:35
def shuffle ( self , buffer_size , seed = None , reshuffle_each_iteration = None ) : """Randomly shuffles the elements of this dataset. 随机重新排列此数据集的元素。 Args: buffer_size: A `tf.int64` scalar `tf.Tensor`, representing the number of elements from this dataset from which the new dataset will sample. tf.int64标量tf.Tensor,表示此数据集中要从中采样新数据集的元素数。 seed: (Optional.) A `tf.int64` scalar `tf.Tensor`, representing the random seed that will be used to create the distribution. See `tf.set_random_seed` for behavior. tf.int64标量tf.Tensor,表示将用于创建分布的随机种子。 有关行为,请参见“ tf.set_random_seed”。 reshuffle_each_iteration:

Difference between Python 2 and 3 for shuffle with a given seed

只谈情不闲聊 提交于 2019-12-12 08:43:00
问题 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 and languages... except for the code using random.shuffle . Example in Python 2.7: In[]: import random random.seed(42) print(random.random()) l = list(range(20)) random.shuffle(l) print(l) Out[]: 0.639426798458 [6, 8, 9, 15, 7, 3, 17, 14, 11, 16, 2, 19, 18, 1, 13, 10, 12, 4, 5, 0] Same input in

Best way to permute contents of each column in numpy

北慕城南 提交于 2019-12-12 08:27:55
问题 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([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >> # Shuffle each column independently to obtain something like array([[ 8, 5, 10, 7], [ 12, 1, 6, 3], [ 4, 9, 14, 11], [ 0, 13, 2, 15]]) 回答1: If your array is multi-dimensional, np.random.permutation permutes along the first axis (columns) by default: >>>

Can a seeded shuffle be reversed?

空扰寡人 提交于 2019-12-12 07:19:15
问题 Take this function, which is a seeded Fisher-Yates shuffle (the order is random, but reproducible given the same seed): function seeded_shuffle(array &$items, $seed = false) { $items = array_values($items); mt_srand($seed ? $seed : time()); for ($i = count($items) - 1; $i > 0; $i--) { $j = mt_rand(0, $i); list($items[$i], $items[$j]) = array($items[$j], $items[$i]); } } Can this algorithm be reversed? I.e., given the seed value and the shuffled array, can the array be "unshuffled" into its

A good way to shuffle and then unshuffle a python list

这一生的挚爱 提交于 2019-12-12 06:56:49
问题 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 the same method. One example would be that i shift the entire list to the right with 1 position and then i can shift the shuffled list with one position to the left so i can get the original list. But this seems kinda simple so i was wondering if they're more creative methods of doing this Edit: The idea would