## net.i2p.stat
Class Frequency

    java.lang.Object
      net.i2p.stat.Frequency

    public class Frequency

extends Object

Manage the calculation of a moving average event frequency over a certain period. This provides lifetime, and rolling average, frequency counts. Unlike Rate, it does not support "bucketed" averages. There is no tracking of the event frequency in the current or last bucket. There are no buckets at all. Depending on what you want, a rolling average might be better than buckets. Or not.

Constructor Summary
`Frequency(long period)`

Method Summary
`void` `eventOccurred()` Take note that a new event occurred, recalculating all the averages and frequencies
`double` `getAverageEventsPerPeriod()` Calculate how many events would occur in a period given the current (rolling) average.
`double` `getAverageInterval()` on average over the last $period, after how many milliseconds are events coming in, as calculated during the last event occurrence?
`long` `getEventCount()` how many events have occurred within the lifetime of this stat?
`long` `getLastEvent()` Deprecated. unused
`double` `getMaxAverageEventsPerPeriod()` Calculate how many events would occur in a period given the maximum rolling average.
`double` `getMinAverageInterval()` Deprecated. unused
`long` `getPeriod()` how long is this frequency averaged over? (ms)
`double` `getStrictAverageEventsPerPeriod()` using the strict average interval, how many events occur within an average period?
`double` `getStrictAverageInterval()` Over the lifetime of this stat, without any decay or weighting, what was the average interval between events? (ms)
`void` `recalculate()` Recalculate the averages

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Frequency

    public Frequency(long period)

Parameters:
  `period` - ms

Method Detail

### getPeriod

    public long getPeriod()

  how long is this frequency averaged over? (ms)

### getLastEvent

    public long getLastEvent()

  Deprecated. unused

  when did the last event occur?

### getAverageInterval

    public double getAverageInterval()

  on average over the last $period, after how many milliseconds are events coming in, as calculated during the last event occurrence?

  Returns:
    milliseconds; returns period + 1 if no events in previous period

### getMinAverageInterval

    public double getMinAverageInterval()

  Deprecated. unused

  what is the lowest average interval (aka most frequent) we have seen? (ms)

  Returns:
    milliseconds; returns period + 1 if no events in previous period

### getAverageEventsPerPeriod

    public double getAverageEventsPerPeriod()

  Calculate how many events would occur in a period given the current (rolling) average. Use getStrictAverageInterval() for the real lifetime average.

### getMaxAverageEventsPerPeriod

    public double getMaxAverageEventsPerPeriod()

  Calculate how many events would occur in a period given the maximum rolling average. Use getStrictAverageEventsPerPeriod() for the real lifetime average.

### getStrictAverageInterval

    public double getStrictAverageInterval()

  Over the lifetime of this stat, without any decay or weighting, what was the average interval between events? (ms)

  Returns:
    milliseconds; returns Double.MAX_VALUE if no events ever

### getStrictAverageEventsPerPeriod

    public double getStrictAverageEventsPerPeriod()

  using the strict average interval, how many events occur within an average period?

### getEventCount

    public long getEventCount()

  how many events have occurred within the lifetime of this stat?

### eventOccurred

    public void eventOccurred()

  Take note that a new event occurred, recalculating all the averages and frequencies

### recalculate

    public void recalculate()

  Recalculate the averages