Python probability question

Asked 2 years ago, Updated 2 years ago, 21 views

List z is as follows

z=[1,2,3,4,5]

You want to see the possibility that the smaller the number, the higher the probability that the number will be drawn.

For example, 1 is 50% Two is 20 percent Three is 15% Four is nine percent 5 is a 6% chance

I'm going to send the selected value to a new list.

I'd appreciate it if you could help me realize the possibility of being chosen with a certain probability

python

2022-09-21 19:04

1 Answers

Keep it simple,

A list of 100 numbers, 1 for 50, 2 for 20...Make 5 with 6 pieces and mix them with random module shuffle.

You can take the mixed list and cut it into elements 0 through 9 to find the probability, and...And so on and so on. There's a lot of course.


2022-09-21 19:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.