mardi 1 août 2023

Create a funnel using random boolean

I would like to create a 4-column chart that represents a customer journey having the following roles:

  • at most left columns only numbers 1
  • at the second column 35% of the 1 is still 1 and the rest is 0
  • at the third column 15% of the 1 on the second column is still 1 and the rest is 0
  • at the fourth column 2.5% of the 1 on the third column is still 1 and the rest is 0

I have tried the function below but it didn't work because I get only 0 on the fourth column:

def create_user_journey_table():
return [[1, 0, 0, 0]]
current_page = user_journey[-1][:]
user_journey.append([1, next_page_2, next_page_3, next_page_4])

next_page_2 = 1 if random.random() < 0.35 else 0
next_page_3 = 1 if (next_page_2 == 1 and random.random() < 0.15) else 0
next_page_4 = 1 if (current_page[0] == 1 and random.random() < 0.028) else 0

user_journey = create_user_journey_table()

Does anyone have any clue?

Thank you a lot!




Aucun commentaire:

Enregistrer un commentaire