class_docstr: Build a Curve Model to predict the performance
  
  Algorithm: https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/curvefitting_assessor/README.md
  
  Parameters
  ----------
  target_pos : int
      The point we need to predict
class_docstr_tok: ["Build","a","Curve","Model","to","predict","the","performance","Algorithm",":","https",":","\/\/github.com\/Microsoft\/nni\/blob\/master\/src\/sdk\/pynni\/nni\/curvefitting_assessor\/README.md","Parameters","--","--","--","--","--","target_pos",":","int","The","point","we","need","to","predict"]
docstr: Adjust the weight of each function using mcmc sampling.
  The initial value of each weight is evenly distribute.
  Brief introduction:
  (1)Definition of sample:
      Sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}
  (2)Definition of samples:
      Samples is a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix,
      representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}}
  (3)Definition of model:
      Model is the function we chose right now. Such as: 'wap', 'weibull'.
  (4)Definition of pos:
      Pos is the position we want to predict, corresponds to the value of epoch.
  
  Returns
  -------
  None
docstr_tok: ["Adjust","the","weight","of","each","function","using","mcmc","sampling",".","The","initial","value","of","each","weight","is","evenly","distribute",".","Brief","introduction",":","(","1",")","Definition","of","sample",":","Sample","is","a","(","1","*","NUM_OF_FUNCTIONS",")","matrix",",","representing","{","w1",",","w2",",","...","wk","}","(","2",")","Definition","of","samples",":","Samples","is","a","collection","of","sample",",","it","'s","a","(","NUM_OF_INSTANCE","*","NUM_OF_FUNCTIONS",")","matrix",",","representing","{","{","w11",",","w12",",","...",",","w1k","}",",","{","w21",",","w22",",","...","w2k","}",",","...","{","wk1",",","wk2",",","...",",","wkk","}","}","(","3",")","Definition","of","model",":","Model","is","the","function","we","chose","right","now",".","Such","as",":","'wap","'",",","'weibull","'",".","(","4",")","Definition","of","pos",":","Pos","is","the","position","we","want","to","predict",",","corresponds","to","the","value","of","epoch",".","Returns","--","--","--","-","None"]
code: def mcmc_sampling(self):
      """Adjust the weight of each function using mcmc sampling.
      The initial value of each weight is evenly distribute.
      Brief introduction:
      (1)Definition of sample:
          Sample is a (1 * NUM_OF_FUNCTIONS) matrix, representing{w1, w2, ... wk}
      (2)Definition of samples:
          Samples is a collection of sample, it's a (NUM_OF_INSTANCE * NUM_OF_FUNCTIONS) matrix,
          representing{{w11, w12, ..., w1k}, {w21, w22, ... w2k}, ...{wk1, wk2,..., wkk}}
      (3)Definition of model:
          Model is the function we chose right now. Such as: 'wap', 'weibull'.
      (4)Definition of pos:
          Pos is the position we want to predict, corresponds to the value of epoch.
  
      Returns
      -------
      None
      """
      init_weight = (
          np.ones((self.effective_model_num), dtype=float)
          / self.effective_model_num
      )
      self.weight_samples = np.broadcast_to(
          init_weight, (NUM_OF_INSTANCE, self.effective_model_num)
      )
      for _ in range(NUM_OF_SIMULATION_TIME):
          # sample new value from Q(i, j)
          new_values = (
              np.random.randn(NUM_OF_INSTANCE, self.effective_model_num)
              * STEP_SIZE
              + self.weight_samples
          )
          new_values = self.normalize_weight(new_values)
          # compute alpha(i, j) = min{1, P(j)Q(j, i)/P(i)Q(i, j)}
          alpha = np.minimum(
              1,
              self.target_distribution(new_values)
              / self.target_distribution(self.weight_samples),
          )
          # sample u
          u = np.random.rand(NUM_OF_INSTANCE)
          # new value
          change_value_flag = (u < alpha).astype(int)
          for j in range(NUM_OF_INSTANCE):
              new_values[j] = (
                  self.weight_samples[j] * (1 - change_value_flag[j])
                  + new_values[j] * change_value_flag[j]
              )
          self.weight_samples = new_values
  
file_path: nni/nni/algorithms/hpo/curvefitting_assessor/model_factory.py
imports: import logging
  import numpy
  from scipy import optimize
  from .curvefunctions import *
label_desc: Use image node_id 12 for calling the CurveModel obj's underlying member method code with example usage: obj.mcmc_sampling() without return types