View Single Post
  #9  
Old 09-02-2013, 03:18 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
going off loriel's post... I came up with:

PHP Code:
function onCreated() {
  
temp.tmax 10;
  
temp.rand = function (m) { return int(((1-random(0,1)^0.5)) * m) };
  
  for (
temp.0temp.1000temp.i++) {
    
temp.("count_" temp.rand(temp.tmax))++;
  }
  for (
temp.0temp.temp.tmaxtemp.i++) {
    echo(
temp.i SPC temp.("count_" temp.i));
  }
}

/*
Sample:
0 179
1 170
2 145
3 126
4 115
5 95
6 75
7 59
8 27
9 9
*/ 
one other way I tried:

PHP Code:
function onCreated() {
  
temp.tmax 10;
  
temp.rand = function (m) {
    
temp.0;
    while (
random(0,1) > 0.5 && temp.m) {
      
temp.i++;
    }
    return 
temp.i;
  };
  
  for (
temp.0temp.1000temp.i++) {
    
temp.("count_" temp.rand(temp.tmax))++;
  }
  for (
temp.0temp.temp.tmaxtemp.i++) {
    echo(
temp.i SPC temp.("count_" temp.i));
  }
}

/*
Sample:
0 520
1 243
2 132
3 56
4 27
5 12
6 2
7 3
8 3
9 1
*/ 
I'm sure there's a math way to do it but **** it.
__________________
Quote:
Reply With Quote