octave:2> intmax
ans = 2147483647
octave:3> P=randstoc(5);
octave:4> help invariantPotenze
'invariantPotenze' is a function from the file /home/accounts/personale/clrmrc90/aa1819/sistemi_stocastici/invariantPotenze.m


 [v,iter,stimaerrore] = invariantPotenze(P,tol,maxit)

 Calcola la probabilita' invariante mediante il metodo delle potenze
 (dunque calcola la probabilita' limite)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
octave:5> v=invariantPotenze(P,1e-6,100)
v =

   0.19294   0.26463   0.18546   0.13262   0.22435

octave:6> rigaP=@(i) P(i,:);
octave:7> invariantSIM(rigaP,100)
ans =

   0.17000   0.35000   0.13000   0.10000   0.25000

octave:8> invariantSIM(rigaP,1000)
ans =

   0.17500   0.26200   0.20800   0.14000   0.21500

octave:9> invariantSIM(rigaP,10000)
ans =

   0.18590   0.27190   0.18490   0.13580   0.22150

octave:10> i2j=(i) randdisc(rigaP(i));
parse error:

  syntax error

>>> i2j=(i) randdisc(rigaP(i));
                   ^

octave:10> i2j=@(i) randdisc(rigaP(i));
octave:11> invariantSIMij(i2j,10000)
ans =

   0.18910   0.26270   0.18160   0.13290   0.23370

octave:12> lambda=1.5
lambda =  1.5000
octave:13> s=@(k) exp(-lambda)*lambda^(k-1)/factorial(k-1);
octave:14> s(1)
ans =  0.22313
octave:15> s(2)
ans =  0.33470
octave:16> s(1:2)
error: for x^A, A must be a square matrix. Use .^ for elementwise power.
error: called from:
error:    at line -1, column -1
octave:16> s(1:2)
error: for x^A, A must be a square matrix. Use .^ for elementwise power.
error: called from:
error:    at line -1, column -1
octave:16> s=@(k) exp(-lambda)*lambda.^(k-1)./factorial(k-1);
octave:17> s(1:2)
ans =

   0.22313   0.33470

octave:18> sum(s(1:100))
ans =  1.00000
octave:19> format long e
octave:20> sum(s(1:100))
ans =    1.00000000000000e+00
octave:21> i2j = @(i) randdisc([1-sum(s(1:i)),s(3:-1:1)]);
octave:22> i2j = @(i) randdisc([1-sum(s(1:i)),s(i:-1:1)]);
octave:23> invariantSIMij(i2j,10000)
ans =

 Columns 1 through 3:

   5.89000000000000e-01   2.45400000000000e-01   1.01100000000000e-01

 Columns 4 through 6:

   4.34000000000000e-02   1.37000000000000e-02   6.20000000000000e-03

 Columns 7 and 8:

   1.00000000000000e-03   2.00000000000000e-04

octave:24> format 
octave:25> invariantSIMij(i2j,10000)
ans =

 Columns 1 through 5:

   5.6860e-01   2.3920e-01   1.0800e-01   4.7200e-02   2.0300e-02

 Columns 6 through 9:

   8.9000e-03   5.1000e-03   2.2000e-03   5.0000e-04

octave:26> invariantSIMij(i2j,10000)
ans =

 Columns 1 through 5:

   5.8610e-01   2.4400e-01   1.0290e-01   4.1000e-02   1.6800e-02

 Columns 6 through 9:

   7.0000e-03   1.8000e-03   2.0000e-04   2.0000e-04

octave:27> invariantSIMij(i2j,10000)
ans =

 Columns 1 through 5:

   5.7080e-01   2.4490e-01   1.0100e-01   4.6500e-02   1.8400e-02

 Columns 6 through 10:

   9.2000e-03   4.6000e-03   2.6000e-03   1.2000e-03   5.0000e-04

 Columns 11 and 12:

   1.0000e-04   2.0000e-04

octave:28> diary off