Search the Community

Showing results for tags 'probability'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Vizcur

    weightedPick random function

    I found this function really useful except for picking the last element, which is really really hard in comparison with the other elements, because only the number '1' in a random selection between 0 and 1 with double precision floating points can give the last element. Therefore, the probability of obtaining the last element is too low to be useful. var test = [0,1,2,3,4,5,6,7,8,9];for(i = 0; i< 1000000; i++){ rnd = this.game.rnd.weightedPick(test); if(rnd == 9) console.log(rnd);} PS: The way i solved this is by adding a "dummy"(or a placeholder) element in the last place of the array. So, any suggestion for a clean solution?. Thanks in advance.