This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Decay

By: a guest on Jun 19th, 2013  |  syntax: Octave  |  size: 0.95 KB  |  views: 94  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. % Cantidad inicial de partículas:
  2. n = 100;
  3. % Tasa de decaimiento:
  4. lambda = 1;
  5. % Tiempos aleatorios de decaimiento:
  6. T1 = rande(n, 1) / lambda;
  7. T2 = rande(n, 1) / lambda;
  8. T3 = rande(n, 1) / lambda;
  9.  
  10. % Tiempos auxiliares para graficar:
  11. t = linspace(0, max(max([T1 T2 T3]))*1.1, 1000);
  12. % Proceso:
  13. N1 = sum(T1 >= t);
  14. N2 = sum(T2 >= t);
  15. N3 = sum(T3 >= t);
  16.  
  17. % Media:
  18. p = exp(-lambda*t);
  19. u = n*p;
  20. % Desvío:
  21. d = sqrt( u .* (1-p));
  22.  
  23. % Probabilidades:
  24. P = [];
  25. for i = 0:n
  26.     P = [P; (p.^i).*(1-p).^(n-i)*bincoeff(n, i)];
  27. end
  28. % P = flipud(P);
  29.  
  30.  
  31. figure(1);
  32. colormap(summer);
  33. brighten(0.5);
  34.  
  35. imagesc(t, 0:n, P, [0 1]);
  36. axis([0 t(end) 0 n], 'xy');
  37. hold on;
  38. plot(   t, [N1; N2; N3],
  39.         t, u, '-g');
  40. legend( 'Proceso 1',
  41.         'Proceso 2',
  42.         'Proceso 3',
  43.         'Media');
  44.  
  45. colorbar()
  46. xlabel('Tiempo [s]');
  47. ylabel('Cantidad de particulas vivas');
  48. title('Decaimiento');
  49. print('decaimiento.png', '-dpng', '-S1024, 600');
  50. pause
clone this paste RAW Paste Data