統計計算與模擬 政治大學統計系余清祥 2004 年 3 月 15~24 日 第五、六週: 隨機變數模擬

Slides:



Advertisements
Similar presentations
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc.. Chap 5-1 Chapter 5 Some Important Discrete Probability Distributions Basic Business Statistics.
Advertisements

CPSC 531:Random-Variate Generation
Chapter 8 Random-Variate Generation
Cell Size Regulation in Bacteria Department of Physics, Harvard University, Cambridge, Massachusetts 02138, USA Ariel Amir.
統計計算與模擬 政治大學統計系余清祥 2004 年 3 月 29 日至 4 月 14 日 第七、九週:矩陣運算
Chapter Four Parameter Estimation and Statistical Inference.
Chapter 10 馬可夫鏈 緒言 如果讀者仔細觀察日常生活中所發生的 諸多事件,必然會發現有些事件的未來 發展或演變與該事件現階段的狀況全然 無關,這種事件稱為獨立試行過程 (process of independent trials) ;而另一些 事件則會受到該事件現階段的狀況影響。
第七章 抽樣與抽樣分配 蒐集統計資料最常見的方式是抽查。這 牽涉到兩個問題: 抽出的樣本是否具有代表性?是否能反應出母體的特徵?
Ch05 點估計與抽樣分配 授課老師 薛欣達. 學習目標 估計母體參數的樣本統計量 應用中央極限定理 根據估計式的需求性質判斷估計式的好壞 應用自由度的概念 利用樣板計算抽樣分配與相關的結果.
Section 1.2 Describing Distributions with Numbers 用數字描述分配.
Chapter Two Data Summary and Presentation. Statistics II2 敘述統計 Vs. 推論統計 n 敘述統計 : 使用分析方法或圖形來描述一組來自於母 體或樣本之資料 n 推論統計 : 利用抽樣方法取得一樣本, 並針對此樣本 計算樣本統計量, 以推論未之母體之參數.
Advanced Chemical Engineering Thermodynamics
第十三章 卡方檢定. 學 習 目 標學 習 目 標學 習 目 標學 習 目 標 1. 學習何謂多項試驗 。 2. 學習如何將一群觀測資料與其期望之分配相比較 與檢定。 3. 學習如何檢定兩變數間是否獨立 。
亂數產生器安全性評估 之統計測試 SEC HW7 姓名:翁玉芬 學號:
第四章 評價股票選擇權的數值方法 蒙地卡羅模擬與二項式模型 財務工程 呂瑞秋著.
Stat_chi21 類別資料 (Categorical data) 一種質性資料, 其觀察值可歸類於數個不相交的項目內, 例 : 性別, 滿意度, …, 一般以各項的統計次數表現. 分析此種資料,通常用卡方檢定 類別資料分析 卡方檢定 卡方檢定基本理論 一個含有 k 項的試驗,設 p i.
Random-Variate Generation. Need for Random-Variates We, usually, model uncertainty and unpredictability with statistical distributions Thereby, in order.
STAT0_sampling Random Sampling  母體: Finite population & Infinity population  由一大小為 N 的有限母體中抽出一樣本數為 n 的樣 本,若每一樣本被抽出的機率是一樣的,這樣本稱 為隨機樣本 (random sample)
第 4 章 迴歸的同步推論與其他主題.
STAT0_corr1 二變數的相關性  變數之間的關係是統計研究上的一大目標  討論二分類變數的相關性,以列聯表來表示  討論二連續隨機變數時,可以作 x-y 散佈圖觀察它 們的關係強度  以相關係數來代表二者關係的強度.
平均值檢定 假設 檢定 One Sample 平均值 是否為 u. One Sample—1 工廠甲過去向 A 公司購買原料, 平均交貨日約為 4.94 日, 標準差 現在 A 公司改組, 甲工廠繼續向 A 公司 購買, 隨機抽取 8 次採購, 平均日數為 4.29 日, 請問 A 公.
Section 2.2 Correlation 相關係數. 散佈圖 1 散佈圖 2 散佈圖的盲點 兩座標軸的刻度不同,散佈圖的外觀呈 現的相聯性強度,會有不同的感受。 散佈圖 2 相聯性看起來比散佈圖 1 來得強。 以統計數字相關係數做為客觀標準。
Simulation Modeling and Analysis
Chapter 9 Hypothesis tests with the t statistic. 當母體  為未知時 ( 我們通常不知 ) ,用樣本 s 來取代 因為用 s 來估計  ,所呈現出來的分佈已不 是 z distribution ,而是 t distribution.
基礎物理總論 基礎物理總論 熱力學與統計力學(三) Statistical Mechanics 東海大學物理系 施奇廷.
Young/Freeman University Physics 11e. Ch 18 Thermal Properties of Matter © 2005 Pearson Education.
1 CH 13- 規格、公差與可靠度  一定性、不一定性和可靠性  誤差、常態分配和品質規格  組合公差.
03/05/2003 Week #2 江支弘 Measuring Center or Average 量度中心或平均 Stemplot: Mean: 平均數 arithmetic average of observations Median: 中位數 middle value of... (in increasing.
1 政治大學東亞所選修 -- 計量分析與中國大陸研究黃智聰 政治大學東亞所選修 課程名稱:計量分析與中國大陸研究 (量化分析) 授課老師:黃智聰 授課內容:時間序列與橫斷面資料的共用 參考書目: Hill, C. R., W. E. Griffiths, and G. G. Judge, (2001),
Monte Carlo Simulation Part.2 Metropolis Algorithm Dept. Phys. Tunghai Univ. Numerical Methods C. T. Shih.
空間域之影像強化 3.1 背景介紹 3.2 基礎灰階值轉換 3.3 以灰階統計圖為基礎之處理 3.4 算術與邏輯運算 3.5 基礎空間域濾波
2009fallStat_samplec.i.1 Chap10 Sampling distribution (review) 樣本必須是隨機樣本 (random sample) ,才能代表母體 Sample mean 是一隨機變數,隨著每一次抽出來的 樣本值不同,它的值也不同,但會有規律性 為了要知道估計的精確性,必需要知道樣本平均數.
Integrated single vendor single buyer model with stochastic demand and variable lead time 指導教授:林燦煌 博士 指導教授:林燦煌 博士 研 究 生:黃笙源 研 究 生:黃笙源 M. Ben-Daya, M. Hariga.
Simulation Basics (模擬基本概念)
Monte Carlo Simulation Part.1 Dept. Phys., Tunghai Univ. Numerical Methods, C. T. Shih.
實用管理科學 陳明德、陳武林 著 前程文化 Ch14 決策分析 14-1 本章結構 隨機模式導論 決策分析步驟 決策分析模式與符號 非機率性模式分析 機率性模式分析 貝氏決策分析技術 決策樹的建立 風險分析與敏感度分析.
Fourier Series. Jean Baptiste Joseph Fourier (French)(1763~1830)
&TwoDOE Class 90a1 &2 Simple Comparative Experiments Statistical Plots Sampling and Sampling Distributions Hypothesis Testing Confidence Interval.
第七章 連續機率分配.
資料結構實習-一 參數傳遞.
Quasi-Monte Carlo Methods for Option Pricing
政治大學公企中心必修課-- 社會科學研究方法(量化分析)--黃智聰
Chapter 3 Entropy : An Additional Balance Equation
政治大學中山所共同選修 課程名稱: 社會科學計量方法與統計-計量方法 Methodology of Social Sciences 授課內容: Inference in the Simple Regression Model 日期: 2003 年 10 月日.
統計計算與模擬 政治大學統計系余清祥 2010 年 2 月 23 日 第一週:導論
Probability Distribution 機率分配 汪群超 12/12. 目的:產生具均等分配的數值 (Data) ,並以 『直方圖』的功能計算出數值在不同範圍內出現 的頻率,及繪製數值的分配圖,以反應出該 機率分配的特性。
統計計算與模擬 政治大學統計系余清祥 2003 年 5 月 26 日 ~ 6 月 3 日 第十四、十五週:蒙地卡羅積分
Chapter 7 Sampling Distribution
Continuous Probability Distributions Chapter 會計資訊系統計學 ( 一 ) 上課投影片 Continuous Probability Distributions §Unlike a discrete random variable.
2005/7 Linear system-1 The Linear Equation System and Eliminations.
Chapter 6 Probability & The Normal Distribution
連續隨機變數 連續變數:時間、分數、重量、……
A) Transformation method (for continuous distributions) U(0,1) : uniform distribution f(x) : arbitrary distribution f(x) dx = U(0,1)(u) du When inverse.
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc.. Chap 6-1 Chapter 6 The Normal Distribution and Other Continuous Distributions Basic Business.
Regression 相關 –Cross table –Bivariate –Contingency Cofficient –Rank Correlation 簡單迴歸 多元迴歸.
1 5 影像復原 5.1 影像衰減與復原模式 5.2 雜訊模式 5.3 具雜訊影像之復原 - 空間域濾波 5.4 具雜訊影像之復原 - 頻域濾波 5.5 線性空間不變系統之衰減 5.6 衰減函數之估計.
搬運機具數量對橋式機作業績效 之影響 報告者:郭塗城. 綱要 一、問題特性 二、貨櫃裝卸作業分解 三、模擬模式 四、模式核對 五、貨櫃裝卸作業績效影響因素之影響效果分析 六、不同情境之績效分析結果 七、範例.
財務管理概論 劉亞秋‧薛立言 合著 (東華書局, 2007)
CH 14-可靠度工程之數學基礎 探討重點 失效時間之機率分配 指數模式之可靠度工程.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
0 Simulation Modeling and Analysis: Input Analysis K. Salah 8 Generating Random Variates Ref: Law & Kelton, Chapter 8.
Statistical Distributions
Chapter 4-2 Continuous Random Variables 主講人 : 虞台文.
Chapter 5 Expectations 主講人 : 虞台文. Content Introduction Expectation of a Function of a Random Variable Expectation of Functions of Multiple Random Variables.
Gil McVean, Department of Statistics Thursday February 12 th 2009 Monte Carlo simulation.
Ch 8 實習.
Chapter 5 Expectations 主講人:虞台文.
政治大學統計系余清祥 2004年5月17日~ 5月26日 第十四、十五週:蒙地卡羅積分 、縮減變異數
Presentation transcript:

統計計算與模擬 政治大學統計系余清祥 2004 年 3 月 15~24 日 第五、六週: 隨機變數模擬

一般隨機變數的產生方式 均勻分配以外的隨機變數通常藉由下列方 法,透過均勻亂數產生。 Inverse Transform Method Composition Method Rejection (and Acceptance) Method Alias Method Table Method

Normal Distribution 與均勻分配類似,常態分配是最常用到 的分配之一。 常見的常態分配亂數產生法:  ( 但僅為近似 )  Box-Muller  Polar  Ratio-of-uniforms

( 近似法 )  因為 Y 的期望值與變異數等於 與標準常態分配相同。

Box and Muller(1958)  The best known “exact” method for the normal distribution. Algorithm 1. Generate U 1, U 2 ~ U(0,1) 2. Let  = 2  U 1 E = –logU 2 & R = 3. Then X = R cos  and Y = R sin  are independent standard normal variables.

Note: Using Box-Muller method with congruential generators must be careful. It is found by several researchers that a ( 乘數 ) = 131 c ( 增量 ) = 0 m ( 除數 ) = 2 35 would have X  (–3.3,3.6). See Neave (1973) and Ripley (1987, p.55) for further information.

Polar Method (recommended!)  Rejection method for generating two independent normal variables. Algorithm 1. Generate V 1, V 2 ~ U(-1,1) retain if 2. Let 3. Then X = CV 1 and Y = CV 2 are independent standard normal variables.

Ratio-of-uniforms (recommended!)  Similar to Polar method, Ratio-of-uniforms is a rejection method. Algorithm 1. Generate U 1,U 2 ~ U(0,1), and let 2. Let X = V / U 1, Z = X 2 /4  Suggest deleting this step! 3. Retain if Z < 1 – U 1  Suggest deleting this step! 4. Retain if 5. Then X is normally distributed.

Ratio of Uniform (Cauchy Distribution)  Ratio-of-uniforms can also be used to create random variables from Cauchy Distribution. Algorithm 1. Generate U 1, U 2 ~ U(0,1), and V= 2U 2 – 1 retain if 2. Then X = V / U 1 ~ Cauchy(0,1), i.e. e.g. 10,000 runs  p-value= (Acceptance rate = )

Inverse Transformation Method Generates a random number from a probability density function by solving the probability density function's variable in terms of randomly generated numbers. This is achieved as follows: We solve the inverse of the integral of our probability density function at an arbitrary point a F(a), in terms of a random number r. We generate a unique random variable a, as follows: a = F -1 (r). The foundation of this method is F(X) ~ U(0,1) for all X.

Note: Usually, we only use Inversion to create simpler r.v.’s, such as exponential distribution (i.e. Exp( ) = – log(U(0,1)). Although Inversion is a universal method, it may be too slow (unless subprograms to calculate F -1 are available).  In other words, although theoretically it is possible to create any r.v.’s, usually there are simpler methods.

Example 1. F(x) = x 2, 0 < x < 1  X = U 1/2. Example 2. Let and we want to generate the minimum and maximum of X’s.  Since which means we can generate these two r.v.’s by

Example 3. Generate X ~ Poisson( ), i.e. where i  {0, 1, 2,…}. Algorithm: 1. Generate U 1 ~ U(0,1) and let i = If let i = i + 1; Otherwise X = i. Note: This method can be used to generate any discrete distributions.

Notes: (1) If total number of classes 30, we start from the middle (or mode). (2) The expected number of trials is E(X)+1. (3) We can use “Indexed Search” to increase the efficiency:  Fix m, let Step 1.Generate U~U(0,1), let k=[mU] & i=q k Step 2.If let i = i + 1; Otherwise X = i.

Example 4. X ~ Poisson(10) (1) Usual method: 11 comparisons on average (2) Mode: Reduced to about 3.54 comparisons (3) Indexed search: we choose m = 5, i.e. Under 10,000 simulation runs (S-Plus), I found that one check on the table plus comparisons  (Comparing to 3.3 in Ripley’s book)

Composition Method We can generate complex distribution from simpler distributions, i.e. where F i (x) are d.f. of other variables.  Or, from a conditional distribution,

Example 1. To simulate x, where We define X 1 =0.1 for x  {1,2,…,10} & X 2 =0.2 for x  {2,4,…,10}. Let X= 0.5(X 1 + X 2 ). Example 2. X ~ B(5,0.2)  Sampling on each digit:

Example 3. Generate an r.v. X from Algorithm: 1. Generate U 1, U 2 from U(0,1) 2. Let Y  (U 1 ) -1/n 3. Return X  -log(U 2 )/y Note:

Rejection Method Generates random numbers for a distribution function f(x). This is achieved as follows: Define a comparison function h(x) such that it encloses the desired function f(x). Choose uniformly distributed random points under h(x). If a point lies outside the area under f(x) reject it and choose another point.

Illustration of the Rejection Method The following is an illustration of the rejection method using a square function for the comparison function.

Example 1. X ~ Beta(2,4), i.e. E(X)=1/3, Then we use g(x)=1, 0 < x < 1 as “envelop” to create f(x). Note: Algorithm: 1. Generate X, U 1 ~ U(0,1). 2. If return X. (Q: Rejection rate?)

Example 2. Generate Gamma(3/2,1), i.e. We want to generate X from The max. of f(x)/g(x) is obtained when since

Algorithm: 1. Generate U 1, U 2 ~ U(0,1) Let Y = -3log U 1 /2. 2. Return X = Y if Question: Why do we choose Y ~ Exp(2/3)?  Gamma(3/2,1) and Exp(2/3) have the same variance!

Alias method: Looks like “rejection” but it is indeed “composition”. Example 1. X ~ B(3,1/3), i.e.

Table method: (Composition) Example 1. X ~ B(3,1/3) P(X=0)= P(X=1)= P(X=2)= P(X=3)=

Algorithm: 1. Generate U ~ U(0,1) 2. If 其中 a 1 [.] = a 2 [.] = a 3 [.] =