def sample_size_necessary_under_cph(power, ratio_of_participants, p_exp, p_con,
                                    postulated_hazard_ratio, alpha=0.05):
    z = lambda p: stats.norm.ppf(p)

    m = 1.0 / ratio_of_participants \
        * ((ratio_of_participants * postulated_hazard_ratio + 1.0) / (postulated_hazard_ratio - 1.0)) ** 2 \
        * (z(1. - alpha / 2.) + z(power)) ** 2

    n_exp = m * ratio_of_participants / (ratio_of_participants * p_exp + p_con)
    n_con = m / (ratio_of_participants * p_exp + p_con)

    return int(np.ceil(n_exp)), int(np.ceil(n_con))
This computes the sample size for needed power to compare two groups under a Cox
dataset/ETHPy150Open CamDavidsonPilon/lifelines/lifelines/statistics.py/sample_size_necessary_under_cph