0

I'm a programmer and terrible with math notations, so sorry for the bad formatting.

I have tree points, lets call them P, A and B. I have the distance from P to A and P to B, and I want to choose the point A or B randomly, but weighted depending on what is closer.

So if P to A is 2 units, and P to B is 14 units, I want to have a much higher chance of getting A. The exact chances or not terribly important, but if A is like 10 times further, is should basically be 10 times more likely.

So for I have this:

PA = P to A  
PB = P to B
Ratio = PA / PB
NormRatio = sigmoid(Ratio)
if (NormRatio < Random(0, 1))  
   Choose A  
else  
   Choose B

Now, I'm aware what ranges a sigmoid function works over, so this does not work. But I suspect the answer something along these lines.

Can anybody point me in the right direction?

Thanks!

Mockarutan
  • 101
  • 1
  • 1
    I think i just realized I don't need to calculate the ratio or "normalize" anything. I can just randomize a value from 0 to the sum of the two distances and the see on which of the two ranges the random value falls on... – Mockarutan Jan 12 '20 at 13:25
  • 1
    I would separately try the ratio's of $$\frac{PA}{PA+PB} or \frac{PB}{PA+PB}$$ each of these would range from zero to one. – poetasis Jan 12 '20 at 13:28

0 Answers0