Skip to content

BayanWin Methodology

A detailed explanation of how BayanWin collects Philippine PCSO lottery data, processes historical draw sequences, applies six distinct analytical models, and presents results responsibly for educational use.

By the BayanWin team · Published · Updated

1. Data Sources and Collection

BayanWin's analytical pipeline begins with official PCSO draw history for five lottery games: Lotto 6/42, Mega Lotto 6/45, Super Lotto 6/49, Grand Lotto 6/55, and Ultra Lotto 6/58. These draws have been conducted by the Philippine Charity Sweepstakes Office (PCSO) for years, generating thousands of six-number draw results per game.

Historical data is ingested from curated sources maintained in structured spreadsheets and synchronized into our database through two mechanisms:

  • Scheduled background ingestion — a Cloud Scheduler job calls our backend API at regular intervals (every 20–30 minutes) to pull new draw results as they are added to source records. This keeps the database current without requiring user interaction.
  • On-demand sync — when a user selects a game on the homepage, the app triggers a data sync to ensure the latest available results are reflected in all dashboards before analysis begins.

The synchronized data is stored in InstantDB, a real-time database that supports fast queries and live updates, allowing dashboards to refresh without full page reloads. For official draw verification, schedule information, and prize claims, always refer to pcso.gov.ph. BayanWin is an independent informational platform and not an official PCSO source.

2. Feature Engineering from Draw History

Raw draw results (six numbers per draw, dated and ordered) are transformed into a rich set of numerical features before being passed to the analytical models. This feature engineering step is what allows machine learning models to find patterns that are not visible in raw number lists.

Key feature categories include:

  • Frequency features — how often each number has appeared in recent windows (last 50, 100, and full-history draws), relative to its expected frequency under a uniform distribution.
  • Gap features — the number of draws since each number last appeared. Numbers with unusually long gaps are flagged as "overdue" for exploratory purposes (though past gaps do not affect future probability).
  • Co-occurrence features — how often pairs of numbers appear together in the same draw, represented as a co-occurrence matrix. Strong co-occurrence patterns across thousands of draws are visualised in the graph view.
  • Sum and product features — aggregate properties of each six-number draw result, used to identify the typical range and distribution of winning combinations.
  • Transition features — which numbers followed which numbers across consecutive draws, forming the basis for Markov chain analysis.
  • Positional features — whether certain numbers tend to appear more often in specific sorted positions (lowest, middle, highest) within winning combinations.

3. Analytical Model Family

BayanWin uses an ensemble of six independent models, each encoding a different set of assumptions about lottery draw sequences. No single model is treated as authoritative. Comparing where models agree and disagree is itself an analytical signal.

3.1 XGBoost (Gradient Boosted Trees)

XGBoost trains an ensemble of decision trees on tabular feature vectors derived from draw history. Each tree corrects the residual error of the previous iteration, making the model progressively better at capturing non-linear relationships between features and draw outcomes. The model is retrained periodically as new draw data accumulates.

Output: six candidate numbers selected by scoring each number across the feature space and picking the top-ranked outputs. The model has no notion of sequence — it treats each prediction as an independent scoring problem.

3.2 Decision Tree

A single interpretable decision tree trained on the same feature set as XGBoost. While less accurate than the boosted ensemble, the tree structure is transparent — you can trace which feature splits led to each prediction. It serves as a simpler, more explainable baseline alongside the more complex models.

3.3 Markov Chain Model

The Markov model treats the draw sequence as a stochastic process where the probability of seeing a number in the next draw depends (in part) on which numbers appeared in recent draws. A transition matrix is built from the full draw history: each cell represents the empirical probability of number B appearing in the draw immediately after number A appeared.

In steady-state, the Markov chain converges to a stationary distribution — a long-run frequency estimate for each number. BayanWin uses this stationary distribution alongside short-window transition probabilities to rank candidates. The Markov graph visualisation shows the strongest positive and negative transition relationships in the dataset.

Read more in the Markov chains lottery article.

3.4 NashHotFilter (Game Theory Heuristic)

NashHotFilter is a hybrid heuristic inspired by equilibrium concepts from game theory — specifically the Nash equilibrium idea that a stable strategy is one where no participant can improve by unilaterally changing their approach. Applied to lottery analysis, this translates into finding a "balanced" set of numbers that are neither excessively hot (overrepresented recently) nor extremely cold (absent for long periods).

The filter blends frequency pressure, gap pressure, and co-occurrence weight into a composite score, then selects the six numbers that best satisfy an equilibrium-inspired balance criterion. It is purely heuristic and exploratory. Read more in the NashHotFilter article.

3.5 Deep Reinforcement Learning (DRL)

The DRL model frames number selection as a sequential decision problem: an agent picks numbers one at a time, receiving a reward signal based on how close the prediction was to the actual draw result (measured via error/distance metrics stored in the database after each draw). Over time, the agent's policy shifts based on what combination of features and selections has historically produced lower error distances.

This creates an adaptive model that can update its strategy as new prediction-vs-result data accumulates, unlike the static ML models above. The DRL model uses a warm-start weight file to avoid retraining from scratch with each new data batch. Learn more in the deep reinforcement learning article.

3.6 Miro — LLM Synthesis Layer

Miro is a multi-step large language model (LLM) pipeline that synthesises output from all five numeric models above into a final six-number recommendation. The LLM receives a structured context bundle containing: each model's candidate numbers, confidence scores, feature summaries, error distance history, and the current statistical state of the game (hot/cold numbers, top pairs, transition highlights).

Rather than generating numbers from raw intuition, Miro performs a structured deliberation: it reasons through model agreement, flags outliers, applies responsible range checks (no duplicate numbers, all numbers within the pool), and outputs a final synthesised line with a brief reasoning trace. The Miro layer is separated from the numeric models in the UI to make clear that it is an integrative perspective, not a seventh independent model.

4. Ensemble Comparison and the Council Panel

After all six models produce their candidate lines, the Council Panel in the BayanWin UI displays them side by side. Numbers that appear in multiple model outputs are highlighted as "agreement" picks — not because agreement guarantees correctness, but because it reveals where different modelling assumptions converge.

This comparative view is intentional: users who study the distribution of agreement and disagreement across models gain a more nuanced understanding of the data than users who follow a single "system." The ensemble design discourages over-reliance on any one output.

5. Error Distance Analysis and Feedback

After each draw, BayanWin stores the distance between each model's prediction and the actual result. "Distance" here refers to metrics like the number of matching numbers, sum difference, and positional offset — not a single binary win/loss indicator. The Error Distance Analysis dashboard visualises this history per model, allowing users to see which models have been consistently closer (on average) and which have been more variable.

This feedback loop also feeds the DRL model's reward signal, meaning the DRL agent can genuinely improve over time on the metric it is optimised for — minimising prediction distance. It does not, however, change the fundamental randomness of the underlying draw.

6. Update Cadence and Data Freshness

PCSO holds draws on specific days per week for each game. BayanWin's scheduler polls for new results every 20–30 minutes during draw days, so new results typically appear within one to two polling cycles of the official draw time. During non-draw periods, the background job runs at a lower cadence to conserve resources.

If a sync is delayed (e.g. due to a source feed interruption), dashboards will display the most recently ingested data with a timestamp indicating the last update. Users can also trigger a manual sync by selecting a game on the homepage, which forces an on-demand ingestion before the dashboards load.

7. Limitations and Responsible Interpretation

Critical limitation: PCSO lottery draws are certified random processes. No statistical model — however sophisticated — can predict the outcome of a certified random draw. The patterns BayanWin surfaces are historical regularities in a finite dataset, not evidence of exploitable structure in future draws.

  • Randomness is not negotiable — each PCSO draw is conducted under certified random procedures. Past frequency, gaps, and transitions do not create obligations for future draws. Every number in the pool has equal probability of being drawn on any given occasion.
  • Small sample sizes for some models — some feature relationships require large historical windows to be meaningful. Games with shorter draw histories (fewer data points) will produce less reliable model outputs.
  • Model drift — the XGBoost and DRL models are trained on historical data and may not adapt instantly to structural changes (e.g. if PCSO modifies a game's number pool or draw frequency).
  • Data quality variability — draw history data is sourced from curated records and may occasionally contain transcription errors. Users who notice inconsistencies are encouraged to contact us with the specific draw date and game.
  • Interpretation risk — a model output that closely matches a past draw does not imply it will be accurate for future draws. Always read the error distance history to calibrate expectations before acting on any output.

Frequently Asked Questions

How often are models retrained?

XGBoost and Decision Tree models are retrained periodically as new draw data accumulates. The DRL model updates incrementally via its reward feedback loop after each new draw is recorded. The Markov transition matrix is recomputed whenever new data is ingested.

Why do different models give different numbers?

Each model encodes different assumptions and uses different feature subsets or learning mechanisms. Disagreement is expected and healthy — it reflects genuine uncertainty in the data rather than a bug. The ensemble approach is specifically designed to surface this diversity so users can see it clearly.

Can these models predict the jackpot?

No. Jackpot prediction would require predicting all six numbers in the correct combination from a pool of 42–58 numbers. The probability of a single ticket matching all six numbers ranges from approximately 1 in 5 million (6/42) to 1 in 40.5 million (6/58). No algorithmic model can reliably overcome these odds; the draws are random.

What does the error distance metric mean?

Error distance measures how many of a model's predicted numbers matched the actual draw, and by how much the non-matching numbers differed numerically. A lower average error distance over many draws indicates a model that has been relatively closer to actual results — but this is a historical measure, not a guarantee of future performance.

Is BayanWin affiliated with PCSO?

No. BayanWin is a fully independent informational and analytical platform. It is not affiliated with, endorsed by, or operated by the Philippine Charity Sweepstakes Office or any government agency. For official results and ticket purchases, always use authorised PCSO channels.

For deeper reading on individual methods, visit the BayanWin Blog. For responsible use guidance, see the Responsible Play page. To report data issues or ask questions, use the Contact page.