File: bard.R

package info (click to toggle)
r-cran-markovchain 0.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,864 kB
  • sloc: cpp: 2,847; sh: 13; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Bard PPT examples
#Page 8
require(matlab)
statesNames=as.character(0:3)
pg8<-zeros(4)
pg8[1,c(2,3)]<-0.5
pg8[2,1]<-1
pg8[3,4]<-1
pg8[4,c(1,4)]<-0.5
pg8Mc<-new("markovchain",transitionMatrix=pg8,states=statesNames, name="Page 8")
summary(pg8Mc)
#Page 9
statesNames=as.character(0:4)
pg9<-zeros(5)
pg9[c(1,2),c(1,2)]<-0.5
pg9[3,3]<-1
pg9[4,c(3,4)]<-1/2
pg9[5,1]<-1
pg9Mc<-new("markovchain",
           transitionMatrix=pg9,
           states=statesNames, 
           name="Page 9")
summary(pg9Mc)
#Page 10
statesNames=as.character(0:3)
pg10<-zeros(4)
pg10[1,c(2,3)]<-1/2
pg10[c(2,3),4]<-1
pg10[4,1]<-1
pg10Mc<-new("markovchain",
           transitionMatrix=pg10,
           states=statesNames, 
           name="Page 10")
summary(pg10Mc)
#Page 11
statesNames=as.character(1:5)
pg11<-zeros(5)
pg11[1,c(1,2)]<-c(0.4,0.6)
pg11[2,c(1,2)]<-c(0.5,0.5)
pg11[3,c(3,4)]<-c(0.3,0.7)
pg11[4,c(3,4,5)]<-c(5,4,1)/10
pg11[5,c(4,5)]<-c(0.8,0.2)

pg11Mc<-new("markovchain",
            transitionMatrix=pg11,
            states=statesNames, 
            name="Page 10")
summary(pg11Mc)