growth-metrics-kit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- growth_metrics_kit-0.1.0/.github/workflows/ci.yml +48 -0
- growth_metrics_kit-0.1.0/.github/workflows/publish.yml +20 -0
- growth_metrics_kit-0.1.0/.gitignore +8 -0
- growth_metrics_kit-0.1.0/CHANGELOG.md +8 -0
- growth_metrics_kit-0.1.0/LICENSE +21 -0
- growth_metrics_kit-0.1.0/PKG-INFO +89 -0
- growth_metrics_kit-0.1.0/README.md +73 -0
- growth_metrics_kit-0.1.0/pyproject.toml +46 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/__init__.py +18 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/_validate.py +25 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/cli.py +91 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/payback.py +33 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/py.typed +0 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/sample_size.py +68 -0
- growth_metrics_kit-0.1.0/src/growth_metrics_kit/viral.py +30 -0
- growth_metrics_kit-0.1.0/tests/test_cli.py +29 -0
- growth_metrics_kit-0.1.0/tests/test_payback.py +57 -0
- growth_metrics_kit-0.1.0/tests/test_sample_size.py +68 -0
- growth_metrics_kit-0.1.0/tests/test_viral.py +49 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
timeout-minutes: 10
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- run: pip install -e . pytest ruff mypy
|
|
21
|
+
- run: ruff check .
|
|
22
|
+
- run: ruff format --check .
|
|
23
|
+
- run: mypy src
|
|
24
|
+
- run: pytest -q
|
|
25
|
+
build:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
timeout-minutes: 10
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.13"
|
|
33
|
+
- run: pip install build twine
|
|
34
|
+
- run: python -m build
|
|
35
|
+
- run: twine check dist/*
|
|
36
|
+
secrets:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
timeout-minutes: 5
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
pull-requests: read
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
with:
|
|
45
|
+
fetch-depth: 0
|
|
46
|
+
- uses: gitleaks/gitleaks-action@v2
|
|
47
|
+
env:
|
|
48
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
# Runs when a GitHub Release is published. Needs a trusted publisher set up on PyPI
|
|
3
|
+
# (project growth-metrics-kit, workflow publish.yml, environment pypi). No token is stored here.
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
- run: pip install build
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- CAC, CAC payback in months, LTV and LTV:CAC.
|
|
6
|
+
- K-factor, total users after N invite cycles, and the ceiling for k below 1.
|
|
7
|
+
- A/B test sample size per variant, and the power of a test at a given sample size.
|
|
8
|
+
- `growth-metrics` command with `payback`, `k-factor` and `sample-size`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Caleb Junwoo Park
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: growth-metrics-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Small, dependency-free calculators for CAC payback, LTV, viral loops and A/B test sizing.
|
|
5
|
+
Project-URL: Source, https://github.com/calebjunwoo/growth-metrics-kit
|
|
6
|
+
Author: Caleb Junwoo Park
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: ab-testing,cac,growth,k-factor,ltv,marketing,sample-size
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Office/Business
|
|
13
|
+
Classifier: Typing :: Typed
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# growth-metrics-kit
|
|
18
|
+
|
|
19
|
+
[](https://github.com/calebjunwoo/growth-metrics-kit/actions/workflows/ci.yml)
|
|
20
|
+
|
|
21
|
+
Small Python calculators for the numbers a growth team argues about: CAC payback, LTV, the K-factor of a referral loop, and how many users an A/B test needs. No dependencies, typed, and usable as a library or from the command line.
|
|
22
|
+
|
|
23
|
+
## Why it exists
|
|
24
|
+
|
|
25
|
+
These formulas are short, and they still get implemented slightly differently in every spreadsheet. The usual mistakes are paying back CAC from revenue instead of gross margin, forgetting that a K-factor of 1 or more has no ceiling, and sizing a test without saying what effect it can detect. This package puts each one in a function with validated inputs and tests, so the assumptions are written down.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pip install git+https://github.com/calebjunwoo/growth-metrics-kit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Python 3.10 or later. A PyPI release will follow once the first version is tagged.
|
|
34
|
+
|
|
35
|
+
## Use it
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from growth_metrics_kit import ab_sample_size, cac_payback_months, k_factor, ltv, viral_total_users
|
|
39
|
+
|
|
40
|
+
cac_payback_months(cac=200, monthly_revenue_per_customer=50, gross_margin=0.8) # 5.0 months
|
|
41
|
+
ltv(monthly_revenue_per_customer=50, gross_margin=0.8, monthly_churn=0.05) # 800.0
|
|
42
|
+
|
|
43
|
+
k = k_factor(invites_per_user=5, invite_conversion=0.15) # 0.75
|
|
44
|
+
viral_total_users(initial_users=1000, k=k, cycles=5) # about 3,288 users
|
|
45
|
+
|
|
46
|
+
ab_sample_size(baseline_rate=0.10, mde=0.02) # 3841 per variant
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The same calculations from a terminal:
|
|
50
|
+
|
|
51
|
+
```console
|
|
52
|
+
$ growth-metrics payback --cac 200 --revenue 50 --margin 0.8 --churn 0.05
|
|
53
|
+
payback_months: 5
|
|
54
|
+
ltv: 800
|
|
55
|
+
ltv_to_cac: 4
|
|
56
|
+
|
|
57
|
+
$ growth-metrics sample-size --baseline 0.10 --mde 0.2 --relative --power 0.9
|
|
58
|
+
users_per_variant: 5142
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Add `--json` to any command for machine-readable output. Bad input exits with code 2 and a message that names the field.
|
|
62
|
+
|
|
63
|
+
## What each function assumes
|
|
64
|
+
|
|
65
|
+
| Function | Formula | Assumption to keep in mind |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `cac` | spend / new customers | Spend and customers must cover the same period |
|
|
68
|
+
| `cac_payback_months` | CAC / (monthly revenue x gross margin) | Constant revenue per customer, no churn during payback |
|
|
69
|
+
| `ltv` | monthly revenue x margin / monthly churn | Constant churn, so it overstates LTV when early churn is high |
|
|
70
|
+
| `k_factor` | invites per user x invite conversion | Ignores how long a cycle takes |
|
|
71
|
+
| `viral_total_users` | seed x (1 - k^(n+1)) / (1 - k) | Every cycle behaves the same |
|
|
72
|
+
| `ab_sample_size` | Two-proportion z-test, normal approximation | Fixed sample size, no peeking. Weak for very small rates or very small samples |
|
|
73
|
+
|
|
74
|
+
## How it was checked
|
|
75
|
+
|
|
76
|
+
- Unit tests (39) cover the formulas, input validation and the command line.
|
|
77
|
+
- The sample-size formula is checked against a worked example (10% to 12%, 80% power, 3,841 per variant), and against a simulation: the test runs 1,500 fake experiments at the computed size and requires a z-test to find the lift 77% to 83% of the time.
|
|
78
|
+
- To confirm that the simulation can fail, I broke the power term on purpose and the test went red.
|
|
79
|
+
- CI runs ruff, mypy in strict mode and the tests on Python 3.10 to 3.13, builds the package, and scans the history for secrets.
|
|
80
|
+
|
|
81
|
+
Not covered: sequential testing, multiple variants, revenue metrics with unequal variance, and cohort-based LTV. They would each be separate functions.
|
|
82
|
+
|
|
83
|
+
## Built with
|
|
84
|
+
|
|
85
|
+
Written with Claude Code and Codex, tests first. I read and ran every test, including the mutation check above.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# growth-metrics-kit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/calebjunwoo/growth-metrics-kit/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
Small Python calculators for the numbers a growth team argues about: CAC payback, LTV, the K-factor of a referral loop, and how many users an A/B test needs. No dependencies, typed, and usable as a library or from the command line.
|
|
6
|
+
|
|
7
|
+
## Why it exists
|
|
8
|
+
|
|
9
|
+
These formulas are short, and they still get implemented slightly differently in every spreadsheet. The usual mistakes are paying back CAC from revenue instead of gross margin, forgetting that a K-factor of 1 or more has no ceiling, and sizing a test without saying what effect it can detect. This package puts each one in a function with validated inputs and tests, so the assumptions are written down.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pip install git+https://github.com/calebjunwoo/growth-metrics-kit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Python 3.10 or later. A PyPI release will follow once the first version is tagged.
|
|
18
|
+
|
|
19
|
+
## Use it
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from growth_metrics_kit import ab_sample_size, cac_payback_months, k_factor, ltv, viral_total_users
|
|
23
|
+
|
|
24
|
+
cac_payback_months(cac=200, monthly_revenue_per_customer=50, gross_margin=0.8) # 5.0 months
|
|
25
|
+
ltv(monthly_revenue_per_customer=50, gross_margin=0.8, monthly_churn=0.05) # 800.0
|
|
26
|
+
|
|
27
|
+
k = k_factor(invites_per_user=5, invite_conversion=0.15) # 0.75
|
|
28
|
+
viral_total_users(initial_users=1000, k=k, cycles=5) # about 3,288 users
|
|
29
|
+
|
|
30
|
+
ab_sample_size(baseline_rate=0.10, mde=0.02) # 3841 per variant
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The same calculations from a terminal:
|
|
34
|
+
|
|
35
|
+
```console
|
|
36
|
+
$ growth-metrics payback --cac 200 --revenue 50 --margin 0.8 --churn 0.05
|
|
37
|
+
payback_months: 5
|
|
38
|
+
ltv: 800
|
|
39
|
+
ltv_to_cac: 4
|
|
40
|
+
|
|
41
|
+
$ growth-metrics sample-size --baseline 0.10 --mde 0.2 --relative --power 0.9
|
|
42
|
+
users_per_variant: 5142
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Add `--json` to any command for machine-readable output. Bad input exits with code 2 and a message that names the field.
|
|
46
|
+
|
|
47
|
+
## What each function assumes
|
|
48
|
+
|
|
49
|
+
| Function | Formula | Assumption to keep in mind |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `cac` | spend / new customers | Spend and customers must cover the same period |
|
|
52
|
+
| `cac_payback_months` | CAC / (monthly revenue x gross margin) | Constant revenue per customer, no churn during payback |
|
|
53
|
+
| `ltv` | monthly revenue x margin / monthly churn | Constant churn, so it overstates LTV when early churn is high |
|
|
54
|
+
| `k_factor` | invites per user x invite conversion | Ignores how long a cycle takes |
|
|
55
|
+
| `viral_total_users` | seed x (1 - k^(n+1)) / (1 - k) | Every cycle behaves the same |
|
|
56
|
+
| `ab_sample_size` | Two-proportion z-test, normal approximation | Fixed sample size, no peeking. Weak for very small rates or very small samples |
|
|
57
|
+
|
|
58
|
+
## How it was checked
|
|
59
|
+
|
|
60
|
+
- Unit tests (39) cover the formulas, input validation and the command line.
|
|
61
|
+
- The sample-size formula is checked against a worked example (10% to 12%, 80% power, 3,841 per variant), and against a simulation: the test runs 1,500 fake experiments at the computed size and requires a z-test to find the lift 77% to 83% of the time.
|
|
62
|
+
- To confirm that the simulation can fail, I broke the power term on purpose and the test went red.
|
|
63
|
+
- CI runs ruff, mypy in strict mode and the tests on Python 3.10 to 3.13, builds the package, and scans the history for secrets.
|
|
64
|
+
|
|
65
|
+
Not covered: sequential testing, multiple variants, revenue metrics with unequal variance, and cohort-based LTV. They would each be separate functions.
|
|
66
|
+
|
|
67
|
+
## Built with
|
|
68
|
+
|
|
69
|
+
Written with Claude Code and Codex, tests first. I read and ran every test, including the mutation check above.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "growth-metrics-kit"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Small, dependency-free calculators for CAC payback, LTV, viral loops and A/B test sizing."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
authors = [{ name = "Caleb Junwoo Park" }]
|
|
14
|
+
keywords = ["growth", "marketing", "cac", "ltv", "ab-testing", "sample-size", "k-factor"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Topic :: Office/Business",
|
|
19
|
+
"Typing :: Typed",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Source = "https://github.com/calebjunwoo/growth-metrics-kit"
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
growth-metrics = "growth_metrics_kit.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.version]
|
|
29
|
+
path = "src/growth_metrics_kit/__init__.py"
|
|
30
|
+
|
|
31
|
+
[tool.hatch.build.targets.wheel]
|
|
32
|
+
packages = ["src/growth_metrics_kit"]
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
pythonpath = ["src"]
|
|
36
|
+
testpaths = ["tests"]
|
|
37
|
+
|
|
38
|
+
[tool.ruff]
|
|
39
|
+
line-length = 120
|
|
40
|
+
target-version = "py310"
|
|
41
|
+
|
|
42
|
+
[tool.ruff.lint]
|
|
43
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
44
|
+
|
|
45
|
+
[tool.mypy]
|
|
46
|
+
strict = true
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Small calculators for growth work: CAC payback, LTV, viral loops and A/B test sizing."""
|
|
2
|
+
|
|
3
|
+
from .payback import cac, cac_payback_months, ltv, ltv_to_cac
|
|
4
|
+
from .sample_size import ab_power, ab_sample_size
|
|
5
|
+
from .viral import k_factor, viral_limit, viral_total_users
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"ab_power",
|
|
9
|
+
"ab_sample_size",
|
|
10
|
+
"cac",
|
|
11
|
+
"cac_payback_months",
|
|
12
|
+
"k_factor",
|
|
13
|
+
"ltv",
|
|
14
|
+
"ltv_to_cac",
|
|
15
|
+
"viral_limit",
|
|
16
|
+
"viral_total_users",
|
|
17
|
+
]
|
|
18
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def positive(name: str, value: float) -> float:
|
|
7
|
+
if not math.isfinite(value) or value <= 0:
|
|
8
|
+
raise ValueError(f"{name} must be a positive number, got {value!r}")
|
|
9
|
+
return value
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def non_negative(name: str, value: float) -> float:
|
|
13
|
+
if not math.isfinite(value) or value < 0:
|
|
14
|
+
raise ValueError(f"{name} must be zero or more, got {value!r}")
|
|
15
|
+
return value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def fraction(name: str, value: float, *, allow_zero: bool = False, allow_one: bool = True) -> float:
|
|
19
|
+
low_ok = value >= 0 if allow_zero else value > 0
|
|
20
|
+
high_ok = value <= 1 if allow_one else value < 1
|
|
21
|
+
if not math.isfinite(value) or not (low_ok and high_ok):
|
|
22
|
+
low = "[0" if allow_zero else "(0"
|
|
23
|
+
high = "1]" if allow_one else "1)"
|
|
24
|
+
raise ValueError(f"{name} must be in {low}, {high}, got {value!r}")
|
|
25
|
+
return value
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
from collections.abc import Sequence
|
|
7
|
+
|
|
8
|
+
from . import (
|
|
9
|
+
__version__,
|
|
10
|
+
ab_sample_size,
|
|
11
|
+
cac_payback_months,
|
|
12
|
+
k_factor,
|
|
13
|
+
ltv,
|
|
14
|
+
ltv_to_cac,
|
|
15
|
+
viral_limit,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _parser() -> argparse.ArgumentParser:
|
|
20
|
+
parser = argparse.ArgumentParser(prog="growth-metrics", description="Growth calculators from the command line.")
|
|
21
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
22
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
23
|
+
|
|
24
|
+
pay = sub.add_parser("payback", help="CAC payback in months, plus LTV and LTV:CAC when churn is given")
|
|
25
|
+
pay.add_argument("--cac", type=float, required=True, help="cost to acquire one customer")
|
|
26
|
+
pay.add_argument("--revenue", type=float, required=True, help="monthly revenue per customer")
|
|
27
|
+
pay.add_argument("--margin", type=float, required=True, help="gross margin, 0 to 1")
|
|
28
|
+
pay.add_argument("--churn", type=float, help="monthly churn, 0 to 1 (adds LTV and LTV:CAC)")
|
|
29
|
+
|
|
30
|
+
kf = sub.add_parser("k-factor", help="viral coefficient and the user ceiling it implies")
|
|
31
|
+
kf.add_argument("--invites", type=float, required=True, help="invites sent per user")
|
|
32
|
+
kf.add_argument("--conversion", type=float, required=True, help="share of invites that convert, 0 to 1")
|
|
33
|
+
kf.add_argument("--users", type=float, default=1000, help="seed users for the ceiling (default 1000)")
|
|
34
|
+
|
|
35
|
+
ss = sub.add_parser("sample-size", help="users needed per variant in an A/B test")
|
|
36
|
+
ss.add_argument("--baseline", type=float, required=True, help="current conversion rate, for example 0.10")
|
|
37
|
+
ss.add_argument("--mde", type=float, required=True, help="smallest change worth detecting")
|
|
38
|
+
ss.add_argument("--relative", action="store_true", help="treat --mde as a relative lift (0.2 = +20%%)")
|
|
39
|
+
ss.add_argument("--alpha", type=float, default=0.05)
|
|
40
|
+
ss.add_argument("--power", type=float, default=0.80)
|
|
41
|
+
ss.add_argument("--one-sided", action="store_true")
|
|
42
|
+
|
|
43
|
+
for p in (pay, kf, ss):
|
|
44
|
+
p.add_argument("--json", action="store_true", help="print JSON instead of plain text")
|
|
45
|
+
return parser
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _run(args: argparse.Namespace) -> dict[str, float | int]:
|
|
49
|
+
if args.command == "payback":
|
|
50
|
+
result: dict[str, float | int] = {
|
|
51
|
+
"payback_months": cac_payback_months(
|
|
52
|
+
cac=args.cac, monthly_revenue_per_customer=args.revenue, gross_margin=args.margin
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
if args.churn is not None:
|
|
56
|
+
value = ltv(monthly_revenue_per_customer=args.revenue, gross_margin=args.margin, monthly_churn=args.churn)
|
|
57
|
+
result["ltv"] = value
|
|
58
|
+
result["ltv_to_cac"] = ltv_to_cac(ltv=value, cac=args.cac)
|
|
59
|
+
return result
|
|
60
|
+
if args.command == "k-factor":
|
|
61
|
+
k = k_factor(invites_per_user=args.invites, invite_conversion=args.conversion)
|
|
62
|
+
return {"k_factor": k, "user_ceiling": viral_limit(initial_users=args.users, k=k)}
|
|
63
|
+
return {
|
|
64
|
+
"users_per_variant": ab_sample_size(
|
|
65
|
+
baseline_rate=args.baseline,
|
|
66
|
+
mde=args.mde,
|
|
67
|
+
relative=args.relative,
|
|
68
|
+
alpha=args.alpha,
|
|
69
|
+
power=args.power,
|
|
70
|
+
two_sided=not args.one_sided,
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
76
|
+
args = _parser().parse_args(argv)
|
|
77
|
+
try:
|
|
78
|
+
result = _run(args)
|
|
79
|
+
except ValueError as error:
|
|
80
|
+
print(f"error: {error}", file=sys.stderr)
|
|
81
|
+
return 2
|
|
82
|
+
if args.json:
|
|
83
|
+
print(json.dumps(result))
|
|
84
|
+
else:
|
|
85
|
+
for key, value in result.items():
|
|
86
|
+
print(f"{key}: {value:.4g}" if isinstance(value, float) else f"{key}: {value}")
|
|
87
|
+
return 0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from ._validate import fraction, non_negative, positive
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def cac(*, spend: float, new_customers: float) -> float:
|
|
7
|
+
"""Customer acquisition cost: spend divided by the customers it brought in."""
|
|
8
|
+
non_negative("spend", spend)
|
|
9
|
+
positive("new_customers", new_customers)
|
|
10
|
+
return spend / new_customers
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def cac_payback_months(*, cac: float, monthly_revenue_per_customer: float, gross_margin: float) -> float:
|
|
14
|
+
"""Months of gross profit needed to earn back the acquisition cost."""
|
|
15
|
+
non_negative("cac", cac)
|
|
16
|
+
positive("monthly_revenue_per_customer", monthly_revenue_per_customer)
|
|
17
|
+
fraction("gross_margin", gross_margin)
|
|
18
|
+
return cac / (monthly_revenue_per_customer * gross_margin)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def ltv(*, monthly_revenue_per_customer: float, gross_margin: float, monthly_churn: float) -> float:
|
|
22
|
+
"""Lifetime value with constant monthly churn: margin-adjusted revenue divided by churn."""
|
|
23
|
+
positive("monthly_revenue_per_customer", monthly_revenue_per_customer)
|
|
24
|
+
fraction("gross_margin", gross_margin)
|
|
25
|
+
fraction("monthly_churn", monthly_churn)
|
|
26
|
+
return monthly_revenue_per_customer * gross_margin / monthly_churn
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def ltv_to_cac(*, ltv: float, cac: float) -> float:
|
|
30
|
+
"""How many times a customer's lifetime value covers what it cost to win them."""
|
|
31
|
+
positive("ltv", ltv)
|
|
32
|
+
positive("cac", cac)
|
|
33
|
+
return ltv / cac
|
|
File without changes
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
from statistics import NormalDist
|
|
5
|
+
|
|
6
|
+
from ._validate import fraction
|
|
7
|
+
|
|
8
|
+
_NORMAL = NormalDist()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _target_rate(baseline_rate: float, mde: float, relative: bool) -> float:
|
|
12
|
+
fraction("baseline_rate", baseline_rate, allow_one=False)
|
|
13
|
+
if mde <= 0 or not math.isfinite(mde):
|
|
14
|
+
raise ValueError(f"mde must be a positive number, got {mde!r}")
|
|
15
|
+
p2 = baseline_rate * (1 + mde) if relative else baseline_rate + mde
|
|
16
|
+
if p2 >= 1:
|
|
17
|
+
raise ValueError("baseline_rate plus the minimum detectable effect must stay below 1")
|
|
18
|
+
return p2
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _z_alpha(alpha: float, two_sided: bool) -> float:
|
|
22
|
+
fraction("alpha", alpha, allow_one=False)
|
|
23
|
+
return _NORMAL.inv_cdf(1 - alpha / 2 if two_sided else 1 - alpha)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def ab_sample_size(
|
|
27
|
+
*,
|
|
28
|
+
baseline_rate: float,
|
|
29
|
+
mde: float,
|
|
30
|
+
relative: bool = False,
|
|
31
|
+
alpha: float = 0.05,
|
|
32
|
+
power: float = 0.80,
|
|
33
|
+
two_sided: bool = True,
|
|
34
|
+
) -> int:
|
|
35
|
+
"""Users needed in each variant to detect a change in a conversion rate.
|
|
36
|
+
|
|
37
|
+
Uses the normal approximation for two independent proportions.
|
|
38
|
+
`mde` is an absolute change (0.02 = 2 points) unless `relative` is true.
|
|
39
|
+
"""
|
|
40
|
+
p1 = baseline_rate
|
|
41
|
+
p2 = _target_rate(p1, mde, relative)
|
|
42
|
+
fraction("power", power, allow_one=False)
|
|
43
|
+
z_a = _z_alpha(alpha, two_sided)
|
|
44
|
+
z_b = _NORMAL.inv_cdf(power)
|
|
45
|
+
pooled = (p1 + p2) / 2
|
|
46
|
+
spread = z_a * math.sqrt(2 * pooled * (1 - pooled)) + z_b * math.sqrt(p1 * (1 - p1) + p2 * (1 - p2))
|
|
47
|
+
return math.ceil(spread**2 / (p2 - p1) ** 2)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def ab_power(
|
|
51
|
+
n: int,
|
|
52
|
+
*,
|
|
53
|
+
baseline_rate: float,
|
|
54
|
+
mde: float,
|
|
55
|
+
relative: bool = False,
|
|
56
|
+
alpha: float = 0.05,
|
|
57
|
+
two_sided: bool = True,
|
|
58
|
+
) -> float:
|
|
59
|
+
"""Chance of detecting the effect with `n` users in each variant."""
|
|
60
|
+
if n <= 0:
|
|
61
|
+
raise ValueError(f"n must be a positive number, got {n!r}")
|
|
62
|
+
p1 = baseline_rate
|
|
63
|
+
p2 = _target_rate(p1, mde, relative)
|
|
64
|
+
z_a = _z_alpha(alpha, two_sided)
|
|
65
|
+
pooled = (p1 + p2) / 2
|
|
66
|
+
se_null = math.sqrt(2 * pooled * (1 - pooled) / n)
|
|
67
|
+
se_alt = math.sqrt((p1 * (1 - p1) + p2 * (1 - p2)) / n)
|
|
68
|
+
return _NORMAL.cdf(((p2 - p1) - z_a * se_null) / se_alt)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
from ._validate import fraction, non_negative
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def k_factor(*, invites_per_user: float, invite_conversion: float) -> float:
|
|
9
|
+
"""Viral coefficient: invites each user sends times the share of invites that convert."""
|
|
10
|
+
non_negative("invites_per_user", invites_per_user)
|
|
11
|
+
fraction("invite_conversion", invite_conversion, allow_zero=True)
|
|
12
|
+
return invites_per_user * invite_conversion
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def viral_total_users(*, initial_users: float, k: float, cycles: int) -> float:
|
|
16
|
+
"""Total users after a number of invite cycles, counting the seed users."""
|
|
17
|
+
non_negative("initial_users", initial_users)
|
|
18
|
+
non_negative("k", k)
|
|
19
|
+
if cycles < 0:
|
|
20
|
+
raise ValueError(f"cycles must be zero or more, got {cycles!r}")
|
|
21
|
+
if k == 1:
|
|
22
|
+
return initial_users * (cycles + 1)
|
|
23
|
+
return initial_users * (1 - k ** (cycles + 1)) / (1 - k)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def viral_limit(*, initial_users: float, k: float) -> float:
|
|
27
|
+
"""Total users if cycles continued forever. Infinite when k is 1 or more."""
|
|
28
|
+
non_negative("initial_users", initial_users)
|
|
29
|
+
non_negative("k", k)
|
|
30
|
+
return math.inf if k >= 1 else initial_users / (1 - k)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from growth_metrics_kit.cli import main
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_payback_command_prints_json(capsys):
|
|
9
|
+
code = main(["payback", "--cac", "200", "--revenue", "50", "--margin", "0.8", "--json"])
|
|
10
|
+
assert code == 0
|
|
11
|
+
assert json.loads(capsys.readouterr().out)["payback_months"] == pytest.approx(5.0)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_sample_size_command_prints_plain_text(capsys):
|
|
15
|
+
code = main(["sample-size", "--baseline", "0.10", "--mde", "0.02"])
|
|
16
|
+
assert code == 0
|
|
17
|
+
assert "3841" in capsys.readouterr().out
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_kfactor_command(capsys):
|
|
21
|
+
assert main(["k-factor", "--invites", "5", "--conversion", "0.2", "--json"]) == 0
|
|
22
|
+
assert json.loads(capsys.readouterr().out)["k_factor"] == pytest.approx(1.0)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_bad_input_returns_exit_code_2_and_a_message(capsys):
|
|
26
|
+
code = main(["payback", "--cac", "200", "--revenue", "50", "--margin", "0"])
|
|
27
|
+
captured = capsys.readouterr()
|
|
28
|
+
assert code == 2
|
|
29
|
+
assert "gross_margin" in captured.err
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from growth_metrics_kit import cac, cac_payback_months, ltv, ltv_to_cac
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_cac_is_spend_divided_by_new_customers():
|
|
9
|
+
assert cac(spend=10_000, new_customers=50) == 200
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_payback_months_uses_gross_margin_not_revenue():
|
|
13
|
+
# 200 / (50 * 0.8) = 5 months
|
|
14
|
+
assert cac_payback_months(cac=200, monthly_revenue_per_customer=50, gross_margin=0.8) == pytest.approx(5.0)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_payback_gets_longer_when_margin_falls():
|
|
18
|
+
high = cac_payback_months(cac=200, monthly_revenue_per_customer=50, gross_margin=0.8)
|
|
19
|
+
low = cac_payback_months(cac=200, monthly_revenue_per_customer=50, gross_margin=0.4)
|
|
20
|
+
assert low == pytest.approx(2 * high)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_ltv_is_margin_adjusted_revenue_over_churn():
|
|
24
|
+
# 50 * 0.8 / 0.05 = 800
|
|
25
|
+
assert ltv(monthly_revenue_per_customer=50, gross_margin=0.8, monthly_churn=0.05) == pytest.approx(800)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_ltv_to_cac_ratio():
|
|
29
|
+
assert ltv_to_cac(ltv=800, cac=200) == pytest.approx(4.0)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.mark.parametrize(
|
|
33
|
+
"kwargs",
|
|
34
|
+
[
|
|
35
|
+
{"cac": -1, "monthly_revenue_per_customer": 50, "gross_margin": 0.8},
|
|
36
|
+
{"cac": 200, "monthly_revenue_per_customer": 0, "gross_margin": 0.8},
|
|
37
|
+
{"cac": 200, "monthly_revenue_per_customer": 50, "gross_margin": 0},
|
|
38
|
+
{"cac": 200, "monthly_revenue_per_customer": 50, "gross_margin": 1.2},
|
|
39
|
+
],
|
|
40
|
+
)
|
|
41
|
+
def test_payback_rejects_inputs_that_can_never_pay_back(kwargs):
|
|
42
|
+
with pytest.raises(ValueError):
|
|
43
|
+
cac_payback_months(**kwargs)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_cac_rejects_zero_customers():
|
|
47
|
+
with pytest.raises(ValueError):
|
|
48
|
+
cac(spend=1000, new_customers=0)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_ltv_rejects_zero_churn():
|
|
52
|
+
with pytest.raises(ValueError):
|
|
53
|
+
ltv(monthly_revenue_per_customer=50, gross_margin=0.8, monthly_churn=0)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_results_are_finite():
|
|
57
|
+
assert math.isfinite(cac_payback_months(cac=1e9, monthly_revenue_per_customer=1, gross_margin=0.01))
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import random
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from growth_metrics_kit import ab_power, ab_sample_size
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_matches_a_hand_worked_example():
|
|
9
|
+
# 10% -> 12%, alpha 0.05 two-sided, power 0.8.
|
|
10
|
+
# ((1.95996*sqrt(2*.11*.89) + 0.84162*sqrt(.1*.9+.12*.88))^2) / .02^2 = 3840.85
|
|
11
|
+
assert ab_sample_size(baseline_rate=0.10, mde=0.02) == 3841
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_relative_and_absolute_mde_agree():
|
|
15
|
+
assert ab_sample_size(baseline_rate=0.10, mde=0.20, relative=True) == ab_sample_size(baseline_rate=0.10, mde=0.02)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_smaller_effects_need_more_users():
|
|
19
|
+
assert ab_sample_size(baseline_rate=0.10, mde=0.01) > ab_sample_size(baseline_rate=0.10, mde=0.02)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_higher_power_needs_more_users():
|
|
23
|
+
assert ab_sample_size(baseline_rate=0.10, mde=0.02, power=0.9) > ab_sample_size(
|
|
24
|
+
baseline_rate=0.10, mde=0.02, power=0.8
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_one_sided_test_needs_fewer_users():
|
|
29
|
+
assert ab_sample_size(baseline_rate=0.10, mde=0.02, two_sided=False) < ab_sample_size(baseline_rate=0.10, mde=0.02)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_power_round_trips_with_sample_size():
|
|
33
|
+
n = ab_sample_size(baseline_rate=0.10, mde=0.02)
|
|
34
|
+
assert ab_power(n, baseline_rate=0.10, mde=0.02) >= 0.80
|
|
35
|
+
assert ab_power(n - 1, baseline_rate=0.10, mde=0.02) < 0.80
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.skipif(not hasattr(random, "binomialvariate"), reason="needs Python 3.12+")
|
|
39
|
+
def test_simulated_experiments_reach_the_requested_power():
|
|
40
|
+
"""Independent check: run many fake A/B tests and count how often a z-test finds the real lift."""
|
|
41
|
+
rng = random.Random(20261205)
|
|
42
|
+
p1, p2 = 0.10, 0.12
|
|
43
|
+
n = ab_sample_size(baseline_rate=p1, mde=p2 - p1)
|
|
44
|
+
runs, hits = 1500, 0
|
|
45
|
+
for _ in range(runs):
|
|
46
|
+
a = rng.binomialvariate(n, p1)
|
|
47
|
+
b = rng.binomialvariate(n, p2)
|
|
48
|
+
pooled = (a + b) / (2 * n)
|
|
49
|
+
se = (2 * pooled * (1 - pooled) / n) ** 0.5
|
|
50
|
+
z = (b / n - a / n) / se
|
|
51
|
+
hits += z > 1.959964
|
|
52
|
+
assert 0.77 <= hits / runs <= 0.83
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@pytest.mark.parametrize(
|
|
56
|
+
"kwargs",
|
|
57
|
+
[
|
|
58
|
+
{"baseline_rate": 0, "mde": 0.02},
|
|
59
|
+
{"baseline_rate": 1, "mde": 0.02},
|
|
60
|
+
{"baseline_rate": 0.10, "mde": 0},
|
|
61
|
+
{"baseline_rate": 0.10, "mde": 0.95},
|
|
62
|
+
{"baseline_rate": 0.10, "mde": 0.02, "power": 1},
|
|
63
|
+
{"baseline_rate": 0.10, "mde": 0.02, "alpha": 0},
|
|
64
|
+
],
|
|
65
|
+
)
|
|
66
|
+
def test_rejects_inputs_that_make_no_sense(kwargs):
|
|
67
|
+
with pytest.raises(ValueError):
|
|
68
|
+
ab_sample_size(**kwargs)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from growth_metrics_kit import k_factor, viral_limit, viral_total_users
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_k_factor_is_invites_times_conversion():
|
|
9
|
+
assert k_factor(invites_per_user=5, invite_conversion=0.2) == pytest.approx(1.0)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_total_users_follow_a_geometric_series():
|
|
13
|
+
# 1000 * (1 + 0.5 + 0.25 + 0.125)
|
|
14
|
+
assert viral_total_users(initial_users=1000, k=0.5, cycles=3) == pytest.approx(1875)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_zero_cycles_returns_the_seed_users():
|
|
18
|
+
assert viral_total_users(initial_users=1000, k=0.5, cycles=0) == 1000
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_k_of_one_adds_the_seed_every_cycle():
|
|
22
|
+
assert viral_total_users(initial_users=1000, k=1.0, cycles=4) == pytest.approx(5000)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_limit_for_k_below_one():
|
|
26
|
+
assert viral_limit(initial_users=1000, k=0.5) == pytest.approx(2000)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_limit_is_infinite_when_k_is_one_or_more():
|
|
30
|
+
assert viral_limit(initial_users=1000, k=1.0) == math.inf
|
|
31
|
+
assert viral_limit(initial_users=1000, k=1.3) == math.inf
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@pytest.mark.parametrize(
|
|
35
|
+
"kwargs",
|
|
36
|
+
[
|
|
37
|
+
{"invites_per_user": -1, "invite_conversion": 0.2},
|
|
38
|
+
{"invites_per_user": 5, "invite_conversion": 1.5},
|
|
39
|
+
{"invites_per_user": 5, "invite_conversion": -0.1},
|
|
40
|
+
],
|
|
41
|
+
)
|
|
42
|
+
def test_k_factor_rejects_impossible_inputs(kwargs):
|
|
43
|
+
with pytest.raises(ValueError):
|
|
44
|
+
k_factor(**kwargs)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_total_users_rejects_negative_cycles():
|
|
48
|
+
with pytest.raises(ValueError):
|
|
49
|
+
viral_total_users(initial_users=1000, k=0.5, cycles=-1)
|