samedi 5 juin 2021

Remapping Random Float value to logarithmic scale

I have a Random float that gives me a value between 0 and 1. I now want to remap that value so that 50% of the time the result is 0.01, 25% of the time it't 0.02, 12.5% of the time it's 0.04....

Somewhat like this:

  • 50% = 0.01
  • 25% = 0.02
  • 12.5% = 0.04
  • 6.25% = 0.08
  • 3.125% = 0.16
  • 1.5625% = 0.32
  • 0.78125% = 0.64

Or with other words remapping 0.0 - 0.5 to 0.00 - 0.01 and 0.50 - 0.75 to 0.01 - 0.02...

I think I can do that with a logarithmic function but I can't figure out how.




Aucun commentaire:

Enregistrer un commentaire