octave:2> x=linspace(pi/2,pi,100); octave:3> H=x.^2.*sin(3*x); octave:4> plot(x,H) octave:5> x=linspace(pi/2,2*pi,100); octave:6> H=x.^2.*sin(3*x); octave:7> plot(x,H) octave:8> epsilon=0.01 epsilon = 0.010000 octave:9> vepsilon=exp(-H/epsilon) vepsilon = Columns 1 through 5: 1.4384e+107 3.9162e+112 4.5454e+115 1.0055e+116 2.1145e+113 Columns 6 through 10: 2.4234e+107 1.0254e+98 1.3143e+85 5.1777e+68 7.9907e+48 Columns 11 through 15: 7.8173e+25 1.0000e+00 4.3881e-29 2.1831e-59 5.0448e-91 Columns 16 through 20: 2.6858e-123 1.9198e-155 1.2166e-186 4.9021e-216 9.3397e-243 Columns 21 through 25: 6.1674e-266 9.6709e-285 2.1840e-298 3.6121e-306 1.7693e-307 Columns 26 through 30: 7.8532e-302 6.9883e-289 1.9169e-268 1.6769e-240 3.1792e-205 Columns 31 through 35: 5.7468e-163 2.8082e-114 6.8215e-60 1.0000e-00 7.2967e+62 Columns 36 through 40: 1.5456e+128 4.1220e+194 4.7427e+260 Inf Inf Columns 41 through 45: Inf Inf Inf Inf Inf Columns 46 through 50: Inf Inf Inf Inf Inf Columns 51 through 55: Inf Inf 2.1671e+295 1.0864e+205 9.8827e+105 Columns 56 through 60: 1.0000e+00 1.1906e-111 2.8010e-225 0.0000e+00 0.0000e+00 Columns 61 through 65: 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 Columns 66 through 70: 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 Columns 71 through 75: 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 Columns 76 through 80: 4.9407e-324 4.1752e-167 1.0000e-00 3.4754e+172 Inf Columns 81 through 85: Inf Inf Inf Inf Inf Columns 86 through 90: Inf Inf Inf Inf Inf Columns 91 through 95: Inf Inf Inf Inf Inf Columns 96 through 100: Inf Inf Inf 2.0868e+240 1.0000e+00 octave:10> vepsilon/sum(vepsilon) ans = Columns 1 through 12: 0 0 0 0 0 0 0 0 0 0 0 0 Columns 13 through 24: 0 0 0 0 0 0 0 0 0 0 0 0 Columns 25 through 36: 0 0 0 0 0 0 0 0 0 0 0 0 Columns 37 through 48: 0 0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Columns 49 through 60: NaN NaN NaN NaN 0 0 0 0 0 0 0 0 Columns 61 through 72: 0 0 0 0 0 0 0 0 0 0 0 0 Columns 73 through 84: 0 0 0 0 0 0 0 NaN NaN NaN NaN NaN Columns 85 through 96: NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Columns 97 through 100: NaN NaN 0 0 octave:11> plot(x,H) octave:12> exp(1000) ans = Inf octave:13> exp(500) ans = 1.4036e+217 octave:14> exp(600) ans = 3.7730e+260 octave:15> exp(700) ans = 1.0142e+304 octave:16> exp(800) ans = Inf octave:17> exp(900)/exp(800) ans = NaN octave:18> exp(900-800) ans = 2.6881e+43 octave:19> P=[0,1/3,2/3;1/3,0,2/3;1,0,0] P = 0.00000 0.33333 0.66667 0.33333 0.00000 0.66667 1.00000 0.00000 0.00000 octave:20> ls octave:21> [V,D]=eig(P') V = 7.2524e-01 8.1650e-01 7.0711e-01 2.4175e-01 -4.0825e-01 -7.0711e-01 6.4466e-01 -4.0825e-01 -1.4122e-16 D = 1.00000 0.00000 0.00000 0.00000 -0.66667 0.00000 0.00000 0.00000 -0.33333 octave:22> v=(V(:,1)/sum(V,:1))' parse error: syntax error >>> v=(V(:,1)/sum(V,:1))' ^ octave:22> v=(V(:,1)/sum(V(:,1))' > octave:22> v=(V(:,1)/sum(V(:,1)))' v = 0.45000 0.15000 0.40000 octave:23> v*P ans = 0.45000 0.15000 0.40000 octave:24> simulazione(P,500,@funzione) error: error creating function handle "@funzione" error: evaluating argument list element number 3 octave:24> simulazione(P,500,@funzione) ans = 3 octave:25> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.39200 octave:26> v v = 0.45000 0.15000 0.40000 octave:27> [i,s]=simulazione(P,500,@funzione) i = 2 s = 0.38800 octave:28> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.39200 octave:29> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.39400 octave:30> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.40000 octave:31> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.39122 octave:32> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40120 octave:33> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40918 octave:34> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.39122 octave:35> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.41317 octave:36> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.40120 octave:37> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.38922 octave:38> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40120 octave:39> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40918 octave:40> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.40319 octave:41> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40918 octave:42> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.40120 octave:43> [i,s]=simulazione(P,500,@funzione) i = 3 s = 0.42715 octave:44> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.38922 octave:45> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.39721 octave:46> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.38922 octave:47> [i,s]=simulazione(P,500,@funzione) i = 2 s = 0.40120 octave:48> [i,s]=simulazione(P,500,@funzione) i = 1 s = 0.40918 octave:49> v v = 0.45000 0.15000 0.40000 octave:50> v*[20;30;40] ans = 29.500 octave:51> clear funzione octave:52> [i,s]=simulazione(P,500,@funzione) i = 1 s = 29.541 octave:53> [i,s]=simulazione(P,500,@funzione) i = 1 s = 29.441 octave:54> [i,s]=simulazione(P,500,@funzione) i = 2 s = 29.441 octave:55> [i,s]=simulazione(P,500,@funzione) i = 3 s = 29.581 octave:56> [i,s]=simulazione(P,500,@funzione) i = 3 s = 29.621 octave:57> k=[0:9] k = 0 1 2 3 4 5 6 7 8 9 octave:58> lambda=2.5 lambda = 2.5000 octave:59> exp(-lambda)*lambda.^k./factorial(k) ans = Columns 1 through 5: 8.2085e-02 2.0521e-01 2.5652e-01 2.1376e-01 1.3360e-01 Columns 6 through 10: 6.6801e-02 2.7834e-02 9.9406e-03 3.1064e-03 8.6290e-04 octave:60> s=exp(-lambda)*lambda.^k./factorial(k) s = Columns 1 through 5: 8.2085e-02 2.0521e-01 2.5652e-01 2.1376e-01 1.3360e-01 Columns 6 through 10: 6.6801e-02 2.7834e-02 9.9406e-03 3.1064e-03 8.6290e-04 octave:61> sum(s) ans = 0.99972 octave:62> diary off