1. Hello and welcome to the brand new home for PlayDota!
    Please read through our Welcome thread to see what's new!
    Dismiss Notice

Best Random Generation in Matlab

Discussion in 'Tech & Programming' started by mapdesigner, Dec 16, 2016.

  1. mapdesigner

    mapdesigner Member

    1,693
    68
    48
    Aug 11, 2011
    Hello guys,

    I want to do some tests for dota probability using matlab. I am wondering, what is the best function used to find certain chance %?

    I found these, but which one of them is suitable for the test? and what is the differnce
    here is what I found so far
    above info here https://uk.mathworks.com/help/matlab/random-number-generation.html
    This says that Randn is better than rand function http://globalsoftbay.blogspot.co.uk/2012/01/what-is-difference-between-rand-and.html

    Edit:

    according to dota wiki, PRD C for 25% C = 0.08475,

    when I ran it in this map code
    Code:
    n= 10^10;
    b1= 0;
    r1= 0;
    k=1;
    c=0.08475
    
    for i = 1:n
      a = rand; %i (100,1);
      if a <= k*c;
          k=1;
          r1=r1+1;
      else
          b1=b1+1;
          k=k+1;
      end
    end
    %total = r1+b1
    n
    100*b1/n
    100*r1/n
    
    
    here is the result I got:

    c = 0.0848
    n = 1.0000e+10
    ans =74.9988
    ans = 25.0012

    not sure, is C = 0.0848 is the actual value used? or is it just how it is printed (and 0.08475 is used) nvm simple test reveled it
     
    Last edited: Dec 16, 2016
  2. Blarrg

    Blarrg Member

    9,975
    198
    63
    Jun 12, 2009
    You want a uniform distribution for your application.