Pick 1 of 2 Items Randomly with a Weighted Percent in Python and Ruby

preview_player
Показать описание
With a 1 line function you can randomly pick item A X% time and item B Y% time.

Hit the subscribe button to receive more videos like this!

REFERENCE LINKS
---------------------------------------------------

COURSES
---------------------------------------------------
Courses I've created that focus on web dev and deployment topics.

THE TOOLS I USE / GEAR
---------------------------------------------------

FOLLOW ME ELSEWHERE
---------------------------------------------------

TIMESTAMPS
---------------------------------------------------
0:00 -- Intro
0:38 -- Starting off with an evenly split sample without weights
1:52 -- Going over weighted sampling, starting off with the "why"
4:16 -- Breaking down the problem using dice rolls as a comparison
6:01 -- Running the Ruby code to pick a weighted sample
6:32 -- Going back to how our weighted_sample function works
8:31 -- Doing the same thing in Python
9:38 -- Python has an alternative built-in option with the choices function
11:44 -- With Python, which solution should you use?
Рекомендации по теме
Комментарии
Автор

Awesome 👍👍👍👍👍👍👍👍. Learn again very simple but very very

bhaveshverma