상세 컨텐츠

본문 제목

R로 난수 생성하기_Generating random numbers in R

카테고리 없음

by Ultimatom 2024. 3. 11. 07:24

본문

728x90
반응형

R을 공부할 때나 시뮬레이션을 할 때 난수를 생성이 필요할 때가 있습니다. R로 난수를 만드는 방법을 공유합니다.

 

#10 random numbers between 0 and 1

runif(10) 

 

#10 random numbers with 0 mean and 1 SD
rnorm(10, 0, 1) 

 

#10 random/duplicate integers between -10 and 10

sample(-10:10, 10, replace=T) 

 

#10 random numbers between -1 and 1

runif(10)*sample(c(-1,1),10,replace=T) 

728x90

댓글 영역