Can I specify a numpy dtype when generating random values?

前端 未结 3 662
粉色の甜心
粉色の甜心 2020-12-30 20:21

I\'m creating a numpy array of random values and adding them to an existing array containing 32-bit floats. I\'d like to generate the random values using the sa

3条回答
  •  太阳男子
    2020-12-30 20:32

    np.random.randn function randomly initializes the array object of a given shape to a "np.float64" You can find this out yourself by doing as follows:

    a = np.random.rand(2,3)
    b = a[1,2]
    print (type(b))
    print (type(a))
    

    output as follows:

    
    
    

提交回复
热议问题