[Python] Generating random numbers using numpy lib

來源:互聯網
上載者:User

標籤:data   4.4   dom   pytho   1.5   div   class   5.5   gpo   

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.