dimanche 2 juillet 2017

How to randomly mix N arrays in numpy?

I have a list of N numpy arrays of the same shape. I need to combine them into one array in the following way. Each element of the output array should be randomly taken from the corresponding position of one of the input array.

For example, if I need to decide what value to use at position [2,0,7], I take all the values locate at this position in all N input arrays. So, I get N values and I choose one value randomly.

To make it a bit more complex. I would like assign a probability to each input array so that probabilities of values to be selected depends on which input array it is.




Aucun commentaire:

Enregistrer un commentaire