4
When using this function Math.floor((Math.random() * 10) + 1)
I get a random number from 1 to 10. We assume that each number has a 10% chance so we have a 50% chance for Odd or Even, but if I wanted to manipulate those odds so that the function would be more likely to give me an Odd number, for example 70% chance of exiting an Odd number and 30% chance of exiting an Even number.
- It is possible to do this?
- What would be the applied logic and how can I do?
What is described in my role, is exactly the problem I want to solve ... I want to generate a random number between 1 and 10, but I want this number to have more chances of being Odd.
– Leo Letto
So my answer solves your problem. You understand it?
– Pablo Almeida
"x" is a random it being greater than 7 (70%) i Gero a pair, being smaller would be the 30% being an Odd, correct?
– Leo Letto
That’s it. It’s two draws. The first is this X to determine whether it’s going to be odd or even. Once this is determined, it calls the function that draws in a loop until the one that matches what was chosen comes out. I’m on the phone, so I did not put more details. Later edit to be more complete, but the idea is this.
– Pablo Almeida
I understood the applied logic, would this solution be a "gambiarra" or there is no more specific function for chance manipulation?
– Leo Letto