I wanted to make a relatively simple algorithm, that isn't just randomly choosing a question. So for each question I have a value called numOfCorrect, when the user gets the answer correct it adds 1, if the user gets it wrong it subtracts 1. like this:
const questions = [
{question: "what is 9 + 10?", numOfCorrect: -5 ...},
{question: "what is the meaning of life?", numOfCorrect: -5 ...},
{question: "how do I get a bias for the incorrect?", numOfCorrect: 0 ...},
{question: "1 + 1 = 4?", numOfCorrect: 10 ...}
]
so if each numOfCorrect is 0, I would want each question to have an even chance of getting picked, so that's just picking a random question normally.
The questions will be sorted from the least numOfCorrect to the most. I don't want to just decrease the range to bias the first indexes. Instead I want the probability for the questions to increase or decrease based on the numOfCorrect value, so there should be a non zero chance for any of the questions to be picked.
I was thinking something like:
-
for a question with a negative numOfCorrect => 1 / questions.length * ( 1 + ( (1/question.numOfCorrect) * -1)), so for a value -5 it would be
0.25 * 1.2
which would be 0.3. So instead of 25% chance it would be 30%. -
for a question with positive numOfCorrect. If numOfCorrect was 1, then it would be 0.25 * 0.9, 2 would be 0.25 * 0.8...
Problem is they won't add to 1 (obviously). I don't know what I'm doing, I'm no mathematician.
So main question. How can pick a random question and bias the ones with a lower numOfCorrect, that will preferably exponentially increase/decrease their probability of being picked as the value numOfCorrect increases/decreases??
Aucun commentaire:
Enregistrer un commentaire