We are seeing lots of trends right now, especially in the digital space. Interestingly, one of them is powered by computer science. Weighted probability is used to power promotions, like spin-the-wheel to win, but under the hood, there’s a very complex algorithm.
The Uses of Weighted Probability
One use of weighted probability is fuzz testing. This is where randomized test data is used to improve software. Specific edge-case sequences have higher weights so that they can test the vulnerable parts of a given codebase. Virtual wheel spins that utilize random number generators also have weighted probability.
The outcome is set when you hit the button, but front-end CSS and JavaScript animations create the illusion of the wheel spinning.
Sainsbury’s Spin the Wheel Nectar promotion is an example here, as people have the chance to win their last shopping bill in Nectar points, but this doesn’t land as often as winning nothing or a small token. The Paddy Power casino also has a promotion called The Wonder Wheel.
The wheel can be spun on a daily basis to generate a reward. Some rewards are more likely to land than others, with weighted probability engines that run alongside random number generators to determine the prize. Sites like OptiMonk also detail other sites that have used spin-the-wheel promotions, including sites like The Body Shop, which use it to reward regular shoppers with deals or discounts on their next order.
As we are seeing more spin-to-win promotions now than ever, largely due to the fact that users spend 13 minutes on average interacting with dynamic content, the tech used to power them is becoming more advanced.
To simulate weighted probability, computer systems simulate a random number roll and then map it against cumulative weights.
Computer Science and Its Link to Weighted Probability
If you want to calculate weighted probability, one way to do that would be to add up the weights of your choices and then assign a sum. Each item has a weight and then a cumulative weight. This allows an item to have a higher chance of being awarded.
Computers then use either the Cumulative Probability Method or the Alias Method, as explained by Peter Stefek, to calculate the weights in the pool, generating a random decimal number or weight. Numbers are then subtracted from the main number until the value becomes zero or less. The item that triggers this is then selected. Items that have higher numbers are more likely to deplete the pool, resulting in 0.
Weighted probability is also often used in genetic algorithms that teach AI platforms. Neural networks are used to determine the next word to generate based on the current context. Inverse Probability Weighting is also used to correct biases in samples, which helps to ensure that polling data or survey data is accurate.
Some of the software that can be used to implement weighted choices include Python and JavaScript. It’s not just retail promotions that use weighted probability either; in fact, it’s all around us. When a mutual fund is used to calculate an annual return, the weighted average is usually done on the monetary value of the individual stocks.
Economic indexes also measure price changes by weighting certain everyday goods, such as bread and housing, against luxury goods, which have a higher weight.
The WACC, or Weighted Average Cost of Capital, is also used by people who work in financial analysis so that company shares can be calculated with the cost of debt and then equity. With so much use for weighted probability, the computer science behind it is only going to grow as the years go by.