# Generating random survival times

Simulation studies represent an important statistical tool to investigate the performance, properties and adequacy of statistical models. Here, we will see how to generate random survival times based on the most commonly used distributions:

- Exponential
- Weibull
- Gompertz
- Log-Logistic
- Lognormal

## Distribution function of the Cox model

Thanks to the Cox proportional hazard model, it is convenient to model survival times through the hazard function, with the baseline function:

The survival function of the Cox proportional hazards models given by with

And thus, the distribution function of the Cox model is

## Random survival times formula

Let be a random variable with distribution function , then follows a **uniform distribution** on the interval , abbreviated as . Moreover, if , then , too.
Thus,

Therefore, the survival time of the Cox model can be expressed as with: , and

Therefore, as long as it is possible to compute , we can generate random survival times.

`Exponential`

:`Weibull`

:`Gompertz`

:`Log-Logistic`

:`Log-Normal`

:

and are tuning parameters.

## Linear and Nonlinear hazard function

It is possible to use nonlinear hazard functions to generate random survival times such that: where is a nonlinear function.