code: def get_logit_endog(true_params, exog, noise_level):
      """
      Gets an endogenous response that is consistent with the true_params,
          perturbed by noise at noise_level.
      """
      N = exog.shape[0]
      ### Create the probability of entering the different classes,
      ### given exog and true_params
      Xdotparams = sp.dot(exog, true_params)
      noise = noise_level * sp.randn(*Xdotparams.shape)
      eXB = sp.column_stack(
          (sp.ones(len(Xdotparams)), sp.exp(Xdotparams))
      )
      class_probabilities = eXB / eXB.sum(1)[:, None]
  
      ### Create the endog
      cdf = class_probabilities.cumsum(axis=1)
      endog = sp.zeros(N)
      for i in range(N):
          endog[i] = sp.searchsorted(cdf[i, :], sp.rand())
  
      return endog
  
file_path: statsmodels/statsmodels/examples/l1_demo/demo.py
imports: from optparse import OptionParser
  import statsmodels.api
  import scipy
  from scipy import linalg
  from scipy import stats
label_desc: Use image node_id 7 for calling a global function with example usage: get_logit_endog(true_params, exog, noise_level) and returns: endog