Spaces:
Sleeping
Sleeping
Download pythia.py from SmartScaling/TutorBot: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/SmartScaling/TutorBot/resolve/main/pythia.py
- Command line
-
hf download hf://spaces/SmartScaling/TutorBot/pythia.py
-
curl -L -o pythia.py https://huggingface.co/spaces/SmartScaling/TutorBot/resolve/main/pythia.py
1.03 kB
| import numpy as np | |
| from langchain_core.tools import tool | |
| def scenario_simulator(params: dict) -> str: | |
| """Simulates product adoption scenarios using Monte Carlo. Params: initial_users, growth_rate, time_months, uncertainty.""" | |
| try: | |
| initial_users = params.get("initial_users", 1000) | |
| growth_rate = params.get("growth_rate", 0.05) # 5%/month default | |
| time_months = params.get("time_months", 12) | |
| uncertainty = params.get("uncertainty", 0.1) # 10% variance | |
| runs = 1000 | |
| final_users = [] | |
| for _ in range(runs): | |
| users = initial_users | |
| for _ in range(time_months): | |
| users *= (1 + np.random.normal(growth_rate, uncertainty)) | |
| final_users.append(users) | |
| mean = np.mean(final_users) | |
| std = np.std(final_users) | |
| return f"Predicted users after {time_months} months: {mean:.0f} ± {std:.0f} (mean ± std, {runs} runs)." | |
| except Exception as e: | |
| return f"Sim error: {e}. Check params: {params}" |