Probability as degree of confidence

Case 5. Updating confidence with new data

When developers hear the word "probability", they often imagine dice, coin flips, and the school formula "favorable outcomes divided by all possible outcomes". This is useful, but a very narrow picture. In machine learning and applied analytics, probability almost always means something else – the degree of our confidence in a statement given the available data.

Case Goal

This case demonstrates an important idea: probability is not a fixed number, but an evolving estimate that gets updated as new information arrives. In machine learning and product analytics this happens constantly: users perform actions, new events come in, models receive additional signals. Each such signal changes our confidence in a hypothesis. Key idea: probability is an estimate that updates as data arrives ("living knowledge" that evolves over time).

 
<?php

// Base probability of churning
$prior 0.3;

echo 
"Prior: $priorPHP_EOL;

// Influence of the new signal
$signalStrength 0.25;
$posterior min(1.0$prior $signalStrength);

echo 
"Posterior: $posteriorPHP_EOL;

// Update the posterior with multiple signals
$signals = [
    
0.1,  // didn't come in today
    
0.05// didn't open the letter
    
0.2,  // unsubscribed from notifications
];

$probability $prior;

foreach (
$signals as $signal) {
    
$probability min(1.0$probability $signal);
}

echo 
"Posterior: $probabilityPHP_EOL;
Result: Memory: 0.002 Mb Time running: < 0.001 sec.
Prior: 0.3
Posterior: 0.55
Posterior: 0.65