I need to calculate the probability of each number whose sum is 1. Suppose we have an array
mass=[1,2,3,4,5]
You need to calculate the probabilities of these numbers.
algorithm:
for i:=1 to n do
I[i]:=i;
endfor;
for s:=n downto n-m+1 do
l:=random(1,s);
L[n-s+1]:=I[l];
I[l]:=I[s];
DEC(s);
endfor.
the first thing I did was calculate the probability for the numbers
def frange(x, y, jump):
while x < y:
yield x
x += jump
s = []
zn=[1,2,3,4,5]
a=0
b=2
for i in frange(a,b,(b-a)/len(zn)):
s.append(i)
print(s)
then I don't quite understand what to do.
Aucun commentaire:
Enregistrer un commentaire