21.4.22/R/トレーニングと実践
839 ワード
Today
講義
R番組第2期第9強
結果
学習内容
9.コイン投げ株シミュレーション
coin toss stock price simulationn <- 10000
stock_price <- vector(length = n)
current_stock <- 34
for(i in 1:n){
if(rbinom(1, 1, 1/2) == 1){
current_stock <- current_stock + 1
}else{
current_stock <- current_stock - 1
}
stock_price[i] <- current_stock
}
current_stock
stock_price
plot(stock_price, type = 'l', col = 'red')
Tomorrow
n <- 10000
stock_price <- vector(length = n)
current_stock <- 34
for(i in 1:n){
if(rbinom(1, 1, 1/2) == 1){
current_stock <- current_stock + 1
}else{
current_stock <- current_stock - 1
}
stock_price[i] <- current_stock
}
current_stock
stock_price
plot(stock_price, type = 'l', col = 'red')
Summary
Reference
この問題について(21.4.22/R/トレーニングと実践), 我々は、より多くの情報をここで見つけました https://velog.io/@actpjk/21.4.22-R-강의-수강-및-실습テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol