If you can't read please download the document
Upload
lenore-massey
View
69
Download
3
Embed Size (px)
DESCRIPTION
亂數函數 (Random-Number Function). Rung-Shiang Cheng Department of Computer and Communication, Kun Shan University [email protected]. Outline. 介紹亂數函數的使用方法 相關範例. 產生亂數 和 模擬生活中的隨機資料. 何時會用到亂數函數呢 ? 統計實驗 … 網路模擬 … ANSI C . 產生 10 個亂數,同時印出 RAND_MAX 的值 (1/2). Example. 把時間當成亂數的種子. - PowerPoint PPT Presentation
Citation preview
(Random-Number Function)Rung-Shiang ChengDepartment of Computer and Communication, Kun Shan [email protected]
Outline
? ANSI C
10RAND_MAX(1/2)Example
10RAND_MAX (2/2)
("0")
1. 2. n
1016Example: .
1016
0 ~ 1Example
0 ~ 1
m nExample: m + (rand() % (n m + 1) )
m n
mn
mn
m nm + (rand() / RAND_MAX) (n m)
m nCase 1: random (20, 60)
m nCase 2: random (0, 1)
NS-2NS-2?Network Simulator, version 2C++, OTCLRouter, Link, End point, TCP/IP protocolsEthernet, WiFi, Sensor Networks
(seed) (distribution) E.g. ParetoConstantUniformExponentialHyperExponentail
*
Uniform Distribution : min_: max_
*
NS-22(0 )
FTP
Error Model (Uniform Distribution)(1/2)TCL Scriptnode0node1( SimpleLink object)error rate : Specify error rateunit : Specify the unit of error (time, pkt, bits)Default: packetranvar : Specify the random variable for generating errors
Error Model (Uniform Distribution)(1/2)goodput
Error rate (1/2)AWK(sent_drop.awk)
Error rate (1/2)&: 5
? (Report)http://teachers.ksu.edu.tw/rscheng/illus/report.htm