Re: Vanilla junk problem. Suggestions? Theories?



Andrew Sidwell wrote:
Twisted wrote:
On Jul 17, 3:06 pm, Andrew Sidwell <ju...@xxxxxxxxxxx> wrote:
At the above URL, there is now a new table, which is a naive first try
by me to stop worse things appearing later on, with a slightly different
algorithm from the one Angband uses; a simpler one, making use of only
one set of min/max depth and rarity values. I think this should be good
enough.
So long as the item still has a chance to be generated deeper than the
"max" value, even if it becomes rarer that way the same as it does
above the "min" depth (traditional OOD item likelihoods).

It'll be a tiny chance, but it'll still be there. Maybe I *do* need to
look into some less steep way of distributing things, using perhaps a
normal distribution or something similar.

I quite like the interpolation idea, but it only lets you have a linear
gradient on a graph of item rarity vs. dlev. I want something curvier,
really...


I don't know how awesome Rand_normal is in sangband, but it's already implemented at least. It takes a mean and a std dev, and uses a pseudonormal table to calculate the value. It's capped at 4 standard deviations as well, which is nice. Code below, if you're interested.

Joshua


/*
* Generate a random integer number of NORMAL distribution
*
* mean = The average value.
* stand = Amount by which one standard deviation differs from the
* mean. Results will never differ from the mean by more than 4 *
* stand, and have only about a 5% chance of differing by more than
* 2 * stand.
*
* The table above is used to generate a pseudo-normal distribution,
* in a manner which is much faster than calling a transcendental
* function to calculate a true normal distribution.
*
* Basically, entry 64*N in the table above represents the number of
* times out of 32767 that a random variable with normal distribution
* will fall within N standard deviations of the mean. That is, about
* 68 percent of the time for N=1 and 95 percent of the time for N=2.
*
* The table above contains a "faked" final entry which allows us to
* pretend that all values in a normal distribution are strictly less
* than four standard deviations away from the mean. This results in
* "conservative" distribution of approximately 1/32768 values.
*
* Note that the binary search takes up to 16 quick iterations.
*
* For high inputs and sufficiently large deviations, the values this
* function returns will be somewhat less than the mean because of the
* need to truncate high numbers to fit a signed short. XXX XXX
*/
s16b Rand_normal(s32b mean, s16b stand)
{
s16b tmp;
s16b offset;
s32b longint;

s16b low = 0;
s16b high = RANDNOR_NUM;


/* Do not randomize inputs greater than MAX_SHORT (32767) */
if (mean > 32767L) return (32767);

/* No variance */
if (stand < 1) return ((s16b)mean);

/* Roll for probability */
tmp = (s16b)rand_int(32768);

/* Binary Search */
while (low < high)
{
int mid = (low + high) >> 1;

/* Move right if forced */
if (Rand_normal_table[mid] < tmp)
{
low = mid + 1;
}

/* Move left otherwise */
else
{
high = mid;
}
}

/* Convert the index into an offset */
offset = (long)stand * (long)low / RANDNOR_STD;


/* One half should be negative */
if (one_in_(2)) return (mean - offset);

/* Store the randomized value */
longint = mean + offset;

/* Do not return a number greater than MAX_SHORT (32767) */
if (longint > 32767) return (32767);
else return ((s16b)longint);
}



/*
* The normal distribution table for the "Rand_normal()" function (below)
*/
static s16b Rand_normal_table[RANDNOR_NUM] =
{
206, 613, 1022, 1430, 1838, 2245, 2652, 3058,
3463, 3867, 4271, 4673, 5075, 5475, 5874, 6271,
6667, 7061, 7454, 7845, 8234, 8621, 9006, 9389,
9770, 10148, 10524, 10898, 11269, 11638, 12004, 12367,
12727, 13085, 13440, 13792, 14140, 14486, 14828, 15168,
15504, 15836, 16166, 16492, 16814, 17133, 17449, 17761,
18069, 18374, 18675, 18972, 19266, 19556, 19842, 20124,
20403, 20678, 20949, 21216, 21479, 21738, 21994, 22245,

22493, 22737, 22977, 23213, 23446, 23674, 23899, 24120,
24336, 24550, 24759, 24965, 25166, 25365, 25559, 25750,
25937, 26120, 26300, 26476, 26649, 26818, 26983, 27146,
27304, 27460, 27612, 27760, 27906, 28048, 28187, 28323,
28455, 28585, 28711, 28835, 28955, 29073, 29188, 29299,
29409, 29515, 29619, 29720, 29818, 29914, 30007, 30098,
30186, 30272, 30356, 30437, 30516, 30593, 30668, 30740,
30810, 30879, 30945, 31010, 31072, 31133, 31192, 31249,

31304, 31358, 31410, 31460, 31509, 31556, 31601, 31646,
31688, 31730, 31770, 31808, 31846, 31882, 31917, 31950,
31983, 32014, 32044, 32074, 32102, 32129, 32155, 32180,
32205, 32228, 32251, 32273, 32294, 32314, 32333, 32352,
32370, 32387, 32404, 32420, 32435, 32450, 32464, 32477,
32490, 32503, 32515, 32526, 32537, 32548, 32558, 32568,
32577, 32586, 32595, 32603, 32611, 32618, 32625, 32632,
32639, 32645, 32651, 32657, 32662, 32667, 32672, 32677,

32682, 32686, 32690, 32694, 32698, 32702, 32705, 32708,
32711, 32714, 32717, 32720, 32722, 32725, 32727, 32729,
32731, 32733, 32735, 32737, 32739, 32740, 32742, 32743,
32745, 32746, 32747, 32748, 32749, 32750, 32751, 32752,
32753, 32754, 32755, 32756, 32757, 32757, 32758, 32758,
32759, 32760, 32760, 32761, 32761, 32761, 32762, 32762,
32763, 32763, 32763, 32764, 32764, 32764, 32764, 32765,
32765, 32765, 32765, 32766, 32766, 32766, 32766, 32767,
};
.



Relevant Pages

  • Re: Standard Deviation and "False Alarm" Rate
    ... The current methodology simply utilizes standard ... deviations but not necessarily be statistically significant. ... For 0.5 Standard Deviations: ... such claims make use of the normal distribution. ...
    (sci.stat.edu)
  • Re: Standard Deviation and "False Alarm" Rate
    ... The current methodology simply utilizes standard ... deviations but not necessarily be statistically significant. ... For 0.5 Standard Deviations: ... such claims make use of the normal distribution. ...
    (sci.stat.edu)
  • Re: Standard Deviation and "False Alarm" Rate
    ... values will still differ by 0.5 or more standard deviations 35 percent ... lead to inaccurate conclusions." ... such claims make use of the normal distribution. ... I think I found where the writer got his number ...
    (sci.stat.edu)