porhw5

17
Jane Hanger 905302277 POR IA4 1. >> P = [ 0.5 0.3 0.2; 0.2 0.6 0.2; 0.3 0.2 0.5] P = 0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000 >> P^3 ans = 0.3370 0.3850 0.2780 0.3100 0.4120 0.2780 0.3370 0.3580 0.3050 >> P^6667254 ans = 0.3265 0.3878 0.2857 0.3265 0.3878 0.2857 0.3265 0.3878 0.2857 >> P P = 0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000 >> n=3 n = 3

Upload: jane-hanger

Post on 08-Sep-2015

212 views

Category:

Documents


0 download

DESCRIPTION

probabilistic operations research

TRANSCRIPT

Jane Hanger905302277POR IA4

1.>> P = [ 0.5 0.3 0.2; 0.2 0.6 0.2; 0.3 0.2 0.5]

P =

0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000

>> P^3

ans =

0.3370 0.3850 0.2780 0.3100 0.4120 0.2780 0.3370 0.3580 0.3050

>> P^6667254

ans =

0.3265 0.3878 0.2857 0.3265 0.3878 0.2857 0.3265 0.3878 0.2857

>> P

P =

0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000

>> n=3

n =

3

>> target = 3

target =

3

>> itmax = 500

itmax =

500

>> [f,fptMean,fptMoment2,fptVar, fptCMean, fptCMoment2, ... fptCVar, fptCStdDev] = CondFpt(P, n, target, itmax);The vector of probs of ever hitting the target state,conditioned on definitely hitting the target state:

f =

1.0000 1.0000 1.0000

The vector of conditional fpt means, given the initial state and given that the target state is eventually visited:

fptCMean =

5.0000 5.0000 3.5000

The vector of conditional fpt variances, given the initial state and given that the target state is eventually visited:

fptCVar =

20.0000 20.0000 16.2500

The vector of conditional fpt std. dev.s, given the initialstate and given that the target state is eventually visited:

fptCStdDev =

4.4721 4.4721 4.0311

>> P

P =

0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000

>> eye(3)

ans =

1 0 0 0 1 0 0 0 1

>> work = eye(3)-P

work =

0.5000 -0.3000 -0.2000 -0.2000 0.4000 -0.2000 -0.3000 -0.2000 0.5000

>> work(1:3,3)=1

work =

0.5000 -0.3000 1.0000 -0.2000 0.4000 1.0000 -0.3000 -0.2000 1.0000

>> RHS = zeros(1,3)

RHS =

0 0 0

>> RHS(3) = 1

RHS =

0 0 1

>> work

work =

0.5000 -0.3000 1.0000 -0.2000 0.4000 1.0000 -0.3000 -0.2000 1.0000

>> RHS

RHS =

0 0 1

>> PI = RHS * inv(work)

PI =

0.3265 0.3878 0.2857

>> PI = RHS / work

PI =

0.3265 0.3878 0.2857

>> PI(1) * 7

ans =

2.2857

>> P

P =

0.5000 0.3000 0.2000 0.2000 0.6000 0.2000 0.3000 0.2000 0.5000

>> n=3

n =

3

>> target = 1

target =

1

>> itmax = 500

itmax =

500

>> [fsupKMatrix, f, fptMean, fptMoment2, fptVar, fptStdDev] = ... FPT_MATLAB( P, n, target, itmax );>> fptMean(1)

ans =

3.0625

>> fptMean(3)

ans =

3.7500

>> fptVar(3)

ans =

11.8750

3.>> P = [ 0.8 0.2 0 0; 0.1 0.8 0.1 0; 0.1 0 0.7 0.2; 0.1 0 0 0.9]

P =

0.8000 0.2000 0 0 0.1000 0.8000 0.1000 0 0.1000 0 0.7000 0.2000 0.1000 0 0 0.9000

>> P^3

ans =

0.5620 0.3880 0.0460 0.0040 0.2190 0.5620 0.1710 0.0480 0.2190 0.0500 0.3450 0.3860 0.2190 0.0500 0.0020 0.7290

>> eye(4)

ans =

1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

>> work = eye(4) - P

work =

0.2000 -0.2000 0 0 -0.1000 0.2000 -0.1000 0 -0.1000 0 0.3000 -0.2000 -0.1000 0 0 0.1000

>> work(1:4,4)=1

work =

0.2000 -0.2000 0 1.0000 -0.1000 0.2000 -0.1000 1.0000 -0.1000 0 0.3000 1.0000 -0.1000 0 0 1.0000

>> RHS = zeros(1,4)

RHS =

0 0 0 0

>> RHS(4)=1

RHS =

0 0 0 1

>> PI = RHS *inv(work)

PI =

0.3333 0.3333 0.1111 0.2222

>> PI = RHS / work

PI =

0.3333 0.3333 0.1111 0.2222

>> P

P =

0.8000 0.2000 0 0 0.1000 0.8000 0.1000 0 0.1000 0 0.7000 0.2000 0.1000 0 0 0.9000

>> n = 4

n =

4

>> target = 1

target =

1

>> itmax = 1000

itmax =

1000

>> [fsupKMatrix, f, fptMean, fptMoment2, fptVar, fptStdDev] = ... FPT_MATLAB( P, n, target, itmax );>> fptMean(4)

ans =

10.0000

>> fptVar(4)

ans =

90.0000

>> 1/sum(P(1,2:4))

ans =

5

5.>> P = [ 0.667 0.111 0.111 0.111; 0.25 0.3 0.25 0.2; 0.192 0.231 0.5 0.077; 0.312 0.25 0.438 0]

P =

0.6670 0.1110 0.1110 0.1110 0.2500 0.3000 0.2500 0.2000 0.1920 0.2310 0.5000 0.0770 0.3120 0.2500 0.4380 0

>> work = eye(4) - P

work =

0.3330 -0.1110 -0.1110 -0.1110 -0.2500 0.7000 -0.2500 -0.2000 -0.1920 -0.2310 0.5000 -0.0770 -0.3120 -0.2500 -0.4380 1.0000

>> work(1:4,4) = 1

work =

0.3330 -0.1110 -0.1110 1.0000 -0.2500 0.7000 -0.2500 1.0000 -0.1920 -0.2310 0.5000 1.0000 -0.3120 -0.2500 -0.4380 1.0000

>> RHS = [0 0 0 1]

RHS =

0 0 0 1

>> PI = RHS / work

PI =

0.4120 0.1972 0.2838 0.1070a.>> 12*PI

ans =

4.9436 2.3665 3.4057 1.2843

>> sum(12*PI)

ans =

12.0000

>> P^5

ans =

0.4230 0.1938 0.2763 0.1069 0.4065 0.1989 0.2875 0.1071 0.4017 0.2004 0.2908 0.1071 0.4067 0.1988 0.2874 0.1070

>> P^2

ans =

0.5286 0.1607 0.2059 0.1048 0.3522 0.2255 0.3154 0.1070 0.3058 0.2254 0.3628 0.1060 0.3547 0.2108 0.3161 0.1184

>> P^3

ans =

0.4650 0.1807 0.2477 0.1067 0.3852 0.2063 0.3000 0.1085 0.3631 0.2119 0.3181 0.1070 0.3869 0.2052 0.3020 0.1059

>> P^4

ans =

0.4361 0.1897 0.2673 0.1068 0.3999 0.2011 0.2919 0.1071 0.3896 0.2041 0.2992 0.1072 0.4004 0.2007 0.2916 0.1072

>> P*P^2

ans =

0.4650 0.1807 0.2477 0.1067 0.3852 0.2063 0.3000 0.1085 0.3631 0.2119 0.3181 0.1070 0.3869 0.2052 0.3020 0.1059

>> P^2*[3 1 1 1; 1 1.2 1 .8; 0.5 0.3 0.5 0.2; 0.2 .2 .1 0]

ans =

1.8704 0.8042 0.8027 0.6983 1.4610 0.7388 0.7460 0.5956 1.3455 0.7063 0.7232 0.5587 1.4566 0.7262 0.7354 0.5866

>> P^3

ans =

0.4650 0.1807 0.2477 0.1067 0.3852 0.2063 0.3000 0.1085 0.3631 0.2119 0.3181 0.1070 0.3869 0.2052 0.3020 0.1059

>> P

P =

0.6670 0.1110 0.1110 0.1110 0.2500 0.3000 0.2500 0.2000 0.1920 0.2310 0.5000 0.0770 0.3120 0.2500 0.4380 0

>> n = 4

n =

4

>> target = 4

target =

4

>> itmax = 1000

itmax =

1000

>> [fsupKMatrix, f, fptMean, fptMoment2, fptVar, fptStdDev] = ... FPT_MATLAB( PP, nn, ttarget, itmax );Undefined function or variable 'PP'. >> [fsupKMatrix, f, fptMean, fptMoment2, fptVar, fptStdDev] = ... FPT_MATLAB( P, n, target, itmax );>> fptMean(4)

ans =

9.3439

>> fptVar(4)

ans =

61.1049

7. >> P = [ 0.033 0.267 0.6 0.2; 0.333 0 0.133 0.533; 0.2 0.267 0.133 0.4; 0.1 0.6 0.2 0.1]

P =

0.0330 0.2670 0.6000 0.2000 0.3330 0 0.1330 0.5330 0.2000 0.2670 0.1330 0.4000 0.1000 0.6000 0.2000 0.1000

>> P^2a. ans =

0.2300 0.2890 0.1751 0.4089 0.0909 0.4442 0.3241 0.1731 0.1621 0.3289 0.2532 0.2755 0.2531 0.1401 0.1864 0.4298

>> work = eye(4) - P

work =

0.9670 -0.2670 -0.6000 -0.2000 -0.3330 1.0000 -0.1330 -0.5330 -0.2000 -0.2670 0.8670 -0.4000 -0.1000 -0.6000 -0.2000 0.9000

>> work(1:4,4) = 1

work =

0.9670 -0.2670 -0.6000 1.0000 -0.3330 1.0000 -0.1330 1.0000 -0.2000 -0.2670 0.8670 1.0000 -0.1000 -0.6000 -0.2000 1.0000

>> RHS = [0 0 0 1]

RHS =

0 0 0 1

>> PI = RHS / work

PI =

0.1789 0.2886 0.2364 0.2962

>> P

P =

0.0330 0.2670 0.6000 0.2000 0.3330 0 0.1330 0.5330 0.2000 0.2670 0.1330 0.4000 0.1000 0.6000 0.2000 0.1000

>> n = 4

n =

4

>> target = 4

target =

4

>> itmax = 1000

itmax =

1000b. >> [fsupKMatrix, f, fptMean, fptMoment2, fptVar, fptStdDev] = ... FPT_MATLAB( P, n, target, itmax );>> fptMean(1)

ans =

3.7326

>> [f,fptMean,fptMoment2,fptVar, fptCMean, fptCMoment2, ... fptCVar, fptCStdDev] = CondFpt(P, n, target, itmax)The vector of probs of ever hitting the target state,conditioned on definitely hitting the target state:

f =

1.1514 1.0564 1.0523 1.0594

The vector of conditional fpt means, given the initial state and given that the target state is eventually visited:

fptCMean =

3.2417 2.5419 2.7575 3.4209

The vector of conditional fpt variances, given the initial state and given that the target state is eventually visited:

fptCVar =

5.3175 5.0577 5.1597 5.2865

The vector of conditional fpt std. dev.s, given the initialstate and given that the target state is eventually visited:

fptCStdDev =

2.3060 2.2489 2.2715 2.2992

f =

1.1514 1.0564 1.0523 1.0594

fptMean =

3.7326 2.6853 2.9017 3.6242

fptMoment2 =

18.2227 12.1686 13.4310 17.9986

fptVar =

4.2905 4.9580 5.0111 4.8639

fptCMean =

3.2417 2.5419 2.7575 3.4209

fptCMoment2 =

15.8262 11.5192 12.7635 16.9889

fptCVar =

5.3175 5.0577 5.1597 5.2865

fptCStdDev =

2.3060 2.2489 2.2715 2.2992

>> fptCMean(1)

ans =

3.2417c.Given that it is a grip the expected number of times the arm will turn in the next 6 moves is 1.0733>> PI(1) * 6

ans =

1.0733d. Over the long run the use of the lift motor id 1.2208 times greater than that of the extention>> PI(2)/PI(3)

ans =

1.2208

9. >> P = [0 0.417 0.25 0.333; 0.208 0 0.292 0.5; 0.167 0.389 0 0.444; 0.167 0.5 0.333 0]

P =

0 0.4170 0.2500 0.3330 0.2080 0 0.2920 0.5000 0.1670 0.3890 0 0.4440 0.1670 0.5000 0.3330 0

>> P^2a. Starting on pad 2 the probability of being on pad 3, 2 jumps later is 0.2185ans =

0.1841 0.2638 0.2327 0.3195 0.1323 0.4503 0.2185 0.1989 0.1551 0.2916 0.3032 0.2501 0.1596 0.1992 0.1878 0.4535

>> work = eye(4) - P

work =

1.0000 -0.4170 -0.2500 -0.3330 -0.2080 1.0000 -0.2920 -0.5000 -0.1670 -0.3890 1.0000 -0.4440 -0.1670 -0.5000 -0.3330 1.0000

>> work(1:4, 4)= 1

work =

1.0000 -0.4170 -0.2500 1.0000 -0.2080 1.0000 -0.2920 1.0000 -0.1670 -0.3890 1.0000 1.0000 -0.1670 -0.5000 -0.3330 1.0000

>> RHS = [0 0 0 1]

RHS =

0 0 0 1

>> PI = RHS / work

PI =

0.1539 0.3077 0.2308 0.3076

b. The steady state probabilities of the behavior of the frog describe the fraction of the time the frog spends on lilypad j over the long run, where time of the actual jumps from lily pad i to j are assumed equal in length. c. The frog does not remember or care where he has been so his likelihood of moving to a particular pad from his current pad depends only on the distance of that pad.