4-3. Exercises

Ex 1. 1μ—μ„œ 6κΉŒμ§€ λ²ˆν˜Έκ°€ μ ν˜€μžˆλŠ” λ™μΌν•œ 6개의 곡이 λ“€μ–΄ μžˆλŠ” μƒμžμ—μ„œ μž„μ˜λ‘œ 두 개의 곡을 κΊΌλƒˆμ„ λ•Œ λ‚˜μ˜¨ 번호의 평균을 XX 라 ν•˜μž.

  1. XX 의 ν™•λ₯ λΆ„ν¬ν•¨μˆ˜λ₯Ό κ΅¬ν•˜μ‹œμ˜€.

  2. XX 의 κΈ°λŒ€κ°’κ³Ό 뢄산을 κ΅¬ν•˜μ‹œμ˜€.

  3. XX κ°€ 4 이상일 ν™•λ₯ μ„ κ΅¬ν•˜μ‹œμ˜€.

Ex 2. 1μ—μ„œ 6κΉŒμ§€ λ²ˆν˜Έκ°€ μ ν˜€μžˆλŠ” λ™μΌν•œ 6개의 곡이 λ“€μ–΄ μžˆλŠ” μƒμžμ—μ„œ μž„μ˜λ‘œ 두 개의 곡을 κΊΌλƒˆμ„ λ•Œ λ‚˜μ˜¨ 번호 쀑 큰 숫자λ₯Ό X라 ν•˜μž.

  1. XX 의 ν™•λ₯ λΆ„ν¬ν•¨μˆ˜λ₯Ό κ΅¬ν•˜μ‹œμ˜€.

  2. XX 의 κΈ°λŒ€κ°’κ³Ό 뢄산을 κ΅¬ν•˜μ‹œμ˜€.

  3. XX κ°€ 4 이상일 ν™•λ₯ μ„ κ΅¬ν•˜μ‹œμ˜€.

Ex 3. 1μ—μ„œ 20κΉŒμ§€ λ²ˆν˜Έκ°€ μ ν˜€μžˆλŠ” λ™μΌν•œ 20개의 곡이 λ“€μ–΄ μžˆλŠ” μƒμžμ—μ„œ μž„μ˜λ‘œ n 개의 곡을 κΊΌλƒˆμ„ λ•Œ λ‚˜μ˜¨ 번호의 평균을 XnX_n 이라 ν•˜μž.

  1. n=2, 5, 10 각각에 λŒ€ν•˜μ—¬, XnX_n 의 ν™•λ₯ λΆ„ν¬ν•¨μˆ˜λ₯Ό κ·Έλž˜ν”„λ‘œ μž‘μ„±ν•˜μ—¬ λΉ„κ΅ν•˜λΌ.

  2. n=2, 5, 10 각각에 λŒ€ν•˜μ—¬, XnX_n의 κΈ°λŒ€κ°’κ³Ό 뢄산을 κ΅¬ν•˜μ—¬ λΉ„κ΅ν•˜λΌ.

  3. n=2, 5, 10 각각에 λŒ€ν•˜μ—¬, XnX_n이 15 이상일 ν™•λ₯ μ„ κ΅¬ν•˜μ—¬ λΉ„κ΅ν•˜λΌ.

[ Solution ]

library(Rstat)

# 20 Balls
ball <- 1:20
S2 <- urnsample2(ball, size=2); (N2 <- nrow(S2))
S5 <- urnsample2(ball, size=5); (N5 <- nrow(S5))
S10 <- urnsample2(ball, size=10); (N10 <- nrow(S10))
S15 <- urnsample2(ball, size=15); (N15 <- nrow(S15))


# Sample Mean and Probability Distribution 
X2 <- apply(S2,1,mean); T2 <- table(X2); P2 <- T2/N2; v2 <- as.numeric(names(T2))
X5 <- apply(S5,1,mean); T5 <- table(X5); P5 <- T5/N5; v5 <- as.numeric(names(T5))
X10 <- apply(S10,1,mean); T10 <- table(X10); P10 <- T10/N10; v10 <- as.numeric(names(T10))
X15 <- apply(S15,1,mean); T15 <- table(X15); P15 <- T15/N15; v15 <- as.numeric(names(T15))

# Probability Distribution Plot
pmax <- max(c(P2,P5,P10,P15))
win.graph(9,6); par(mfrow=c(2,2)); par(mar=c(2,2,3,2))
plot(v2, P2, type="h", main="n=2", ylim=c(0,pmax), xlim=c(1,20), lwd=2, col=2)
plot(v5, P5, type="h", main="n=5", ylim=c(0,pmax), xlim=c(1,20), lwd=2, col=2)
plot(v10, P10, type="h", main="n=10", ylim=c(0,pmax), xlim=c(1,20), lwd=2, col=2)
plot(v15, P15, type="h", main="n=15", ylim=c(0,pmax), xlim=c(1,20), lwd=2, col=2)

# Expected Value and Variance
disc.exp(v2,T2); disc.exp(v5,T5); disc.exp(v10,T10); disc.exp(v15,T15)

# P(X>=15)
PX2 <- sum(P2[v2 >= 15]); PX5 <- sum(P5[v5 >= 15])
PX10 <- sum(P10[v10 >= 15]); PX15 <- sum(P15[v15 >= 15])
cat(PX2, PX5, PX10, PX15, "\n")

Last updated

Was this helpful?