Coding Math: Episode 47 - Weighted Random

preview_player
Показать описание
Weighted random functions allow you to randomly choose between multiple options, while specifying the exact odds of getting any one option.
Рекомендации по теме
Комментарии
Автор

thanks a million. I was solving a leetcode question on weighted probabilty. Your video helped a ton

jamjam
Автор

You should get way more views!
Your videos are so cleanly made.

Anyway, excited for that fractal video :D

freshtauwaka
Автор

Very clear easier to understand now I understand how weighted random works and was trying to figure it out thank you still getting my head around the for loop you softcoded it to subtract the chance value

letsgettomillwithoutvids
Автор

The exact thing I wanted, with the best explanation and a perfect showcase. Thank you.

puppyguard
Автор

I hope to implement this idea to generate random behaviors that change over time. This is exactly what I needed!

rib_rob_personal
Автор

im working with a different language but this helped me so much ^^ you explained everything very well while keeping my attention, even with my adhd lol

taylozen
Автор

thank you! I'm a Unity developer, and I followed this pretty well.

richardosborn
Автор

I used this weighted random algorithm to generate random mates based on their fitness values for a genetic algorithm.

kamoroso
Автор

Thank you for this. I can't believe this never crossed my mind for how to do this

AngeofDrkness
Автор

Was stuck on how to implement a weighted enemy spawn in my game.. this cleared all the doubts... Thankyou sir! Love from Pakistan ❤❤❤

syeddaniyalhaidernaqvi
Автор

Please keep making these! You've changed my coding career!

AfterthoughtTV
Автор

Very very useful video, thank you for providing

_laryssa
Автор

Ok, i am like 1 minute in and I have to admit. I did not expect this to be in Javascript at all.
You're exactly what i'm looking for, sir. Thank you.

harrygray
Автор

This weighs in favor of the earlier results you check though, such as if nothing has a 25% chance and a gold piece has a 20% chance, only 75% of the time the gold piece has a chance to be picked, meaning its actual percentage is 15% (20%*75%)? Or am i mathing wrong?

If you randomize the order of prizes every time, though, then that should correct for this.

ephemeraldgames
Автор

{ banana, 3 },
{ apple, 1},
{ pineapple, 5}

if the array contains the items blow in the order, the first element is banana which means if the random number is less than 3, banana will get picked every time.
if the number is grater than 1, the result is acceptable. However, If the random number is less than 1, we expect the item to be apple. unfortunately, the result will be banana since we loop through from the first index of the array which is banana.

before call the function sorting process should get done in advance in order to get the expected results.

susi
Автор

This was so good thanks, but I was wondering, what if I want the percentage to be exact, like the demon should appear exactly 10 times out of 100?

rishitchakraborty
Автор

That was so nice, very usable. Keep up the good work!

zjelco
Автор

I used this to create randomized loot tables. thank you so much..

SintaxErorr
Автор

Thank you for that man! It was really helpful

umppo
Автор

One question are the computerised roulette machines fixed, or can they be fixed in a negative or positive way.?

a-k