9.8: Weighted Selection (for Genetic Algorithms) - The Nature of Code

In this video, I look at yet another technique for "pool selection" -- how to pick an item randomly from an array with a non-uniform distribution, i.e. some elements have higher probability of being picked than others. I use this same method in my Traveling Salesperson coding challenge, but it can be applied more broadly. Code: https://thecodingtrain.com/tracks/the... šŸ•¹ļø p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/s... šŸŽ„ Previous:    • 9.7:Ā GeneticĀ Algorithm:Ā PoolĀ SelectionĀ -Ā T...Ā Ā  šŸŽ„ Next:    • 9.9:Ā GeneticĀ Algorithm:Ā InteractiveĀ Select...Ā Ā  šŸŽ„ All:    • TheĀ NatureĀ ofĀ CodeĀ Ā  References: šŸ”— Nature of Code: https://nature-of-code-2nd-edition.ne... šŸ”— Even Better GA Selection Pool Algorithm: https://github.com/CodingTrain/Sugges... šŸ”— Genetic Algorithm: Random Pool Selection: https://github.com/CodingTrain/Sugges... Related Coding Challenges: šŸš‚    • CodingĀ ChallengeĀ 35:Ā TravelingĀ SalespersonĀ Ā  šŸš‚    • CodingĀ ChallengeĀ 95:Ā ApproximatingĀ theĀ Val...Ā Ā  Timestamps: 0:00 Hello 5:52 Explain improved algorithm 7:20 Github issues 8:01 Start coding 8:41 Normalize the fruit score 10:44 Pick a fruit randomly according to its probability 12:13 Diagram the algorithm 15:50 Verify the algorithm works 17:48 Advantages of the algorithm 18:16 Outro Editing by Mathieu Blanchette Animations by Jason Heglund Music from Epidemic Sound šŸš‚ Website: https://thecodingtrain.com/ šŸ‘¾ Share Your Creation! https://thecodingtrain.com/guides/pas... 🚩 Suggest Topics: https://github.com/CodingTrain/Sugges... šŸ’” GitHub: https://github.com/CodingTrain šŸ’¬ Discord: https://thecodingtrain.com/discord šŸ’– Membership: http://youtube.com/thecodingtrain/join šŸ›’ Store: https://standard.tv/codingtrain šŸ–‹ļø Twitter: Ā Ā /Ā thecodingtrainĀ Ā  šŸ“ø Instagram: Ā Ā /Ā the.coding.trainĀ Ā  šŸŽ„    • CodingĀ ChallengesĀ Ā  šŸŽ„    • StartĀ learningĀ here!Ā Ā  šŸ”— p5.js: https://p5js.org šŸ”— p5.js Web Editor: https://editor.p5js.org/ šŸ”— Processing: https://processing.org šŸ“„ Code of Conduct: https://github.com/CodingTrain/Code-o... This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecod... #poolselection #probability #p5js