1. 程式人生 > >[Python] Generating random numbers using numpy lib

[Python] Generating random numbers using numpy lib

gpo sin tin clas data body mean mea 1.4

import numpy as np 

def test_run():
    data=np.random.random((3,4))
    """
    [[ 0.80150549  0.96756513  0.18914514  0.85937016]
    [ 0.23563908  0.75685996  0.46804508  0.91735016]
    [ 0.70541929  0.04969046  0.75052217  0.2801136 ]]
    """

    data=np.random.rand(3,4)
    """
    [[ 0.48137826  0.82544788  0.24014543  0.56807129]
    [ 0.02557921  0.50690438  0.29423376  0.85673923]
    [ 0.32648763  0.97304461  0.6034564   0.70554691]]
    
""" data=np.random.normal(size=(2,3)) #mean=0, sd=1 """ [[ 1.57598046 0.06976049 -1.6502364 ] [ 0.30437287 -0.88249543 -0.04233034]] """ data=np.random.normal(50,10,size=(2,3)) #mean=50, sd=10 """ [[ 34.40308274 56.17179863 36.05758636] [ 57.38723594 41.43156664 65.54296858]]
""" print(np.random.randint(10)) #6 print(np.random.randint(0,10)) #9 print(np.random.randint(0,10,size=(5))) #[2 1 8 4 1] print(np.random.randint(0,10,size=(2,3))) """ [[0 2 4] [3 8 3]] """ if __name__ == "__main__": test_run()

[Python] Generating random numbers using numpy lib