org.apache.tinkerpop.gremlin.algorithm.generator

## Class PowerLawDistribution

- java.lang.Object
- - org.apache.tinkerpop.gremlin.algorithm.generator.PowerLawDistribution

- All Implemented Interfaces:
    Distribution

      public class PowerLawDistribution
      extends Object
      implements Distribution

  Generates values according to a scale-free distribution with the configured gamma value.
  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PowerLawDistribution(double gamma)` Constructs a new scale-free distribution for the provided gamma value.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getValue(Random random, double multiplier, double beta)`
    `Distribution` | `initialize(int invocations, int expectedTotal)` Initializes the distribution such that expectedTotal is equal to the expected sum of generated values after the given number of invocatiosn.
    `int` | `nextConditionalValue(Random random, int otherValue)` Returns the next value conditional on another given value.
    `int` | `nextValue(Random random)` Returns the next value.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PowerLawDistribution

          public PowerLawDistribution(double gamma)

      Constructs a new scale-free distribution for the provided gamma value.

  - ### Method Detail

    - #### initialize

          public Distribution initialize(int invocations,
                                         int expectedTotal)

      Description copied from interface: `Distribution`
      Initializes the distribution such that expectedTotal is equal to the expected sum of generated values after the given number of invocatiosn.

      Since most distributions have an element of randomness, these values are the expected values.
      Specified by:
        `initialize` in interface `Distribution`
      Returns:
        A new distribution configured to match the expected total for the number of invocations.

    - #### nextValue

          public int nextValue(Random random)

      Description copied from interface: `Distribution`
      Returns the next value. If this value is randomly generated, the randomness must be drawn from the provided random generator.

      DO NOT use your own internal random generator as this makes the generated values non-reproducible and leads to faulty behavior.
      Specified by:
        `nextValue` in interface `Distribution`
      Parameters:
        `random` - random generator to use for randomness
      Returns:
        next value

    - #### nextConditionalValue

          public int nextConditionalValue(Random random,
                                          int otherValue)

      Description copied from interface: `Distribution`
      Returns the next value conditional on another given value.

      This can be used, for instance, to define conditional degree distributions where the in-degree is conditional on the out-degree.

      If this value is randomly generated, the randomness must be drawn from the provided random generator. DO NOT use your own internal random generator as this makes the generated values non-reproducible and leads to faulty behavior.
      Specified by:
        `nextConditionalValue` in interface `Distribution`
      Parameters:
        `random` - random generator to use for randomness
        `otherValue` - The prior value
      Returns:
        next value

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getValue

          public static int getValue(Random random,
                                     double multiplier,
                                     double beta)

Copyright © 2013–2021 Apache Software Foundation. All rights reserved.