Edited at

# WAA03

## データ解析基礎論 a weekly assignment A03

#### WAA03.1

```# データのinputと正形
par(mfrow=c(1,1))
control <- dat[dat\$condition == "control",]
medicineA <- dat[dat\$condition == "medicine A",]
medicineB <- dat[dat\$condition == "medicine B",]

# figure1
plot(control\$w,control\$blood.pressure,pch = 19,xlab = "weight",
ylab = "blood pressure",col = "skyblue",ylim = c(60,160),xlim = c(40,80),
main = "relationship between blood pressure and weight (by medicine type)")
abline(lm(control\$blood.pressure~control\$w), lwd=2,col = "blue")
par(new = T)

plot(medicineA\$w,medicineA\$blood.pressure,pch = 17,col = "moccasin",
ylab = "",xlab = "",xaxt = 'n',yaxt ='n')
abline(lm(medicineA\$blood.pressure ~ medicineA\$w),
lwd = 2,col = "navajowhite2")

par(new = T)
plot(medicineB\$w,medicineB\$blood.pressure,pch = 15,col = "chocolate1",
ylab = "",xlab = "",xaxt = 'n',yaxt ='n')
abline(lm(medicineB\$blood.pressure ~ medicineB\$w),
lwd = 2,col = "chocolate")

legend("topleft", c('control','medicineA','medicineB'),
col=c('blue','navajowhite2','chocolate'),cex = 0.9,lwd = 2,pch = c(19,17,15))
```

```# figure2
par(mfrow=c(3,1))
plot(control\$w,control\$blood.pressure,pch = 19,xlab = "",
ylab = "blood pressure",col = "skyblue",ylim = c(60,160),xlim = c(40,80),
main = "relationship between blood pressure and weight (by medicine type)")
abline(lm(control\$blood.pressure~control\$w), lwd=2,col = "blue")
text(43, 140, 'Control',cex=2,col = "black")

plot(medicineA\$w,medicineA\$blood.pressure,pch = 17,col = "moccasin",
ylab = "blood pressure",xlab = "",ylim = c(60,160),xlim = c(40,80))
abline(lm(medicineA\$blood.pressure ~ medicineA\$w),
lwd = 2,col = "navajowhite2")
text(45, 140, 'Medicine B',cex=2,col = "black")

plot(medicineB\$w,medicineB\$blood.pressure,pch = 15,col = "chocolate1",
ylab = "blood pressure",xlab = "weight",ylim = c(60,160),xlim = c(40,80))
abline(lm(medicineB\$blood.pressure ~ medicineB\$w),
lwd = 2,col = "chocolate")
text(45, 140, 'Medicine B',cex=2,col = "black")
```

#### WAA03.2

```dbinom(3,10,0.5)
[1] 0.1171875
sum(dbinom(0:3,10,0.5))
[1] 0.171875
```

#### WAA03.3

```dbinom(2,20,0.5)
[1] 0.0001811981
sum(dbinom(0:2,20,0.5))
[1] 0.0002012253
sum(dbinom(0:2,20,0.5))+sum(dbinom(18:20,20,0.5))
[1] 0.0004024506
```