code: def power_under_cph(
      n_exp, n_con, p_exp, p_con, postulated_hazard_ratio, alpha=0.05
  ) -> float:
      """
      This computes the power of the hypothesis test that the two groups, experiment and control,
      have different hazards (that is, the relative hazard ratio is different from 1.)
  
      Parameters
      ----------
  
      n_exp : integer
          size of the experiment group.
  
      n_con : integer
          size of the control group.
  
      p_exp : float
          probability of failure in experimental group over period of study.
  
      p_con : float
          probability of failure in control group over period of study
  
      postulated_hazard_ratio : float
      the postulated hazard ratio
  
      alpha : float, optional (default=0.05)
          type I error rate
  
      Returns
      -------
  
      float:
          power to detect the magnitude of the hazard ratio as small as that specified by postulated_hazard_ratio.
  
  
      Notes
      -----
      `Reference <https://cran.r-project.org/web/packages/powerSurvEpi/powerSurvEpi.pdf>`_.
  
  
      See Also
      --------
      sample_size_necessary_under_cph
      """
  
      def z(p):
          return stats.norm.ppf(p)
  
      m = n_exp * p_exp + n_con * p_con
      k = float(n_exp) / float(n_con)
      return stats.norm.cdf(
          np.sqrt(k * m)
          * abs(postulated_hazard_ratio - 1)
          / (k * postulated_hazard_ratio + 1)
          - z(1 - alpha / 2.0)
      )
  
imports: from itertools import combinations
  import warnings
  import numpy
  from scipy import stats
  import pandas
  from lifelines import utils
  from lifelines.utils import group_survival_table_from_events, string_rjustify, format_p_value, format_floats, interpolate_at_times_and_return_pandas, _expected_value_of_survival_up_to_t, _expected_value_of_survival_squared_up_to_t
  from lifelines import KaplanMeierFitter
label_desc: Use image node_id 2 for calling a global function with example usage: power_under_cph(n_exp, n_con, p_exp, p_con, postulated_hazard_ratio, alpha) and returns: stats, stats