-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha1p5.R
More file actions
34 lines (24 loc) · 733 Bytes
/
a1p5.R
File metadata and controls
34 lines (24 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
EXPSIZE <- 1000000;
count <- 0;
decodedCount <- 0;
while (count < EXPSIZE) {
channelSelector <- runif(1, min = 0, max = 1);
decoderSuccess <- runif(1, min = 0, max = 1);
if (channelSelector < 0.5) {
if (decoderSuccess <= 0.8)
decoded <- TRUE;
} else if (0.5 <= channelSelector && channelSelector < 0.8) {
if (decoderSuccess <= 0.9)
decoded <- TRUE;
} else if (0.8 <= channelSelector) {
if (decoderSuccess <= 0.7)
decoded <- TRUE;
}
if (decoded) {
decodedCount <- decodedCount + 1;
decoded <- FALSE;
}
count <- count + 1
}
X = sprintf( "Probability of decoded after %d tests %f", EXPSIZE, (1.0*decodedCount) / EXPSIZE);
print(X);