#include Global $QL =0, $LEC = 0, $AEC = 0, $SS = 0, $Next_Arr, $Next_Dep Global $div, $percent Global $a, $b $Next_Arr = rand_exp(6) $Next_Dep = $Next_Arr + rand_exp(10) ;next arrival (enter to system) and next deparcher (output) While ($AEC < 1000) ;number of inputs! if ($Next_Arr < $Next_Dep) Then if ($SS = 0) Then $SS = 1 ;server status $Next_Arr = $Next_Arr + rand_exp(6) Else If ($QL = 9) Then ;queue lenth is 9 $LEC += 1 ;number of loss pockets! $Next_Arr = $Next_Arr + rand_exp(6) Else $QL += 1 $NextArr = $Next_Arr + rand_exp(6) EndIf if ($QL = 0) Then $SS = 0 $Next_Dep = $Netxt_Arr + rand_exp(10) Else $QL -= 1 $Next_Dep = $Next_Dep + rand_exp(10) EndIf EndIf EndIf WEnd test() Func test() $div = $LEC / 1000 $percent = $div * 100 ;calculate loss pockets ConsoleWrite ($percent & "%" &@CRLF) ConsoleWrite ($LEC & @CRLF) EndFunc ;--------------------- exponential distribution formula (where I have problem)---------------------- Func rand_exp($lambda) $a = Random(0,1,0) $b = ((-1)*($lambda))*Log($a) EndFunc