Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 114
# From 6.3 FE 2 N = matrix(RDF,[[0.25,0,0.8],[.25,.25,.05],[0.5,.75,0]]) show(N)
# From 6.3 FE 2 w/ some outflow N = matrix(RDF,[[0.2,0,0.8],[.2,.25,.05],[0.3,.55,0]]) show(N)
(0.20.00.80.20.250.050.30.550.0)\displaystyle \left(\begin{array}{rrr} 0.2 & 0.0 & 0.8 \\ 0.2 & 0.25 & 0.05 \\ 0.3 & 0.55 & 0.0 \end{array}\right)
# If include plant->plant, consumer -> consumer print "Adjacency Matrix #1:" P = matrix(RDF,[[1,0,1],[1,1,1],[1,1,0]]) show(P) print "Adjacency Matrix #1 - Normalized" P2 = matrix(RDF,[[1/3,0,1/2],[1/3,1/2,1/2],[1/3,1/2,0]]) # Normalized show(P2) print "Eigenvectors of normalized adj matrix #1" P2.eigenvectors_right() # If don't include print "Adjacency Matrix #2 - Normalized - Eigenvectors" Q = matrix(RDF,[[0,0,1],[1,0,1],[1,1,0]]) Q2 = matrix(RDF,[[0,0,1/2],[1/2,0,1/2],[1/2,1,0]]) # Normalized show(Q2) Q2.eigenvectors_right() # Looks like principal eigenvector has largest value for consumer, which implies that is most important part of food web (I would expect producers to be the most important)
Adjacency Matrix #1:
(1.00.01.01.01.01.01.01.00.0)\displaystyle \left(\begin{array}{rrr} 1.0 & 0.0 & 1.0 \\ 1.0 & 1.0 & 1.0 \\ 1.0 & 1.0 & 0.0 \end{array}\right)
Adjacency Matrix #1 - Normalized
(0.3333333333330.00.50.3333333333330.50.50.3333333333330.50.0)\displaystyle \left(\begin{array}{rrr} 0.333333333333 & 0.0 & 0.5 \\ 0.333333333333 & 0.5 & 0.5 \\ 0.333333333333 & 0.5 & 0.0 \end{array}\right)
Eigenvectors of normalized adj matrix #1 [(1.0000000000000004, [(-0.3841106397986881, -0.7682212795973757, -0.5121475197315837)], 1), (0.21712927295533266, [(-0.7801055290649249, 0.598802669063579, 0.1813028600013458)], 1), (-0.3837959396219991, [(-0.5550693922285759, -0.24104362714869784, 0.7961130193772734)], 1)] Adjacency Matrix #2 - Normalized - Eigenvectors
(0.00.00.50.50.00.50.51.00.0)\displaystyle \left(\begin{array}{rrr} 0.0 & 0.0 & 0.5 \\ 0.5 & 0.0 & 0.5 \\ 0.5 & 1.0 & 0.0 \end{array}\right)
[(1.0000000000000004, [(0.3713906763541043, 0.5570860145311556, 0.7427813527082072)], 1), (-0.5 + 7.740554994819442e-09*I, [(0.7071067811865475 + 1.0946797853968453e-08*I, -2.366423949090489e-16 - 1.0946797853968458e-08*I, -0.7071067811865477)], 1), (-0.5 - 7.740554994819442e-09*I, [(0.7071067811865475 - 1.0946797853968453e-08*I, -2.366423949090489e-16 + 1.0946797853968458e-08*I, -0.7071067811865477)], 1)]
# Sum of throughputs T = vector([1,1,1/0.85]) F = N # Normalized flow matrix G = matrix(RDF,[[0.2,0,0.8/0.85],[.2,.25,.05/0.85],[0.3,.55,0]]) show(G)
(0.20.00.9411764705880.20.250.05882352941180.30.550.0)\displaystyle \left(\begin{array}{rrr} 0.2 & 0.0 & 0.941176470588 \\ 0.2 & 0.25 & 0.0588235294118 \\ 0.3 & 0.55 & 0.0 \end{array}\right)
# Matrix of indirect flows where i = # of iterations Gindirect = zero_matrix(RDF,3,3) for i in srange(2,100): Gindirect += G^i if i % 10 == 0: print "i = " + str(i) show(Gindirect) # Doesn't converge to 1 matrix
i = 10
(1.328570504521.704561303441.482727330960.5378347281660.6252760459530.7221959395690.8348386137260.9570236032781.12002602816)\displaystyle \left(\begin{array}{rrr} 1.32857050452 & 1.70456130344 & 1.48272733096 \\ 0.537834728166 & 0.625276045953 & 0.722195939569 \\ 0.834838613726 & 0.957023603278 & 1.12002602816 \end{array}\right)
i = 20
(1.541251366631.961912964591.746986942380.6276210785810.7339210031140.8337568128650.9737585928571.125122120691.29263620166)\displaystyle \left(\begin{array}{rrr} 1.54125136663 & 1.96191296459 & 1.74698694238 \\ 0.627621078581 & 0.733921003114 & 0.833756812865 \\ 0.973758592857 & 1.12512212069 & 1.29263620166 \end{array}\right)
i = 30
(1.568669500581.995089942421.781054410210.6391960432810.7479271476580.8481388907360.9916677060181.146792824161.31488855981)\displaystyle \left(\begin{array}{rrr} 1.56866950058 & 1.99508994242 & 1.78105441021 \\ 0.639196043281 & 0.747927147658 & 0.848138890736 \\ 0.991667706018 & 1.14679282416 & 1.31488855981 \end{array}\right)
i = 40
(1.572204157851.999367011241.785446278120.6406882503420.7497327745710.849992981760.9939764910391.149586541251.31775726195)\displaystyle \left(\begin{array}{rrr} 1.57220415785 & 1.99936701124 & 1.78544627812 \\ 0.640688250342 & 0.749732774571 & 0.84999298176 \\ 0.993976491039 & 1.14958654125 & 1.31775726195 \end{array}\right)
i = 50
(1.572659834451.999918397131.786012463550.6408806208570.7499655501610.8502320051860.9942741321471.149946698231.31812708576)\displaystyle \left(\begin{array}{rrr} 1.57265983445 & 1.99991839713 & 1.78601246355 \\ 0.640880620857 & 0.749965550161 & 0.850232005186 \\ 0.994274132147 & 1.14994669823 & 1.31812708576 \end{array}\right)
i = 60
(1.57271857881.999989480021.786085454340.6409054206420.7499955588380.8502628193140.9943125030771.149993128511.31817476226)\displaystyle \left(\begin{array}{rrr} 1.5727185788 & 1.99998948002 & 1.78608545434 \\ 0.640905420642 & 0.749995558838 & 0.850262819314 \\ 0.994312503077 & 1.14999312851 & 1.31817476226 \end{array}\right)
i = 70
(1.572726151931.99999864381.786094864080.640908617750.749999427460.8502667917720.9943174497331.149999114151.31818090855)\displaystyle \left(\begin{array}{rrr} 1.57272615193 & 1.9999986438 & 1.78609486408 \\ 0.64090861775 & 0.74999942746 & 0.850266791772 \\ 0.994317449733 & 1.14999911415 & 1.31818090855 \end{array}\right)
i = 80
(1.572727128241.999999825161.786096077150.6409090299110.749999926190.8502673038880.994318087441.14999988581.31818170092)\displaystyle \left(\begin{array}{rrr} 1.57272712824 & 1.99999982516 & 1.78609607715 \\ 0.640909029911 & 0.74999992619 & 0.850267303888 \\ 0.99431808744 & 1.1499998858 & 1.31818170092 \end{array}\right)
i = 90
(1.57272725411.999999977461.786096233540.6409090830450.7499999904850.8502673699080.9943181696511.149999985281.31818180306)\displaystyle \left(\begin{array}{rrr} 1.5727272541 & 1.99999997746 & 1.78609623354 \\ 0.640909083045 & 0.749999990485 & 0.850267369908 \\ 0.994318169651 & 1.14999998528 & 1.31818180306 \end{array}\right)