示例#1
0
def integrated_mean(f, lb, ub):
    """
calculate the integrated mean of a function f

Inputs:
    f -- a function that takes a list and returns a number
    lb -- a list of lower bounds
    ub -- a list of upper bounds
"""
    expectation = integrate(f, lb, ub)
    from mystic.math.stats import mean, volume
    vol = volume(lb, ub)
    return mean(expectation, vol)
示例#2
0
def integrated_mean(f, lb, ub):
  """
calculate the integrated mean of a function f

Inputs:
    f -- a function that takes a list and returns a number
    lb -- a list of lower bounds
    ub -- a list of upper bounds
"""
  expectation = integrate(f, lb, ub)
  from mystic.math.stats import mean,volume
  vol = volume(lb, ub)
  return mean(expectation, vol)
示例#3
0
        failure, success = sample(model, lb[0], ub[0])
        pof = float(failure) / float(failure + success)
        print("Exact PoF: %s" % pof)

        for i in range(len(lb)):
            print("\n")
            print(" lower bounds: %s" % lb[i])
            print(" upper bounds: %s" % ub[i])
        for solved in params0[0]:
            print("solved: %s" % solved)
        print("subdiameters (squared): %s" % subdiams0[0])
        print("diameter (squared): %s" % diam0[0])
        print(" probability mass: %s" % probmass0[0])
        expectation = expectation_value(model, lower_bounds, upper_bounds)
        print(" expectation: %s" % expectation)
        mean_value = mean(expectation, cuboid_volume)
        print(" mean value: %s" % mean_value)
        mcdiarmid = mcdiarmid_bound(mean_value, sqrt(diam0[0]))
        print("McDiarmid bound: %s" % mcdiarmid)

    # determine 'best' cuts to cuboid
    for cut in range(max_number_of_cuts):
        print("\n..... cut #%s ....." % (cut + 1))
        lb, ub = make_cut(lb, ub, RVstart, RVend, cuboid_volume)

    if DEBUG:
        print("\n..... cut #%s ....." % (max_number_of_cuts + 1))
    # get diameter for each subcuboid
    params, subdiams, diam, probmass = test_cuboids(lb,ub,RVstart,RVend,\
                                                    cuboid_volume)
    SOLVED_PARAMETERS, SUB_DIAMETERS = params, subdiams
示例#4
0
        failure, success = sample(model, lb[0], ub[0])
        pof = float(failure) / float(failure + success)
        print "Exact PoF: %s" % pof

        for i in range(len(lb)):
            print "\n"
            print " lower bounds: %s" % lb[i]
            print " upper bounds: %s" % ub[i]
        for solved in params0[0]:
            print "solved: %s" % solved
        print "subdiameters (squared): %s" % subdiams0[0]
        print "diameter (squared): %s" % diam0[0]
        print " probability mass: %s" % probmass0[0]
        expectation = expectation_value(model, lower_bounds, upper_bounds)
        print " expectation: %s" % expectation
        mean_value = mean(expectation, cuboid_volume)
        print " mean value: %s" % mean_value
        mcdiarmid = mcdiarmid_bound(mean_value, sqrt(diam0[0]))
        print "McDiarmid bound: %s" % mcdiarmid

    # determine 'best' cuts to cuboid
    for cut in range(max_number_of_cuts):
        print "\n..... cut #%s ....." % (cut + 1)
        lb, ub = make_cut(lb, ub, RVstart, RVend, cuboid_volume)

    if DEBUG:
        print "\n..... cut #%s ....." % (max_number_of_cuts + 1)
    # get diameter for each subcuboid
    params, subdiams, diam, probmass = test_cuboids(lb, ub, RVstart, RVend, cuboid_volume)
    SOLVED_PARAMETERS, SUB_DIAMETERS = params, subdiams
    TOTAL_DIAMETERS, PROBABILITY_MASS = diam, probmass