コード例 #1
0
ファイル: straightMU.py プロジェクト: brandonmayer/ssapy
def straightMUa(bundles, revenue, pricePrediction, verbose = False):
    if verbose:
        print "straightMUa"
        
    expectedPrices = pricePrediction.expectedValue()
    
    return straightMV(bundles, revenue, expectedPrices, verbose)
コード例 #2
0
ファイル: straightMU.py プロジェクト: brandonmayer/ssapy
def straightMU(bundles, revenue, pricePrediction, n_samples, verbose = False):
    
    if verbose:
        print "straightMU - Drawing {0} samples.".format(n_samples)
        
    samples = pricePrediction.sample(n_samples = n_samples)
    
    if verbose:
        print "Samples:"
        print "{0}".format(samples)
    
    expectedPrices = numpy.mean(samples, 0)
    
    if verbose:
        print "Expected Price Vector: {0}".format(expectedPrices)
    
    return straightMV( bundles, revenue, expectedPrices, verbose)
コード例 #3
0
ファイル: averageMU.py プロジェクト: brandonmayer/ssapy
def averageMU(bundles, revenue, pricePrediction, nSamples, verbose = False):
    if verbose:
        print "averageMU - Drawing {0} samples.".format(nSamples)
        
    bundleView = numpy.atleast_2d(bundles)
    
    samples = pricePrediction.sample(n_samples = nSamples)
    accum = numpy.zeros(bundleView.shape[1], dtype = 'float')
    
    #accumulate sum of marginal utility
    for sample in samples:
        accum += straightMV(bundles, revenue, sample, verbose)
        
    #divide by number of samples for average
    accum /= nSamples
    
    if verbose:
        print "bid = {0}".format(accum)
        
    return accum