Please Remember...
This is a fictional example and not real documentation. The purpose is to demonstrate my technical writing.
Important to Know
- Quant models don’t prove guilt. They highlight trades that look unusual based on known patterns.
- Further investigation is always needed. The model is a tool to guide your attention, not make final judgments.
← trading fraud and detection models | quant models (logistic regression formula)
Understanding How Logistic Regression Calculates Probabilities
Where is it used?
Logistic regression models are widely used in financial fraud detection, including:
- Detecting insider trading by spotting unusual trading patterns that differ from normal behaviour.
- Flagging suspicious trades that may involve market manipulation or other illicit activities.
- Monitoring post-trade surveillance to identify transactions that deviate from expected norms based on factors like trade size, frequency, and trader risk profiles.
In our example, logistic regression helps quantify the likelihood that a specific trade is fraudulent based on trade features.
The Formula
Not seeing the formula?
Refresh the page if you see something like "[ P(y = 1 \mid X) = ..." rather than a pretty formula.
In math language (to impress the quant analysts):
“The probability that y equals 1 given X is one over one plus e raised to the negative of beta-zero plus beta-one times x-one, plus beta-two times x-two, and so on.”
What It Does
This formula calculates the probability of a binary outcome (e.g., fraud vs. not fraud) based on multiple input features, where each feature is given a weight (called a coefficient) that reflects how important it is to the prediction.
What It Means
The event we're predicting (The y in P(y = 1 ∣ X))
The event we’re predicting is represented by y.
For example:
y = 1might mean “this trade is fraudulent”y = 0might mean “this trade is not fraudulent”
The big X in P(y = 1 ∣ X)
Big X refers to the entire set of trade details being evaluated.
So P(y = 1 ∣ X) is asking:
- “What’s the probability that this set of trade features (X) indicates a fraudulent trade (y = 1)?
These features might include the original spreadsheet fields from the client plus any additional info we’ve added, such as:
- trader risk scores
- standard deviation from normal behaviour
- timing or size of trade, etc.
The factors (the x values)
Each x (little x) is one of the individual trade features, things like:
- Trade size
- Frequency of trades
- Time of day
- Trader ID risk score
- Deviation from historical norms
The weight each factor carries (β)
Each feature gets multiplied by a beta coefficient (β), which is learned from historical data.
- A positive β increases the likelihood of fraud when that feature's value is high.
- A negative β decreases the likelihood.
These β values are learned during training. The model is shown historical trades with labels (fraud or not fraud) and adjusts the coefficients to best match the patterns.
The Sigmoid Function (everything after the equal sign)
The formula uses the sigmoid function to turn the weighted sum of inputs into a probability.
Why the sigmoid function?
- It squashes any number (even large positives or negatives) into a range between 0 and 1.
- That makes it perfect for probabilities.
- If the result is:
- 0.75, we interpret it as a 75% chance of fraud.
- 0.15, it's a 15% chance.
This lets analysts focus on trades with higher risk scores, improving surveillance and prioritisation.
Euler’s number “e”
The constant e is roughly equal to 2.718.
- It’s used in exponential functions like this one to make the formula work properly with the sigmoid curve.
- Its role is mathematical: it helps ensure that no matter what numbers we feed into the formula, we always get a valid probability between 0 and 1.