Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. function P()
  2. Sum=0
  3. Maxisp=5000
  4. Maxt=30000
  5. MatrixGammaBin=1:13
  6. MatrixExpBin=1:20
  7. MatrixWeibullBin=1:25
  8. MatrixS(Maxt)=0
  9. MatrixResult(Maxt)=0
  10. for isp=1:Maxisp
  11.  
  12. //Weibull
  13. TAU=-1
  14. for k=1:25
  15. while or([(TAU>30000), or(TAU<0)]) do
  16. R=grand(1,1,'unf',0,1)
  17. TAU=10000 * (-log(R))^(1/3) //k=3, lambda=10000
  18. end
  19. MatrixWeibull(k)=round(TAU)
  20. TAU=-1
  21. end
  22. //EndofWeibull
  23.  
  24. //Exp
  25. for k=1:20
  26. R=(grand(1,1,'unf',0,1))
  27. TAU = -(1 / 0.0001) * log(R)
  28. MatrixExp(k)=round(TAU)
  29. end
  30. //EndofExp
  31.  
  32. //Gamma
  33. R1=9;
  34. R2=9;
  35. R3=9;
  36. TAU=-1;
  37. MatrixGamma=1:13
  38. for k=1:13
  39. while or([(TAU>30000), or(TAU<0)]) do
  40. R1=grand(1,1,'unf',0,1)
  41. R2=grand(1,1,'unf',0,1)
  42. R3=grand(1,1,'unf',0,1)
  43. TAU=-(1 / 0.0001) * (log(R1) + log(R2) + log(R3))
  44. end
  45. MatrixGamma(k)=round(TAU)
  46. TAU=-1
  47. end
  48. //EndofGamma
  49.  
  50. for t=1:Maxt
  51. for i=1:13
  52. if MatrixGamma(i)>t then
  53. MatrixGammaBin(i)=1
  54. else
  55. MatrixGammaBin(i)=0
  56. end
  57. end
  58.  
  59. for ii=1:20
  60. if MatrixExp(ii)>t then
  61. MatrixExpBin(ii)=1
  62. else
  63. MatrixExpBin(ii)=0
  64. end
  65. end
  66.  
  67. for iii=1:25
  68. if MatrixWeibull(iii)>t then
  69. MatrixWeibullBin(iii)=1
  70. else
  71. MatrixWeibullBin(iii)=0
  72. end
  73. end
  74.  
  75. S = 1 - ((1 - MatrixWeibullBin(1) * MatrixExpBin(1)) * (1 - MatrixWeibullBin(2) * MatrixExpBin(2)) * (1 - MatrixWeibullBin(3) * MatrixExpBin(3) * MatrixGammaBin(1)) * (1 - MatrixWeibullBin(4) * MatrixExpBin(4) * MatrixGammaBin(2)) * (1 - MatrixWeibullBin(5) * MatrixExpBin(5) * MatrixGammaBin(3)) * (1 - MatrixWeibullBin(6) * MatrixWeibullBin(7) * MatrixExpBin(6) * MatrixGammaBin(4)) * (1 - MatrixWeibullBin(8) * MatrixWeibullBin(9) * MatrixExpBin(7) * MatrixGammaBin(5)) * (1 - MatrixWeibullBin(10) * MatrixWeibullBin(11) * MatrixExpBin(8) * MatrixGammaBin(6)) * (1 - MatrixWeibullBin(12) * MatrixWeibullBin(13) * MatrixExpBin(9) * MatrixGammaBin(7)) * (1 - MatrixWeibullBin(14) * MatrixWeibullBin(15) * MatrixExpBin(10) * MatrixGammaBin(8)) * (1 - MatrixWeibullBin(16) * MatrixWeibullBin(17) * MatrixExpBin(11) * MatrixExpBin(12) * MatrixGammaBin(9)) * (1 - MatrixWeibullBin(18) * MatrixWeibullBin(19) * MatrixExpBin(13) * MatrixExpBin(14) * MatrixGammaBin(10)) * (1 - MatrixWeibullBin(20) * MatrixWeibullBin(21) * MatrixExpBin(15) * MatrixExpBin(16) * MatrixGammaBin(11)) * (1 - MatrixWeibullBin(22) * MatrixWeibullBin(23) * MatrixExpBin(17) * MatrixExpBin(18) * MatrixGammaBin(12)) * (1 - MatrixWeibullBin(24) * MatrixWeibullBin(25) * MatrixExpBin(19) * MatrixExpBin(20) * MatrixGammaBin(13)))
  76. //TODO: исправить алгоритм суммирования
  77. MatrixS(t)=MatrixS(t)+S
  78. Sum=Sum+MatrixS(t)
  79. //Pt=((1/Maxisp)*Sum)
  80. //MatrixResult(t)=MatrixResult(t)+Pt
  81. Sum=0
  82. end
  83. print(%io(2),isp,clock())
  84. if modulo(isp,100)==0 then
  85. clf()
  86. plot2d(MatrixS)
  87. end
  88. end
  89. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement