Stats: Use action count of the user who is tenth percentile
This commit is contained in:
parent
e2d7e94e4c
commit
05f1da430c
|
@ -1,3 +1,5 @@
|
||||||
|
import { sortBy } from 'lodash'
|
||||||
|
|
||||||
export const logInterpolation = (min: number, max: number, value: number) => {
|
export const logInterpolation = (min: number, max: number, value: number) => {
|
||||||
if (value <= min) return 0
|
if (value <= min) return 0
|
||||||
if (value >= max) return 1
|
if (value >= max) return 1
|
||||||
|
@ -16,4 +18,15 @@ export function normpdf(x: number, mean = 0, variance = 1) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const TAU = Math.PI * 2
|
export const TAU = Math.PI * 2
|
||||||
|
|
||||||
|
export function median(values: number[]) {
|
||||||
|
if (values.length === 0) return NaN
|
||||||
|
|
||||||
|
const sorted = sortBy(values, (x) => x)
|
||||||
|
const mid = Math.floor(sorted.length / 2)
|
||||||
|
if (sorted.length % 2 === 0) {
|
||||||
|
return (sorted[mid - 1] + sorted[mid]) / 2
|
||||||
|
}
|
||||||
|
return sorted[mid]
|
||||||
|
}
|
||||||
|
|
|
@ -157,13 +157,11 @@ export async function getStaticPropz() {
|
||||||
bets?.map((b) => b.userId) ?? [],
|
bets?.map((b) => b.userId) ?? [],
|
||||||
comments?.map((c) => c.userId) ?? []
|
comments?.map((c) => c.userId) ?? []
|
||||||
)
|
)
|
||||||
const counts = Object.entries(countBy(userIds))
|
const counts = Object.values(countBy(userIds))
|
||||||
const topTenth = sortBy(counts, ([, count]) => count)
|
const sortedCounts = sortBy(counts, (count) => count).reverse()
|
||||||
.reverse()
|
if (sortedCounts.length === 0) return 0
|
||||||
// Take the top 10% of users, except for the top 2, to avoid outliers.
|
const tenthPercentile = sortedCounts[Math.floor(sortedCounts.length * 0.1)]
|
||||||
.slice(2, counts.length * 0.1)
|
return tenthPercentile
|
||||||
const topTenthTotal = sumBy(topTenth, ([_, count]) => count)
|
|
||||||
return topTenthTotal
|
|
||||||
})
|
})
|
||||||
const weeklyTopTenthActions = dailyTopTenthActions.map((_, i) => {
|
const weeklyTopTenthActions = dailyTopTenthActions.map((_, i) => {
|
||||||
const start = Math.max(0, i - 6)
|
const start = Math.max(0, i - 6)
|
||||||
|
@ -212,9 +210,11 @@ export async function getStaticPropz() {
|
||||||
weekOnWeekRetention,
|
weekOnWeekRetention,
|
||||||
weeklyActivationRate,
|
weeklyActivationRate,
|
||||||
monthlyRetention,
|
monthlyRetention,
|
||||||
dailyTopTenthActions,
|
topTenthActions: {
|
||||||
weeklyTopTenthActions,
|
daily: dailyTopTenthActions,
|
||||||
monthlyTopTenthActions,
|
weekly: weeklyTopTenthActions,
|
||||||
|
monthly: monthlyTopTenthActions,
|
||||||
|
},
|
||||||
manaBet: {
|
manaBet: {
|
||||||
daily: dailyManaBet,
|
daily: dailyManaBet,
|
||||||
weekly: weeklyManaBet,
|
weekly: weeklyManaBet,
|
||||||
|
@ -237,9 +237,11 @@ export default function Analytics(props: {
|
||||||
weekOnWeekRetention: number[]
|
weekOnWeekRetention: number[]
|
||||||
monthlyRetention: number[]
|
monthlyRetention: number[]
|
||||||
weeklyActivationRate: number[]
|
weeklyActivationRate: number[]
|
||||||
dailyTopTenthActions: number[]
|
topTenthActions: {
|
||||||
weeklyTopTenthActions: number[]
|
daily: number[]
|
||||||
monthlyTopTenthActions: number[]
|
weekly: number[]
|
||||||
|
monthly: number[]
|
||||||
|
}
|
||||||
manaBet: {
|
manaBet: {
|
||||||
daily: number[]
|
daily: number[]
|
||||||
weekly: number[]
|
weekly: number[]
|
||||||
|
@ -258,9 +260,11 @@ export default function Analytics(props: {
|
||||||
weekOnWeekRetention: [],
|
weekOnWeekRetention: [],
|
||||||
monthlyRetention: [],
|
monthlyRetention: [],
|
||||||
weeklyActivationRate: [],
|
weeklyActivationRate: [],
|
||||||
dailyTopTenthActions: [],
|
topTenthActions: {
|
||||||
weeklyTopTenthActions: [],
|
daily: [],
|
||||||
monthlyTopTenthActions: [],
|
weekly: [],
|
||||||
|
monthly: [],
|
||||||
|
},
|
||||||
manaBet: {
|
manaBet: {
|
||||||
daily: [],
|
daily: [],
|
||||||
weekly: [],
|
weekly: [],
|
||||||
|
@ -301,9 +305,11 @@ export function CustomAnalytics(props: {
|
||||||
weekOnWeekRetention: number[]
|
weekOnWeekRetention: number[]
|
||||||
monthlyRetention: number[]
|
monthlyRetention: number[]
|
||||||
weeklyActivationRate: number[]
|
weeklyActivationRate: number[]
|
||||||
dailyTopTenthActions: number[]
|
topTenthActions: {
|
||||||
weeklyTopTenthActions: number[]
|
daily: number[]
|
||||||
monthlyTopTenthActions: number[]
|
weekly: number[]
|
||||||
|
monthly: number[]
|
||||||
|
}
|
||||||
manaBet: {
|
manaBet: {
|
||||||
daily: number[]
|
daily: number[]
|
||||||
weekly: number[]
|
weekly: number[]
|
||||||
|
@ -321,9 +327,7 @@ export function CustomAnalytics(props: {
|
||||||
weekOnWeekRetention,
|
weekOnWeekRetention,
|
||||||
monthlyRetention,
|
monthlyRetention,
|
||||||
weeklyActivationRate,
|
weeklyActivationRate,
|
||||||
dailyTopTenthActions,
|
topTenthActions,
|
||||||
weeklyTopTenthActions,
|
|
||||||
monthlyTopTenthActions,
|
|
||||||
manaBet,
|
manaBet,
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
|
@ -525,10 +529,10 @@ export function CustomAnalytics(props: {
|
||||||
/>
|
/>
|
||||||
<Spacer h={8} />
|
<Spacer h={8} />
|
||||||
|
|
||||||
<Title text="Total actions by top tenth" />
|
<Title text="Action count of top tenth" />
|
||||||
<p className="text-gray-500">
|
<p className="text-gray-500">
|
||||||
From the top 10% of users, how many bets, comments, and markets did they
|
Number of actions (bets, comments, markets created) taken by the tenth
|
||||||
create? (Excluding top 2 users each day.)
|
percentile of top users.
|
||||||
</p>
|
</p>
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultIndex={1}
|
defaultIndex={1}
|
||||||
|
@ -537,7 +541,7 @@ export function CustomAnalytics(props: {
|
||||||
title: 'Daily',
|
title: 'Daily',
|
||||||
content: (
|
content: (
|
||||||
<DailyCountChart
|
<DailyCountChart
|
||||||
dailyCounts={dailyTopTenthActions}
|
dailyCounts={topTenthActions.daily}
|
||||||
startDate={startDate}
|
startDate={startDate}
|
||||||
small
|
small
|
||||||
/>
|
/>
|
||||||
|
@ -547,7 +551,7 @@ export function CustomAnalytics(props: {
|
||||||
title: 'Weekly',
|
title: 'Weekly',
|
||||||
content: (
|
content: (
|
||||||
<DailyCountChart
|
<DailyCountChart
|
||||||
dailyCounts={weeklyTopTenthActions}
|
dailyCounts={topTenthActions.weekly}
|
||||||
startDate={startDate}
|
startDate={startDate}
|
||||||
small
|
small
|
||||||
/>
|
/>
|
||||||
|
@ -557,7 +561,7 @@ export function CustomAnalytics(props: {
|
||||||
title: 'Monthly',
|
title: 'Monthly',
|
||||||
content: (
|
content: (
|
||||||
<DailyCountChart
|
<DailyCountChart
|
||||||
dailyCounts={monthlyTopTenthActions}
|
dailyCounts={topTenthActions.monthly}
|
||||||
startDate={startDate}
|
startDate={startDate}
|
||||||
small
|
small
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user