Coding a custom probability function

Lazy

New member
Joined
Sep 21, 2021
Messages
1
Hello guys! One of my favourite hobbies is to code things, and I'm currently developing a small videogame. I know how to randomly generate a number (both integer and decimal) between two chosen numbers, and every number between those constants has the same chance to be the output. But now I have to generate a number in a very uncommon way (at least, as a developer):
I need to create a function (a programmer function, not a mathematical function) that generates a random decimal number between 0 and 1. The numbers will not be generated in an uniform way, but I need to get numbers around 0.8 with a higher probability than any other number (so 0.8 has to be the mode), and the probability of getting a number that's not 0.8 goes down on the edges (0 and 1). I know that there's a way to code my function that generates a random number given a probability distribution function, and I know how to create my coded function, but I have no clue on how to create the math function, aka the PDF. I'm not a mathematician and I'm not really good with math, so trying to explain my problem is really hard for me, and looking around on the internet I think I've seen some helpful articles like beta distribution functions and skewness, but I'm not sure if that's what I'm looking for, and I have no idea on how to use them.
Throwing a bunch of random numbers on Desmos online, I created something similar to what I want to achieve:
Cattura.PNG
where the 0.8 has the highest chance of being returned by the function, and 1 and 0 have very low chances. The function should not return values greather than 1 or lower than 0.
Any clue on how to help me solve this problem? Thanks anyway <3
 
Top