Results 1 to 23 of 23

Thread: lotz of hard work right here (new include)

  1. #1
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    lotz of hard work right here (new include)

    tbis is a very cool include kinda think, it generates random numbers based on a gaussian (or normal) distribution. (google gaussian distribution on me) use the function gaussianbox(...,...,...,...) to click inside a box, but randomly and more likely towards the center. i am hoping for this to be included in the next version of srl, and i will update it very soon. enjoy!

    ps, i dont remember if there is rep on srl but if there is, ++

    wow, oops no attachment, what, no attachments allowed! (fixed, thnx dankness)
    ppps, wow, its size doesnt remind me of how huge of a job it was to make... kinda new to pascal...


    fine, dont leave comments, see if i care, i still updated the code...again...(just include this, not srl, this includes srl).

    THIS IS ALL OUT OF DATE, GO TO COMPLETE REVAMP INSTEAD

  2. #2
    Join Date
    Aug 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sounds like it would be a good script... probably good for random movements

  3. #3
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This just uses your code and shows its result... please run the code below and tell me if the results give a Normal Distribution (or gaussian distribution (which looks the same))

    Someone please post thier result... thanks (you should get at least 30,000 in your sample to show a reasonable level of confidence in your results)
    Code:
    {.include \srl\srl.scar}
    function findgaussian(min, max : integer) : integer;
    var
      values : array[-16..16] of extended;
      e, a, mypi, b, total, selected:extended;
      i,margin : integer;
    
    begin
      e := 2.718281828
      mypi := 3.1415926535897932354626433832795 {from memory}
      a := 2*mypi;
      a := sqrt(a);
      i := 1;
      b := 1875;
      b := b/10000;
    
      for i:=-16 to 16 do
        values[i] := pow(e, -pow((b*i),2)/2)/a;
    
      selected := random(4919578);
      selected:=selected/1000000;
      i:=-16;
      total:=0;
      while(i<=16) and (selected > total) do
      begin
        total := total+values[i];
        i:=i+1;
      end
      margin:= (max-min)/32;
      Result := random(margin)+margin*(i+16)+min;
      if margin=0 then
        Result:=random(max-min)+min;
    end;
    
    procedure TestFindGaussian(TotalNum: Integer);
    var
      i, temp, count: Integer;
      Num: Array of Integer;
    
    begin
      setarraylength(Num, TotalNum);
      repeat
        Count := Count + 1;
        temp := findgaussian(0, (TotalNum));
        Num[temp] := Num[temp] + 1;
        if Count mod 1000 = 0 then
        begin
          ClearDebug;
          Writeln('Result in %  press q to quiet  Total sample size: ' + inttostr(Count));
          for i := 0 to (TotalNum - 1) do
          begin
            writeln(inttostr(i) + ' --> ' + inttostr(round(Num[i]/Count*100)) + '%');
          end;
          writeln('');
        end;
      until IsKeyDown('q') or IsKeyDown('Q');
    end;
    
    begin
      TestFindGaussian(strtoint(Readln('Total number of digets to test (try 10)')));
    end.

  4. #4
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    alright flyboy, added your function, ps, for your tester, there has to be at least 32 digits or it will not be gaussian at all

  5. #5
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Result in % press q to quiet Total sample size: 31000
    0 --> 0%
    1 --> 0%
    2 --> 0%
    3 --> 0%
    4 --> 0%
    5 --> 0%
    6 --> 0%
    7 --> 0%
    8 --> 0%
    9 --> 0%
    10 --> 0%
    11 --> 0%
    12 --> 0%
    13 --> 0%
    14 --> 0%
    15 --> 0%
    16 --> 0%
    17 --> 0%
    18 --> 0%
    19 --> 0%
    20 --> 0%
    21 --> 0%
    22 --> 1%
    23 --> 0%
    24 --> 1%
    25 --> 1%
    26 --> 1%
    27 --> 1%
    28 --> 1%
    29 --> 1%
    30 --> 1%
    31 --> 1%
    32 --> 1%
    33 --> 1%
    34 --> 1%
    35 --> 1%
    36 --> 2%
    37 --> 2%
    38 --> 2%
    39 --> 2%
    40 --> 2%
    41 --> 2%
    42 --> 2%
    43 --> 2%
    44 --> 2%
    45 --> 3%
    46 --> 2%
    47 --> 2%
    48 --> 3%
    49 --> 3%
    50 --> 3%
    51 --> 3%
    52 --> 3%
    53 --> 3%
    54 --> 3%
    55 --> 3%
    56 --> 3%
    57 --> 2%
    58 --> 3%
    59 --> 3%
    60 --> 2%
    61 --> 2%
    62 --> 2%
    63 --> 2%
    64 --> 2%
    65 --> 2%
    66 --> 2%
    67 --> 2%
    68 --> 2%
    69 --> 1%
    70 --> 1%
    71 --> 1%
    72 --> 1%
    73 --> 1%
    74 --> 1%
    75 --> 0%
    76 --> 0%
    77 --> 0%
    78 --> 0%
    79 --> 0%
    80 --> 0%
    81 --> 0%
    82 --> 0%
    83 --> 0%
    84 --> 0%
    85 --> 0%
    86 --> 0%
    87 --> 0%
    88 --> 0%
    89 --> 0%
    90 --> 0%
    91 --> 0%
    92 --> 0%
    93 --> 0%
    94 --> 0%
    95 --> 0%
    96 --> 0%
    97 --> 0%
    98 --> 0%
    99 --> 0%

    its crazy how close it is to what youd expect, by the way, it samples from 3 standard deviations.
    Result in % press q to quiet Total sample size: 109000
    0 --> 0%
    1 --> 0%
    2 --> 0%
    3 --> 0%
    4 --> 0%
    5 --> 1%
    6 --> 1%
    7 --> 1%
    8 --> 2%
    9 --> 3%
    10 --> 3%
    11 --> 4%
    12 --> 5%
    13 --> 6%
    14 --> 7%
    15 --> 8%
    16 --> 8%
    17 --> 8%
    18 --> 8%
    19 --> 8% q
    20 --> 7%
    21 --> 6%
    22 --> 5%
    23 --> 4%
    24 --> 3%
    25 --> 0%
    26 --> 0%
    27 --> 0%
    28 --> 0%
    29 --> 0%
    30 --> 0%
    31 --> 0%

  6. #6
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What do you get when you use smaller numbers like you would in the game (12 or less)

  7. #7
    Join Date
    Sep 2006
    Posts
    63
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ...That is a very confusing script... Then it must be good lol (I don't know)

  8. #8
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it just does random, i could do it to work with smaller numbers, if you want, like how small would it really matter if its truly gaussian?

  9. #9
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The proplem I see is that it is only a normal distribution for a larger range. Smaller ranges give the same results as random()
    Code:
    Result in %  press q to quiet  Total sample size: 64000
    0 --> 5%
    1 --> 5%
    2 --> 5%
    3 --> 5%
    4 --> 5%
    5 --> 5%
    6 --> 5%
    7 --> 5%
    8 --> 5%
    9 --> 5%
    10 --> 5%
    11 --> 5%
    12 --> 5%
    13 --> 5%
    14 --> 5%
    15 --> 5%
    16 --> 5%
    17 --> 5%
    18 --> 5%
    19 --> 5%
    q
    Successfully executed
    Possibly consider using a variable for the variance. I suspect for a lot of our uses a variance of 0.2 - 0.6 would be appropriate

  10. #10
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i told you, only 32 and above is normal, for how small would you like it to work.

  11. #11
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lardmaster View Post
    i told you, only 32 and above is normal, for how small would you like it to work.
    sorry, I should have rescaned all the posts above prior to making comments...

    I would think you should make it accomidate all sizes of box to click within... That way a person could use it 100% of the time regaurdless of the box size needed.

    A typical application requiring a small value would be clicking within option boxes and 'Click to Continue', the box will have a large x value and smal y value .

    EDIT:
    Hmmmm if you have it print the total for each number Num[i] you will descover a huge hole in your math... sorry

  12. #12
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ???

  13. #13
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There is no fancy math here, just simple logic. What do you think?

  14. #14
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    your logic makes no sense to me, see my other post about the complete revam, the method is so simple it will astound you (plz explain your program)

  15. #15
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    just compare results. I just made a sliding odds system which creates a nice bell curve and can handle numbers from 0 to 100 easily. I'm sure a more simple formula could do what I just did, that's why I posted... its stll bulky and could be cut down a lot.

    I've been thinking if we just make a function which takes one number (lets say RandNum: Integer) in and returns it using 0 as the mean with its extreams being +/- RandNum. This will lend itself to fit into the existing MMouse function. Thus changing up the Mouse function since it just calls MMouse.

  16. #16
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Flyboy View Post
    just compare results. I just made a sliding odds system which creates a nice bell curve
    slidiing odds system??? i didnt know that odd numbers were so tangible that you could just slide em on down. your program is very complex and the system it uses strange variable names, which do not quite make sense for thier use. offset? this does not seem like it should equal the square of the maximum number plus 1. whats all this stuff with maxnumber +1?

  17. #17
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    It's not odd numbers. Wait til you take a stat class, until then don't worry about it.

  18. #18
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lardmaster View Post
    slidiing odds system??? i didnt know that odd numbers were so tangible that you could just slide em on down. your program is very complex and the system it uses strange variable names, which do not quite make sense for thier use. offset? this does not seem like it should equal the square of the maximum number plus 1. whats all this stuff with maxnumber +1?
    lol - yes there is a bit of strangness going on here. The wird variable names is cause this started as a full mouse() repacement, then got refined to just returning a normally distributed number. Since different formulas are needed for small numbers and big numbers, I just took a page from simulator building in spread sheets, where the objective is results not clean formulas. Thus it looks a lot more complicated than it is... I just splashed my thoughts onto SCAR and then tweaked till it gave the results I was after Here is the scivey on the logic behind it:

    Step 1:
    Take the first number 0 and put it in a lotter where its chance of winning is 1:MaxNumber^2
    if there is a winner... great we are done

    Step 2:
    Take the first two numbers (0 ,1) and put them in a lottery with odds 1MaxNumber^2 - MaxNumber)
    if ether number wins... great we are done

    Step 3:
    Take the first three numbers (0, 1, 2) put them in a lottery with odds 1MaxNumber^2 - (MaxNumber * 2))
    if there is a winner... great we are done

    Step 4:
    Keep doing as above till you reach MaxNumber

    Step 5:
    Randomly change the number to a negative number 50% of the time

    Step 6:
    if the answer is 0 then 50% of the time goto Step 1 the other 50% of the time... great we are done

    Step 7:
    For some reason every now and then I got a wierd huge number so I added a failsafe which checks if the number is beyond the possible range and if it is just use Random(MaxNumber) - very sloppy but given the frequency of this occurance, it does not statistically affect the results.

    If any of you have the time or care to please clean up this code and make it more cpu friendly, this is ok for small numbers ( less than 100) but gets cpu intensive for big numbers as the number of itterations gets huge as the number increases.

  19. #19
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    but why does this make a bell curve, to me it just seems to make a bunch of random lotterys ;(, check out my new gaussian procedure though

  20. #20
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry to be blunt, but who's formula did you rip. I'm having doubts at the moment if it is your original work since your having trouble understanding the concept of sliding odds. There's noting wrong with googling formulas and adapting them to our purposes in SCAR, but passing yourself off as a math wizz when you don't understand the formula your using does not make sence to me.

    P.S. Ok just re-read that... seemed a bit harsh. I do love what your trying to do, just feeling a little like im been conned.

    P.P.S. I just Re-re-read the above and decided I'm just in a bad mood... please disregaurd the whole post

  21. #21
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    its ok, the first program, i completely concieved by my self. the second one, i got from a website that said "how to make a gaussian distribution random number generator" so im assuming that they put it up there for other people to use the idea. and no, i am not a math wiz , but i do know a fair amount, i just havent taken any statistical mechanics classes, so i really dont understand the formula i am using... . but the algorithm for doing logorithms...i am proud of, i understand completely!

  22. #22
    Join Date
    Feb 2006
    Location
    Sunshine Coast, Qld. Australia
    Posts
    412
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks... I'm having one of those "BAD" weeks of my life... and I'm not talking about trivial stuff like a bad report card ether. Sorry if I took some of it out on you

  23. #23
    Join Date
    Sep 2006
    Location
    Scripter's Heaven
    Posts
    455
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmmm. i posted yesterday, but it isnt there, basicly, the first one was mine, the second one i googled, but i am proud of my ln finder which i did on my own. and no i not math wiz but i pretty good and not taken any statistical classes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. SRL Scripting = Hard? Indeed.
    By Torrent of Flame in forum News and General
    Replies: 27
    Last Post: 12-21-2008, 02:03 PM
  2. Bug, Very hard to figure!
    By faster789 in forum OSR Help
    Replies: 6
    Last Post: 04-07-2008, 09:37 AM
  3. Need help Hard :(
    By ZaSz in forum General
    Replies: 3
    Last Post: 02-18-2008, 07:07 AM
  4. Hard Problem
    By badandymitch in forum OSR Help
    Replies: 3
    Last Post: 05-03-2007, 01:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •