edu.usc.bg.base.generator
Class ScrambledZipfianGenerator

java.lang.Object
  extended by edu.usc.bg.base.generator.Generator
      extended by edu.usc.bg.base.generator.IntegerGenerator
          extended by edu.usc.bg.base.generator.ScrambledZipfianGenerator

public class ScrambledZipfianGenerator
extends IntegerGenerator

A generator of a zipfian distribution. It produces a sequence of items, such that some items are more popular than others, according to a zipfian distribution. When you construct an instance of this class, you specify the number of items in the set to draw from, either by specifying an itemcount (so that the sequence is of items from 0 to itemcount-1) or by specifying a min and a max (so that the sequence is of items from min to max inclusive). After you construct the instance, you can change the number of items by calling nextInt(itemcount) or nextLong(itemcount). Unlike @ZipfianGenerator, this class scatters the "popular" items across the itemspace. Use this, instead of @ZipfianGenerator, if you don't want the head of the distribution (the popular items) clustered together.


Field Summary
static long ITEM_COUNT
           
static double USED_ZIPFIAN_CONSTANT
           
static double ZETAN
           
 
Constructor Summary
ScrambledZipfianGenerator(long _items)
          Create a zipfian generator for the specified number of items.
ScrambledZipfianGenerator(long _min, long _max)
          Create a zipfian generator for items between min and max.
ScrambledZipfianGenerator(long min, long max, double _zipfianconstant)
          Create a zipfian generator for items between min and max (inclusive) for the specified zipfian constant.
 
Method Summary
static void main(java.lang.String[] args)
           
 double mean()
          since the values are scrambled (hopefully uniformly), the mean is simply the middle of the range.
 int nextInt()
          Return the next int in the sequence.
 long nextLong()
          Return the next long in the sequence.
 
Methods inherited from class edu.usc.bg.base.generator.IntegerGenerator
lastInt, lastString, nextString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZETAN

public static final double ZETAN
See Also:
Constant Field Values

USED_ZIPFIAN_CONSTANT

public static final double USED_ZIPFIAN_CONSTANT
See Also:
Constant Field Values

ITEM_COUNT

public static final long ITEM_COUNT
See Also:
Constant Field Values
Constructor Detail

ScrambledZipfianGenerator

public ScrambledZipfianGenerator(long _items)
Create a zipfian generator for the specified number of items.

Parameters:
_items - The number of items in the distribution.

ScrambledZipfianGenerator

public ScrambledZipfianGenerator(long _min,
                                 long _max)
Create a zipfian generator for items between min and max.

Parameters:
_min - The smallest integer to generate in the sequence.
_max - The largest integer to generate in the sequence.

ScrambledZipfianGenerator

public ScrambledZipfianGenerator(long min,
                                 long max,
                                 double _zipfianconstant)
Create a zipfian generator for items between min and max (inclusive) for the specified zipfian constant. If you use a zipfian constant other than 0.99, this will take a long time to complete because we need to recompute zeta.

Parameters:
min - The smallest integer to generate in the sequence.
max - The largest integer to generate in the sequence.
_zipfianconstant - The zipfian constant to use.
Method Detail

nextInt

public int nextInt()
Return the next int in the sequence.

Specified by:
nextInt in class IntegerGenerator

nextLong

public long nextLong()
Return the next long in the sequence.


main

public static void main(java.lang.String[] args)

mean

public double mean()
since the values are scrambled (hopefully uniformly), the mean is simply the middle of the range.

Specified by:
mean in class IntegerGenerator