<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="RIGHT: auto"><FONT style="RIGHT: auto" face="arial, helvetica, sans-serif" size=2>Estou tentando rodar o programa de simulação de <SPAN class="" id=misspell-0>percolação (rede de bethe)</SPAN>, mas esta <SPAN class="" id=misspell-1>demandando</SPAN> um tempo de processamento muito alto, pois há preciso de muitas iterações. O computador que estou utilizando tem processador i3 e 4<SPAN class=mark id=misspell-2>gb</SPAN> de memória. Alguém pode me dar uma dica de como posso diminuir o tempo de processamento? Abaixo segue o código:</FONT></div>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"><SPAN lang=EN style="RIGHT: auto">
<div style="RIGHT: auto"><FONT style="RIGHT: auto" face="arial, helvetica, sans-serif" size=2>programa <- <SPAN class=mark id=misspell-3>function</SPAN>(f,n,m) {</FONT></div>
<div style="RIGHT: auto"><FONT face=Arial size=2># f: número máximo de filhos</FONT></div>
<div style="RIGHT: auto"><FONT face=Arial size=2># n: número de gerações</FONT></div>
<div style="RIGHT: auto"><FONT face=Arial size=2># m: número de iterações</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>S <- <SPAN class=mark id=misspell-4>matrix</SPAN>(0,101,2)</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>for (p <SPAN class=mark id=misspell-5>in</SPAN> <SPAN class=mark id=misspell-6>seq</SPAN>(0,1,<SPAN class=mark id=misspell-7>by</SPAN>=0.01)) {</FONT></div>
<div><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-8>pp</SPAN> <- 0</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>for (g <SPAN class=mark id=misspell-9>in</SPAN> 1:m) {</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>y <- 1</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>for (k <SPAN class=mark id=misspell-10>in</SPAN> 1:n) {</FONT></div>
<div style="RIGHT: auto"><FONT style="RIGHT: auto" face="arial, helvetica, sans-serif" size=2>y <- <SPAN class=mark id=misspell-11>sum</SPAN>(<SPAN class=mark id=misspell-12>rbinom</SPAN>(y,f,p))</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-13>if</SPAN> (y == 0) <SPAN class=mark id=misspell-14>break</SPAN></FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>}</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-15>if</SPAN> (y > 0) <SPAN class=mark id=misspell-16>pp</SPAN> <- <SPAN class=mark id=misspell-17>pp</SPAN> + 1</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>}</FONT></div>
<div style="RIGHT: auto"><FONT style="RIGHT: auto" face="arial, helvetica, sans-serif" size=2>S[p/0.01+1,1] <- p</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>S[p/0.01+1,2] <- <SPAN class=mark id=misspell-18>pp</SPAN>/m</FONT></div></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>}<VAR id=yui-ie-cursor></VAR></FONT></div>
<div style="RIGHT: auto">
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-19>return</SPAN>(S)</FONT></div></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>}</FONT></div>
<div style="RIGHT: auto">
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2></FONT> </div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-20>prog</SPAN> <- programa(2,100,1000)</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2><SPAN class=mark id=misspell-21>plot</SPAN>(<SPAN class=mark id=misspell-22>prog</SPAN>, <SPAN class=mark id=misspell-23>xlab</SPAN> = "p", <SPAN class=mark id=misspell-24>ylab</SPAN> = "Probabilidade de <SPAN class=mark id=misspell-25>Percolação</SPAN>")</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2></FONT> </div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>Desde já agradeço pela atenção!</FONT></div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2></FONT> </div>
<div style="RIGHT: auto"><FONT face="arial, helvetica, sans-serif" size=2>Tiago Vieira.</FONT></div></SPAN></div></div></body></html>