annäherung an Integrale

Multiple Importance Sampling

Resampled Importance
Sampling

Ziehen der Samples

Batch selection


    samples = [[w0,s0],[w1,s1],[wM,sM]]
    get_index():
      r = random()
      for i in range(length(samples)):
        r -= weights[i][0]
        if r <= 0:
          return i
      return None

    get_weight():
      i = get_index()
      if i is not None:
        w = sum(s[0] for s in samples) / p(sample)
        return[w,samples[i][1]]
      return [0,None]


  

Reservoir


    reservoir_sample = None
    weight_sum = 0

    add_sample(sample,weight):
      weight_sum += weight;
      if random() < ( weight / weight_sum ):
        reservoir_sample = sample

    get_weight():
      if reservoir_sample is not None:
        return  weight_sum / p(reservoir_sample)