The math of Survival Analysis
Now that we have introduced the main notions in Survival Analysis, let's define the variables and functions that we will be using and give simple examples to provide additional insight:
, Survival Time
is a positive random variable representing the waiting time until an event occurs. Its probability density function (p.d.f.) is and cumulative distribution function (c.d.f.) is given by
 Example:
Let's take the example of credit risk and assume that the event of interest is
fully repaying a loan
. We can now analyze the cumulative distribution function of two distinct borrowers through time. Here, we can see that the probability that Borrower B has fully repaid his/her loan reaches 50% or 80% much faster than Borrower A's. This indicates that Borrower B is potentially less risky than Borrower A.Figure 1  Comparing cumulative distribution functions
, Survival function
is the probability that the event of interest has not occurred by some time

Example: Here, we will consider the example of churn modeling, assume that the event of interest is
stopping the SaaS subscription
and analyze the survival function of three distinct customers through time. Here, we can see that the probability of remaining a customer reaches 50% much faster for Client C than Client B. On the other hand, Client A's probability doesn't even go below 60% from week 0 to week 15 of the analysis. In a nutshell,Figure 2  Comparing survival functions  Client C is very likely to churn within the first 2 weeks
 Client B is likely to churn within the next 15 weeks
 Client A is very likely to remain a customer within the next 15 weeks.
, hazard function and risk score
expresses the conditional probability that the event will occur within , given that it has not occurred before.
Thus, the hazard and Survival functions are linked by the following formula: where is the cumulative hazard function
However, the hazard function is rarely used in its original form. Most of the time, we subdivide the time axis in parts and calculate the risk score of a sample , such that:
 Example: Let's reuse our churn example. The previous conclusion can be translated into risk scores such that: . Indeed the faster you experience the event, the higher your risk score is.