Generating a random number between two values from an array in Python -
Assume that I have a single column float array of non-integer values:
data = [1.1; 1.2; 1.3; 1.4; 1.5]
I want to generate random numbers between the two sequential values in this array and want to store those values in a new array. The first value in the new array of ie will be a random number between 1.1 and 1.2, which will be random random numbers 1.2 and 1.3 and so on.
I want to get a new array such as data_rand = [1.15; 1.24; 1.37; 1.46] Based on the basic data array.
My question is (how will I / what is the best way) in an array, through all the values, again and again, produces a non-integer random number between each pair of pairs after the numbers in the array, By saving these random numbers in a new array? Can this small 5-value data provide an example based on the array? Or tell me in the right direction for each step of the process.
import random rand_data = map (random. [Figures: - 1], data [1 : and b > You can map this function to two slides in your list (the first piece removes the last element, the second piece removes the first element), in your example, two slices will look like this: [ 1.1, 1.2, 1.3, 1.4] and [1.2, 1.3, 1.4, 1.5] .
Comments
Post a Comment