Documentation
¶
Overview ¶
A simple, non-synchronized RlogC implementation.
A simple, non-synchronized RlogC implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func F ¶
This function increments n logarithmically.
This function computes (in a mathematical sense):
f(n) = log(exp(n)+1)
However, to prevent floating point overflows, this function, its implementation exploits the following rule:
f(n) = n + f(-n)
Which can be proven as follows:
f(n) = log(exp(n)+1) f(n) = log(exp(n)+exp(0)) f(n) = log(exp(n-n)+exp(0-n))+n f(n) = log(exp(0)+exp(-n))+n f(n) = log(1+exp(-n))+n f(n) = n + log(exp(-n)+1) f(n) = n + f(-n)
The function is implemented as
f(n) = max(0,n) + log(exp(-abs(n))+1)
Which is correct because:
max(0,n) = 0 IF n<0 -abs(n) = n IF n<0 max(0,n) = n IF n>0 -abs(n) = -n IF n>0 max(0,n) = -abs(n) = 0 IF n = 0
func GetDecayFromHalfLife ¶
Calculates the decay value for a given Half-life time.
Half-life (symbol t½) is the time required for a quantity to reduce to half of its initial value. See also: https://en.wikipedia.org/wiki/Half-life
The time unit of HL is the same as the time unit of the Timer in use.
For example, if you want to have a Half-life time of one hour, and your Timer increments once every second - thus the time unit of your Timer is one second - you must specify the number of seconds of this hour: 3600. However, if your Timer's time unit is one millisecond, you must specify the number of milliseconds within an hour (3600000) in order to get a Half-life time of one hour.
Types ¶
type HC ¶
func (*HC) Access ¶
Decays the counter and increments it.
If the decay factor is 0.9, then:
decay = log(0.9)
type RlogcHeap ¶
func (*RlogcHeap) BorrowElements ¶
Borrows the priority queue. DANGEROUS! Handle with care!
func (*RlogcHeap) StealElements ¶
Borrows the priority queue. DANGEROUS! Handle with care!