Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on docs: Weighted Sum #155

Open
markandpathak opened this issue Jun 24, 2024 · 1 comment
Open

Issue on docs: Weighted Sum #155

markandpathak opened this issue Jun 24, 2024 · 1 comment

Comments

@markandpathak
Copy link

Path: /guide/billable-metrics/aggregation-types/weighted-sum

The weighted sum calculation is very confusing or may be I have understood it all wrong:
There's an image, an equation and a calculated example. All three doesn't match
image

The image simply divides property by the time elapsed between two consecutive reading and sums up all values. There's no mention of billing period in that info-graphic.

The equation mentioned is SUM(events.properties.property_name) / (DATEDIFF(SECOND, timestamp.event_1, timestamp.event_2) + 1) * (DATEDIFF(SECOND, 'period_start', 'period_end') + 1) In which property is divided by time difference between events and then multiplied by the billing period.

However, the example calculations shows opposite:
image

In examples the property is divided by the billing period(Compare with the equation provided) which is 2678400 for a month and then multiplied by the time duration between two events.

Can you please clarify, out of three which logic is the true logic?
The documentation also doesn't provide any useful information on how a particular pricing model can be implemented using this Agg type. Can I implement metering for storage (GB-month like in s3) using this? How?

@markandpathak markandpathak changed the title Issue on docs Issue on docs: Weighted Sum Jun 24, 2024
@sarkissianraffi
Copy link
Contributor

I don't see differences in the calculation. It's always a value weighted per seconds used during a period (like a month). For instance, this one is correct:
(20 / 2678400) x 86400 = 0.64516129032 GB/s 👉 20GB used for 86400 seconds during a month
(30 / 2678400) x 1296000 = 14.5161290323 GB/s 👉 30GB used for 1296000 seconds during a month

The one from the image explains exactly the same:
A- 1GB used for 3600 seconds. In that case, there is no division by a month, because this value is not necessarily a month. It can be a week, a quarter or a year, depending on the plan cadence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants