How to generate random numbers from the power function in NumPy with Python

1 Answer

0 votes
import numpy as np

floatnum = 2.0

randomnumbers = np.random.power(floatnum, size=30)

# Produces 30 values drawn from the Power distribution with exponent 2.0

print(randomnumbers)

   
'''
run:
 
[0.1740035  0.75182145 0.49597839 0.36973963 0.12025598 0.27882853
 0.86402424 0.67771898 0.90133237 0.3560534  0.49050153 0.98158343
 0.48664136 0.21238976 0.61693987 0.79968942 0.57462773 0.76397897
 0.6955343  0.31352032 0.77161529 0.96560834 0.61116719 0.80575677
 0.82586528 0.63886459 0.72805687 0.41758979 0.73627217 0.77142723]
   
'''

 



answered Feb 10 by avibootz
...