Skip to Content
R 錦囊妙計
book

R 錦囊妙計

by Paul Teetor
January 2014
Beginner to intermediate
488 pages
8h 1m
Chinese
GoTop Information, Inc.
Content preview from R 錦囊妙計
8.10 將機率轉換為分位數
|
219
延伸資訊
本章「簡介」瞭解更多關於內建機率分配之資訊。
8.10 將機率轉換為分位數
問題點
給定機率
p
值和一個分配,您需要決定對應於
p
分位數
:即
x
的值,使得
P
(
X
x
) =
p
解決方案
R 中,每個內建的分配皆包括分位數函數,能將機率轉換為分位數。函數名稱為前綴
q」加上分配名稱,例如,
qnorm
函數是常態分配的分位數函數。
而且,分位數函數的第一個引數是機率;其餘引數則是分配的參數,如:平均數、標準
差、分配形狀,或是發生率等:
> qnorm(0.05, mean=100, sd=15)
[1] 75.3272
討論說明
計算分位數的用途之一為計算信賴區間。若我們想知道標準常態變數 95% 的信賴區間
α
= 0.05)時,則需要計算機率為
α
/2 = 0.025 (1 –
α
)/2 = 0.975 的分位數如下:
> qnorm(0.025)
[1] -1.959964
> qnorm(0.975)
[1] 1.959964
同樣地,分位數函數的第一個引數允許輸入向量的形式。因此,我們輸入分位數向量,
並將前述範例簡化為一行指令如下:
> qnorm(c(0.025,0.975))
[1] -1.959964 1.959964
如前所述,所有 R 內建的機率分配皆有對應的分位數函數。下列為常見的離散型分配分
位數函數:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

R 语言经典实例(原书第 2 版)

R 语言经典实例(原书第 2 版)

J.D. Long, Paul Teetor
優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769829