R實戰:【常用函數】rnorm常態分佈_R

來源:互聯網
上載者:User

R實戰系列專欄

rnorm常態分佈(The Normal Distribution)函數

整體分布函數rnorm的函式宣告如下:

rnorm(n, mean = 0, sd = 1)

n:產生隨機數個數

mean:期望

sd:是方差

產生1000個隨機數,服從標準常態分佈

> rnorm(1000)   [1] -1.236751e+00  3.366310e-02 -1.118280e+00  2.248415e-01  1.036253e+00   [6] -4.981205e-01  1.417859e+00  7.423066e-01 -1.649157e+00  4.752631e-02  [11]  2.947828e-01 -1.693057e+00  3.417998e-01  8.506275e-01  2.413585e-01  [16]  1.205450e-01 -1.098822e+00 -1.944444e-01  1.247038e+00 -2.301569e+00  [21]  2.241360e-01  1.447203e+00  1.045240e+00  8.210854e-01 -1.949543e+00

繪製出這1000個數字

> x<-rnorm(1000)> plot(seq(length(x)),x)

繪製標準整體分布的函數映像

> x<-rnorm(3000) #產生3000個數字,符合標準正太分布> curve(dnorm(x), from=-5,to=5) #dnorm輸入x求出其正太分布函數,curve繪製該函數區間[-5,5]上的映像



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.