include misc.e
include file.e
include get.e
include msgbox.e
include uppersort.e
printf(1,"%s\n",{""})
atom T,R
T=0.1
R=10
atom S1,T1,R1,R2,RT,Tx,Tsum
sequence Boxes
Boxes=repeat(0,101)
with trace
function abs(atom x)
if x<0 then
return -x
else
return x
end if
end function
function RandResistor(atom R, atom T)
--This functions distribution was tested.
atom S1,T1
S1=rand(1000)
if S1<=500 then
S1=-1
else
S1=1
end if
T1=rand(1000)/1000
return R+S1*T*T1*R
end function
trace(1)
Tsum=0
for k=1 to 10000000 do
R1=RandResistor(R,T)
R2=RandResistor(R,T)
RT=R1+R2
Tx=(RT/(2*R))-1
Tsum+=Tx
if k/10000=floor(k/10000) then
?Tsum
end if
Tx=abs(Tx*1000)
for j=1+1e-6 to 101 do
if Tx<=j then
Boxes[j]+=1
if j=11 then
?Tx
sleep(1)
end if
exit
end if
end for
end for
Tsum=0
for k=1 to length(Boxes) do
printf(1,"%d\n",{Boxes[k]})
Tsum+=Boxes[k]
end for
?Boxes
?Boxes/10000000
?Tsum
atom fno
fno=open("Report.txt","w")
print(fno,Boxes)
close(fno)
sleep(222)