public class ActivityIndex
extends java.lang.Object
Old formula for activity index was not linear and difficult to turn into a query due to conditional multipliers. Thus a new formula was written.
T
- Time played after someone is considered active on a particular week
t1, t2, t3
- Time played that week
Activity index takes into account last 3 weeks.
Activity for a single week is calculated using A(t) = (1 / (pi/2 * (t/T) + 1))
.
A(t) is based on function f(x) = 1 / (x + 1), which has property f(0) = 1, decreasing from there, but not in a straight line.
You can see the function plotted here https://www.wolframalpha.com/input/?i=1+%2F+(x%2B1)+from+-1+to+2
To fine tune the curve pi/2 is used since it felt like a good curve.
Activity index A is calculated by using the formula:
A = 5 - 5 * [A(t1) + A(t2) + A(t3)] / 3
Plot for A and limits https://www.wolframalpha.com/input/?i=plot+y+%3D+5+-+5+*+(1+%2F+(pi%2F2+*+x%2B1))+and+y+%3D1+and+y+%3D+2+and+y+%3D+3+and+y+%3D+3.75+from+-0.5+to+3
New Limits for A would thus be
< 1: Inactive
> 1: Irregular
> 2: Regular
> 3: Active
> 3.75: Very Active
Modifier and Type | Field and Description |
---|---|
static double |
ACTIVE |
static double |
IRREGULAR |
static double |
REGULAR |
static double |
VERY_ACTIVE |
Constructor and Description |
---|
ActivityIndex(DataContainer container,
long date,
long playtimeMsThreshold) |
ActivityIndex(double value,
long date) |
ActivityIndex(java.util.List<Session> sessions,
long date,
long playtimeMsThreshold) |
Modifier and Type | Method and Description |
---|---|
double |
distance(ActivityIndex other) |
long |
getDate() |
static java.lang.String[] |
getDefaultGroups() |
java.lang.String |
getFormattedValue(Formatter<java.lang.Double> formatter) |
java.lang.String |
getGroup() |
static java.lang.String |
getGroup(double value) |
static java.lang.String[] |
getGroups(Locale locale) |
double |
getValue() |
public static final double VERY_ACTIVE
public static final double ACTIVE
public static final double REGULAR
public static final double IRREGULAR
public ActivityIndex(DataContainer container, long date, long playtimeMsThreshold)
public ActivityIndex(java.util.List<Session> sessions, long date, long playtimeMsThreshold)
public ActivityIndex(double value, long date)
public static java.lang.String[] getDefaultGroups()
public static java.lang.String[] getGroups(Locale locale)
public double getValue()
public long getDate()
public java.lang.String getFormattedValue(Formatter<java.lang.Double> formatter)
public double distance(ActivityIndex other)
public static java.lang.String getGroup(double value)
public java.lang.String getGroup()