Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Robert Ricci
Evaluating Networked Systems
Commits
cb60fc16
Commit
cb60fc16
authored
Feb 24, 2015
by
Robert Ricci
Browse files
R Commands to be used during the lecture
parent
c1ee67ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
130 additions
and
0 deletions
+130
-0
lectures/lecture12/rcommands.txt
lectures/lecture12/rcommands.txt
+130
-0
No files found.
lectures/lecture12/rcommands.txt
0 → 100644
View file @
cb60fc16
Determining probababilities for different execution times:
Execution time is normally distributed with mean 10s, stddev 2s
Evaluate probability of having a runtime of 3s:
dnorm(3, mean = 10, sd = 2)
Plot the probability curve over 20s:
x <- seq(0,20, by = .1)
plot(x,dnorm(x, mean = 10, sd = 2))
Plot the PDF over 20s:
plot(x,pnorm(x, mean = 10, sd = 2))
Part A: Probability of time being more than 12s
1 - probability of less than 12s
1 - pnorm(12, mean = 10, sd = 2)
Part B: Probability of time being less than 9s
pnorm(9, mean = 10, sd = 2)
Part C: Probability of time being between 8 and 12s
pnorm(12, mean = 10, sd = 2) - pnorm(8, mean = 10, sd = 2)
Part D: 95% of exection time
Invert the PDF:
x2 = seq(0,1,by = 0.01)
plot(x2,qnorm(x2, mean = 10, sd = 2))
qnorm(0.95, mean = 10, sd = 2)
----------------------------------------------------------------------
Basic confidence intervals:
Mean number of Disk I/Os:
I <- c(28, 31, 12, 18, 42, 29, 33, 45, 53, 34, 42, 21, 36, 23, 36,
36, 27, 9, 11, 19, 35, 24, 31, 29, 16, 23, 34, 24, 38, 15, 18, 35, 27)
Show quantiles:
quantile(I)
Part A: 10th and 90th percentiles
quantile(I,c(.10,.90))
Part B: Mean
mean(I)
Part C: 90% CI for the mean
Note: for double-sided 90% CI, qnorm() parameter is half as wide (95%)
sd(I)
length(I)
mean(I) - (qnorm(.95)*sd(I))/sqrt(length(I))
mean(I) + (qnorm(.95)*sd(I))/sqrt(length(I))
Part D: What fraction make less than 25 IOs, and what is 90% CI for this
fraction?
Ismall <- c(12, 18, 21, 23, 9, 11, 19, 24, 16, 23, 24, 15, 18)
p = length(Ismall) / length(I)
Proportion:
p + qnorm(0.95) * sqrt((p*(1-p))/length(I))
p - qnorm(0.95) * sqrt((p*(1-p))/length(I))
Part E: What is the one-sided 90% confidence interval for the mean?
Using formula from Secion 13.7
mean(I) - qt(.90,length(I)-1) * (sd(I)/sqrt(length(I)))
----------------------------------------------------------------------
Testing for differences:
System A:
A <- c(140, 120, 176, 288, 992, 144, 2736, 2796, 752, 17720, 96)
System B:
B <- c(98, 120, 141, 317, 893, 86, 1642, 1678, 376, 8860, 67)
Difference between the systems: (paired)
diff <- A - B
90% confidence interval for differences:
mean(diff) - (qnorm(.95)*sd(diff))/sqrt(length(diff))
mean(diff) + (qnorm(.95)*sd(diff))/sqrt(length(diff))
Part A: Graph the CIs
x3 <- seq(.80,.99, by = .01)
plot(x3,mean(diff) - (qnorm(x3)*sd(diff))/sqrt(length(diff)), type='l', ylim=c(-1000,3000))
lines(x3,mean(diff) + (qnorm(x3)*sd(diff))/sqrt(length(diff)))
Part B: How many measurements does it take to get a difference at 90%
confidence?
Bottom end of 90% confidence interval for A:
mean(A) - (qnorm(.95)*sd(A))/sqrt(length(A))
Upper end of CI for B:
mean(B) + (qnorm(.95)*sd(B))/sqrt(length(B))
So, we need:
mean(A) - (qnorm(.95)*sd(A))/sqrt(n)) >= mean(B) + (qnorm(.95)*sd(B))/sqrt(n)
Which becomes:
((qnorm(.95)*(sd(A) + sd(B)))/(mean(A) + mean(B)))^2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment