From 704a5d6773ae6c982fd34fdf277dee88425e487d Mon Sep 17 00:00:00 2001 From: neilhacker <39994403+neilhacker@users.noreply.github.com> Date: Thu, 19 Sep 2019 15:29:40 +0100 Subject: [PATCH] Create frog_code --- .../frog_code | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 import itertools iterable = [1,2,3,4,5,6,7,8,9,10] z = 1/(len(iterable)+1) # this gives fraction that is missed in all groups as it is prob of the first jump current_prob=[] # will take the probabilites for the frog jumping once, twice ... current_prob.append(1/(iterable[-1]+1)) for x in iterable: a = list(itertools.combinations(iterable, x)) #this will give all combinations for x+1 jumps e.g if x=2 you get all subgroups that would lead to 3 jumps fractions = [] for i in range(0,len(a)): frac = 1 for j in a[i]: b = 1/frog_code diff --git a/import itertools iterable = [1,2,3,4,5,6,7,8,9,10] z = 1/(len(iterable)+1) # this gives fraction that is missed in all groups as it is prob of the first jump current_prob=[] # will take the probabilites for the frog jumping once, twice ... current_prob.append(1/(iterable[-1]+1)) for x in iterable: a = list(itertools.combinations(iterable, x)) #this will give all combinations for x+1 jumps e.g if x=2 you get all subgroups that would lead to 3 jumps fractions = [] for i in range(0,len(a)): frac = 1 for j in a[i]: b = 1/frog_code b/import itertools iterable = [1,2,3,4,5,6,7,8,9,10] z = 1/(len(iterable)+1) # this gives fraction that is missed in all groups as it is prob of the first jump current_prob=[] # will take the probabilites for the frog jumping once, twice ... current_prob.append(1/(iterable[-1]+1)) for x in iterable: a = list(itertools.combinations(iterable, x)) #this will give all combinations for x+1 jumps e.g if x=2 you get all subgroups that would lead to 3 jumps fractions = [] for i in range(0,len(a)): frac = 1 for j in a[i]: b = 1/frog_code new file mode 100644 index 0000000..b48784b --- /dev/null +++ b/import itertools iterable = [1,2,3,4,5,6,7,8,9,10] z = 1/(len(iterable)+1) # this gives fraction that is missed in all groups as it is prob of the first jump current_prob=[] # will take the probabilites for the frog jumping once, twice ... current_prob.append(1/(iterable[-1]+1)) for x in iterable: a = list(itertools.combinations(iterable, x)) #this will give all combinations for x+1 jumps e.g if x=2 you get all subgroups that would lead to 3 jumps fractions = [] for i in range(0,len(a)): frac = 1 for j in a[i]: b = 1/frog_code @@ -0,0 +1,32 @@ +import itertools +iterable = [1,2,3,4,5,6,7,8,9,10] +z = 1/(len(iterable)+1) # this gives fraction that is missed in all groups as it is prob of the first jump + +current_prob=[] # will take the probabilites for the frog jumping once, twice ... +current_prob.append(1/(iterable[-1]+1)) + +for x in iterable: + a = list(itertools.combinations(iterable, x)) +#this will give all combinations for x+1 jumps e.g if x=2 you get all subgroups that would lead to 3 jumps + fractions = [] + for i in range(0,len(a)): + frac = 1 + for j in a[i]: + b = 1/j + frac*=b + fractions.append(frac) + total = 0 + for y in fractions: + total+=y + current_prob.append(total*z) + +steps = iterable +steps.append(len(iterable)+1) +expected = 0 +for i in range(1,len(steps)+1): + expected=(i*current_prob[i-1])+expected + +for i in range(1,len(steps)+1): + print(f"Probabilty of haivng {i} jumps is {current_prob[i-1]}") + +print(expected)