• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python scipy.amax函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中scipy.amax函数的典型用法代码示例。如果您正苦于以下问题:Python amax函数的具体用法?Python amax怎么用?Python amax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了amax函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: plot_drainage_curve

    def plot_drainage_curve(self,
                            data=None,
                            x_values='capillary_pressure',
                            y_values='invading_phase_saturation'):
        r"""
        Plot the drainage curve as the non-wetting phase saturation vs the
        applied capillary pressure.

        Parameters
        ----------
        data : dictionary of arrays
            This dictionary should be obtained from the ``get_drainage_data``
            method.

        x_values and y_values : string
            The dictionary keys of the arrays containing the x-values and
            y-values

        """
        # Begin creating nicely formatted plot
        if data is None:
            data = self.get_drainage_data()
        xdata = data[x_values]
        ydata = data[y_values]
        fig = plt.figure()
        plt.plot(xdata, ydata, 'ko-')
        plt.ylabel(y_values)
        plt.xlabel(x_values)
        plt.grid(True)
        if sp.amax(xdata) <= 1:
            plt.xlim(xmin=0, xmax=1)
        if sp.amax(ydata) <= 1:
            plt.ylim(ymin=0, ymax=1)
        return fig
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:34,代码来源:__Drainage__.py


示例2: test_distance_center

def test_distance_center():
    shape = sp.array([7, 5, 9])
    spacing = sp.array([2, 1, 0.5])
    pn = OpenPNM.Network.Cubic(shape=shape, spacing=spacing)
    sx, sy, sz = spacing
    center_coord = sp.around(topology.find_centroid(pn['pore.coords']), 7)
    cx, cy, cz = center_coord
    coords = pn['pore.coords']
    x, y, z = coords.T
    coords = sp.concatenate((coords, center_coord.reshape((1, 3))))
    pn['pore.center'] = False
    mask1 = (x <= (cx + sx/2)) * (y <= (cy + sy/2)) * (z <= (cz + sz/2))
    mask2 = (x >= (cx - sx/2)) * (y >= (cy - sy/2)) * (z >= (cz - sz/2))
    center_pores_mask = pn.Ps[mask1 * mask2]
    pn['pore.center'][center_pores_mask] = True
    center = pn.Ps[pn['pore.center']]
    L1 = sp.amax(topology.find_pores_distance(network=pn,
                                              pores1=center,
                                              pores2=pn.Ps))
    L2 = sp.amax(topology.find_pores_distance(network=pn,
                                              pores1=pn.Ps,
                                              pores2=pn.Ps))
    l1 = ((shape[0] - 1) * sx) ** 2
    l2 = ((shape[1] - 1) * sy) ** 2
    l3 = ((shape[2] - 1) * sz) ** 2
    L3 = sp.sqrt(l1 + l2 + l3)
    assert sp.around(L1 * 2, 7) == sp.around(L2, 7)
    assert sp.around(L2, 7) == sp.around(L3, 7)
开发者ID:TomTranter,项目名称:OpenPNM,代码行数:28,代码来源:test_topological_manipulations.py


示例3: integrate

    def integrate(self,t,u,v):
        # integrate only one step in time.
        # assume same delta in x and y
        maxu = amax(u);
        maxv = amax(v);
        maxVel = amax((maxu,maxv));

        dt = self.cflConstant*self.dx/maxVel;
        print 'Time step selected: ', dt;

        k1 = self.dudt(t,u,v);
        l1 = self.dvdt(t,u,v);

        k2 = self.dudt(t+dt/2, u+(dt*k1/2), v+(dt*l1/2));
        l2 = self.dvdt(t+dt/2, u+(dt*k1/2), v+(dt*l1/2));

        k3 = self.dudt(t+dt/2, u+(dt*k2/2), v+(dt*l2/2));
        l3 = self.dvdt(t+dt/2, u+(dt*k2/2), v+(dt*l2/2));

        k4 = self.dudt(t+dt, u+(dt*k3), v+(dt*l3));
        l4 = self.dvdt(t+dt, u+(dt*k3), v+(dt*l3));

        k = (k1 + 2*k2 + 2*k3 + k4)/6;
        l = (l1 + 2*l2 + 2*l3 + l4)/6;

        un = u + dt*k;
        vn = v + dt*k;
        tn = t + dt;

        return (tn,un,vn);
开发者ID:anirban89,项目名称:My-Masters_Code,代码行数:30,代码来源:rk4.py


示例4: amalgamate_throat_data

 def amalgamate_throat_data(self,fluids='all'):
     r"""
     Returns a dictionary containing ALL throat data from all fluids, physics and geometry objects
     """
     self._throat_data_amalgamate = {}
     if type(fluids)!= sp.ndarray and fluids=='all':
         fluids = self._fluids
     elif type(fluids)!= sp.ndarray: 
         fluids = sp.array(fluids,ndmin=1)
     #Add fluid data
     for item in fluids:
         if type(item)==sp.str_: item =  self.find_object_by_name(item)
         for key in item._throat_data.keys():
             if sp.amax(item._throat_data[key]) < sp.inf:
                 dict_name = item.name+'_throat_'+key
                 self._throat_data_amalgamate.update({dict_name : item._throat_data[key]})
         for key in item._throat_info.keys():
             if sp.amax(item._throat_info[key]) < sp.inf:
                 dict_name = item.name+'_throat_label_'+key
                 self._throat_data_amalgamate.update({dict_name : item._throat_info[key]})
     #Add geometry data
     for key in self._throat_data.keys():
         if sp.amax(self._throat_data[key]) < sp.inf:
             dict_name = 'throat'+'_'+key
             self._throat_data_amalgamate.update({dict_name : self._throat_data[key]})
     for key in self._throat_info.keys():
         if sp.amax(self._throat_info[key]) < sp.inf:
             dict_name = 'throat'+'_label_'+key
             self._throat_data_amalgamate.update({dict_name : self._throat_info[key]})
     return self._throat_data_amalgamate
开发者ID:AgustinPerez,项目名称:OpenPNM,代码行数:30,代码来源:__GenericNetwork__.py


示例5: test_get_coords

 def test_get_coords(self):
     f = OpenPNM.Network.models.pore_topology.adjust_spacing
     self.net.models.add(propname='pore.coords2',
                         model=f,
                         new_spacing=2)
     assert 'pore.coords2' in self.net.keys()
     a = sp.amax(self.net['pore.coords'])
     assert sp.amax(self.net['pore.coords2']) == 2*a
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:8,代码来源:PoreTopologyTest.py


示例6: porosity_profile

def porosity_profile(network,
                      fig=None, axis=2):

    r'''
    Compute and plot the porosity profile in all three dimensions

    Parameters
    ----------
    network : OpenPNM Network object
    axis : integer type 0 for x-axis, 1 for y-axis, 2 for z-axis

    Notes
    -----
    the area of the porous medium at any position is calculated from the
    maximum pore coordinates in each direction

    '''
    if fig is None:
        fig = _plt.figure()
    L_x = _sp.amax(network['pore.coords'][:,0]) + _sp.mean(((21/88.0)*network['pore.volume'])**(1/3.0))
    L_y = _sp.amax(network['pore.coords'][:,1]) + _sp.mean(((21/88.0)*network['pore.volume'])**(1/3.0))
    L_z = _sp.amax(network['pore.coords'][:,2]) + _sp.mean(((21/88.0)*network['pore.volume'])**(1/3.0))
    if axis is 0:
        xlab = 'x-direction'
        area = L_y*L_z
    elif axis is 1:
        xlab = 'y-direction'
        area = L_x*L_z
    else:
        axis = 2
        xlab = 'z-direction'
        area = L_x*L_y
    n_max = _sp.amax(network['pore.coords'][:,axis]) + _sp.mean(((21/88.0)*network['pore.volume'])**(1/3.0))
    steps = _sp.linspace(0,n_max,100,endpoint=True)
    vals = _sp.zeros_like(steps)
    p_area = _sp.zeros_like(steps)
    t_area = _sp.zeros_like(steps)

    rp = ((21/88.0)*network['pore.volume'])**(1/3.0)
    p_upper = network['pore.coords'][:,axis] + rp
    p_lower = network['pore.coords'][:,axis] - rp
    TC1 = network['throat.conns'][:,0]
    TC2 = network['throat.conns'][:,1]
    t_upper = network['pore.coords'][:,axis][TC1]
    t_lower = network['pore.coords'][:,axis][TC2]

    for i in range(0,len(steps)):
        p_temp = (p_upper > steps[i])*(p_lower < steps[i])
        t_temp = (t_upper > steps[i])*(t_lower < steps[i])
        p_area[i] = sum((22/7.0)*(rp[p_temp]**2 - (network['pore.coords'][:,axis][p_temp]-steps[i])**2))
        t_area[i] = sum(network['throat.area'][t_temp])
        vals[i] = (p_area[i]+t_area[i])/area
    yaxis = vals
    xaxis = steps/n_max
    _plt.plot(xaxis,yaxis,'bo-')
    _plt.xlabel(xlab)
    _plt.ylabel('Porosity')
    fig.show()
开发者ID:Maggie1988,项目名称:OpenPNM,代码行数:58,代码来源:Plots.py


示例7: standarizeImage

def standarizeImage(im):
    im = array(im, 'float32') 
    if im.shape[0] > 480:
        resize_factor = 480.0 / im.shape[0]  # don't remove trailing .0 to avoid integer devision
        im = imresize(im, resize_factor)
    if amax(im) > 1.1:
        im = im / 255.0
    assert((amax(im) > 0.01) & (amax(im) <= 1))
    assert((amin(im) >= 0.00))
    return im
开发者ID:loclhero,项目名称:phow_caltech101.py,代码行数:10,代码来源:phow_caltech101.py


示例8: standardizeImage

def standardizeImage(im): #Scales image down to 640x480 or whatever the correct aspect ratio is with conf.imSize as the height
	im = array(im, 'float32') 
	if im.shape[0] > conf.imSize:
		resize_factor = float(conf.imSize) / im.shape[0]	 # don't remove trailing .0 to avoid integer devision
		im = imresize(im, resize_factor)
	if amax(im) > 1.1:
		im = im / 255.0
	assert((amax(im) > 0.01) & (amax(im) <= 1))
	assert((amin(im) >= 0.00))
	return im
开发者ID:lbarnett,项目名称:BirdID,代码行数:10,代码来源:phow_birdid_multi.py


示例9: __init__

 def __init__(
         self, spike_count_range, train_count_range, num_units_range,
         firing_rate=50 * pq.Hz):
     self.spike_count_range = spike_count_range
     self.train_count_range = train_count_range
     self.num_units_range = num_units_range
     self.num_trains_per_spike_count = \
         sp.amax(num_units_range) * sp.amax(train_count_range)
     self.trains = [
         [stg.gen_homogeneous_poisson(firing_rate, max_spikes=num_spikes)
          for i in xrange(self.num_trains_per_spike_count)]
         for num_spikes in spike_count_range]
开发者ID:jgosmann,项目名称:spyke-metrics-extra,代码行数:12,代码来源:benchmark_multiunit_metrics.py


示例10: test_respects_refractory_period

 def test_respects_refractory_period(self):
     refractory = 100 * pq.ms
     st = self.invoke_gen_func(
         self.highRate, max_spikes=1000, refractory=refractory)
     self.assertGreater(
         sp.amax(sp.absolute(sp.diff(st.rescale(pq.s).magnitude))),
         refractory.rescale(pq.s).magnitude)
     st = self.invoke_gen_func(
         self.highRate, t_stop=10 * pq.s, refractory=refractory)
     self.assertGreater(
         sp.amax(sp.absolute(sp.diff(st.rescale(pq.s).magnitude))),
         refractory.rescale(pq.s).magnitude)
开发者ID:NeuroArchive,项目名称:spykeutils,代码行数:12,代码来源:test_spike_train_generation.py


示例11: test_neighbor_min

 def test_neighbor_min(self):
     catch = self.geo.pop('pore.seed', None)
     catch = self.geo.models.pop('pore.seed', None)
     catch = self.geo.models.pop('throat.seed', None)
     mod = gm.pore_misc.neighbor
     self.geo['throat.seed'] = sp.rand(self.net.Nt,)
     self.geo.models.add(model=mod,
                         propname='pore.seed',
                         throat_prop='throat.seed',
                         mode='min')
     assert sp.all(sp.in1d(self.geo['pore.seed'], self.geo['throat.seed']))
     pmax = sp.amax(self.geo['pore.seed'])
     tmax = sp.amax(self.geo['throat.seed'])
     assert pmax <= tmax
开发者ID:MichaelHoeh,项目名称:OpenPNM,代码行数:14,代码来源:PoreMiscTest.py


示例12: expectation_prop_inner

def expectation_prop_inner(m0,V0,Y,Z,F,z,needed):
    #expectation propagation on multivariate gaussian for soft inequality constraint
    #m0,v0 are mean vector , covariance before EP
    #Y is inequality value, Z is sign, 1 for geq, -1 for leq, F is softness variance
    #z is number of ep rounds to run
    #returns mt, Vt the value and variance for observations created by ep
    m0=sp.array(m0).flatten()
    V0=sp.array(V0)
    n = V0.shape[0]
    print "expectation prpagation running on "+str(n)+" dimensions for "+str(z)+" loops:"
    mt =sp.zeros(n)
    Vt= sp.eye(n)*float(1e10)
    m = sp.empty(n)
    V = sp.empty([n,n])
    conv = sp.empty(z)
    for i in xrange(z):
        
        #compute the m V give ep obs
        m,V = gaussian_fusion(m0,mt,V0,Vt)
        mtprev=mt.copy()
        Vtprev=Vt.copy()
        for j in [k for k in xrange(n) if needed[k]]:
            print [i,j]
            #the cavity dist at index j
            tmp = 1./(Vt[j,j]-V[j,j])
            v_ = (V[j,j]*Vt[j,j])*tmp
            m_ = tmp*(m[j]*Vt[j, j]-mt[j]*V[j, j])
            alpha = sp.sign(Z[j])*(m_-Y[j]) / (sp.sqrt(v_+F[j]))
            pr = PhiR(alpha)
            
            
            if sp.isnan(pr):
                
                pr = -alpha
            beta = pr*(pr+alpha)/(v_+F[j])
            kappa = sp.sign(Z[j])*(pr+alpha) / (sp.sqrt(v_+F[j]))
            
            #print [alpha,beta,kappa,pr]
            mt[j] = m_+1./kappa
            #mt[j] = min(abs(mt[j]),1e5)*sp.sign(mt[j])
            Vt[j,j] = min(1e10,1./beta - v_)
        #print sp.amax(mtprev-mt)
        #print sp.amax(sp.diagonal(Vtprev)-sp.diagonal(Vt))
        #TODO make this a ratio instead of absolute
        delta = max(sp.amax(mtprev-mt),sp.amax(sp.diagonal(Vtprev)-sp.diagonal(Vt)))
        conv[i]=delta
    print "EP finished with final max deltas "+str(conv[-3:])
    V = V0.dot(spl.solve(V0+Vt,Vt))
    m = V.dot((spl.solve(V0,m0)+spl.solve(Vt,mt)).T)
    return mt, Vt
开发者ID:markm541374,项目名称:GPc,代码行数:50,代码来源:eprop.py


示例13: standardizeImage

def standardizeImage(im): #Scales image down to 640x480
	im = array(im, 'float32') 
	if im.shape[0] > conf.imSize:
		resize_factor = float(conf.imSize) / im.shape[0]	 # don't remove trailing .0 to avoid integer devision
		im = imresize(im, resize_factor)
	if amax(im) > 1.1:
		im = im / 255.0
	assert((amax(im) > 0.01) & (amax(im) <= 1))
	assert((amin(im) >= 0.00))
	"""r = 480.0 / im.shape[1]
	dim = (480, int(im.shape[0] * r))
	im = cv2.resize(im, dim, interpolation = cv2.INTER_AREA)"""

	return im
开发者ID:wbg595,项目名称:Research,代码行数:14,代码来源:phow_birdid_multi.py


示例14: output_percentile_set

def output_percentile_set(data_field, args):
    r"""
    Does three sets of percentiles and stacks them as columns: raw data,
    absolute value data, normalized+absolute value
    """
    data = {}
    #
    # outputting percentiles of initial subtraction to screen
    field = data_field.clone()
    pctle = Percentiles(field, percentiles=args.perc)
    pctle.process()
    data['raw'] = pctle.processed_data
    #
    # normalizing data
    field = data_field.clone()
    field.data_map = field.data_map/sp.amax(sp.absolute(field.data_map))
    field.data_vector = sp.ravel(field.data_map)
    pctle = Percentiles(field, percentiles=args.perc)
    pctle.process()
    data['norm'] = pctle.processed_data
    #
    # taking absolute value of data
    field = data_field.clone()
    field.data_map = sp.absolute(field.data_map)
    field.data_vector = sp.absolute(field.data_vector)
    pctle = Percentiles(field, percentiles=args.perc)
    pctle.process()
    data['abs'] = pctle.processed_data
    #
    # absolute value + normed
    field.data_map = field.data_map/sp.amax(field.data_map)
    field.data_vector = sp.ravel(field.data_map)
    pctle = Percentiles(field, percentiles=args.perc)
    pctle.process()
    data['abs+norm'] = pctle.processed_data
    #
    # outputting stacked percentiles
    fmt = '    {:>6.2f}\t{: 0.6e}\t{: 0.6e}\t{: 0.6e}\t{: 0.6e}\n'
    content = 'Percentile\tRaw Data\tAbsolute\tNormalized\tNorm+abs\n'
    data = zip(args.perc, data['raw'].values(),
               data['abs'].values(),
               data['norm'].values(),
               data['abs+norm'].values())
    #
    for row in data:
        content += fmt.format(*row)
    content += '\n'
    print(content)
开发者ID:stadelmanma,项目名称:netl-AP_MAP_FLOW,代码行数:48,代码来源:apm_subtract_data_maps.py


示例15: plot_delta

def plot_delta():     
    beta = 0.99
    N = 1000
    u = lambda c: sp.sqrt(c)
    W = sp.linspace(0,1,N)
    X, Y = sp.meshgrid(W,W)
    Wdiff = sp.transpose(X-Y)
    index = Wdiff <0
    Wdiff[index] = 0
    util_grid = u(Wdiff)
    util_grid[index] = -10**10
    
    Vprime = sp.zeros((N,1))
    delta = sp.ones(1)
    tol = 10**-9
    it = 0
    max_iter = 500
    
    while (delta[-1] >= tol) and (it < max_iter):
        V = Vprime
        it += 1;
        print(it)
        val = util_grid + beta*sp.transpose(V)
        Vprime = sp.amax(val, axis = 1)
        Vprime = Vprime.reshape((N,1))
        delta = sp.append(delta,sp.dot(sp.transpose(Vprime - V),Vprime-V))
        
    plt.figure()
    plt.plot(delta[1:])
    plt.ylabel(r'$\delta_k$')
    plt.xlabel('iteration')
    plt.savefig('convergence.pdf')
开发者ID:jareddf,项目名称:numerical_computing,代码行数:32,代码来源:VFI_plots.py


示例16: scale

def scale(x, M=None, m=None, REVERSE=None):
    """ Function that standardize the data
        Input:
            x: the data
            M: the Max vector
            m: the Min vector
        Output:
            x: the standardize data
            M: the Max vector
            m: the Min vector
    """
    if not sp.issubdtype(x.dtype, float):
        do_convert = 1
    else:
        do_convert = 0
    if REVERSE is None:
        if M is None:
            M = sp.amax(x, axis=0)
            m = sp.amin(x, axis=0)
            if do_convert:
                xs = 2 * (x.astype("float") - m) / (M - m) - 1
            else:
                xs = 2 * (x - m) / (M - m) - 1
            return xs, M, m
        else:
            if do_convert:
                xs = 2 * (x.astype("float") - m) / (M - m) - 1
            else:
                xs = 2 * (x - m) / (M - m) - 1
            return xs
    else:
        return (1 + x) / 2 * (M - m) + m
开发者ID:lennepkade,项目名称:PGPDA,代码行数:32,代码来源:pgpda.py


示例17: print_all_stats

def print_all_stats(ctx, series):
    ftime = get_ftime(series)
    start = 0 
    end = ctx.interval
    print('start-time, samples, min, avg, median, 90%, 95%, 99%, max')
    while (start < ftime):  # for each time interval
        end = ftime if ftime < end else end
        sample_arrays = [ s.get_samples(start, end) for s in series ]
        samplevalue_arrays = []
        for sample_array in sample_arrays:
            samplevalue_arrays.append( 
                [ sample.value for sample in sample_array ] )
        #print('samplevalue_arrays len: %d' % len(samplevalue_arrays))
        #print('samplevalue_arrays elements len: ' + \
               #str(map( lambda l: len(l), samplevalue_arrays)))
        # collapse list of lists of sample values into list of sample values
        samplevalues = reduce( array_collapser, samplevalue_arrays, [] )
        #print('samplevalues: ' + str(sorted(samplevalues)))
        # compute all stats and print them
        myarray = scipy.fromiter(samplevalues, float)
        mymin = scipy.amin(myarray)
        myavg = scipy.average(myarray)
        mymedian = scipy.median(myarray)
        my90th = scipy.percentile(myarray, 90)
        my95th = scipy.percentile(myarray, 95)
        my99th = scipy.percentile(myarray, 99)
        mymax = scipy.amax(myarray)
        print( '%f, %d, %f, %f, %f, %f, %f, %f, %f' % (
            start, len(samplevalues), 
            mymin, myavg, mymedian, my90th, my95th, my99th, mymax))

        # advance to next interval
        start += ctx.interval
        end += ctx.interval
开发者ID:huyanhua,项目名称:fio,代码行数:34,代码来源:fiologparser.py


示例18: plot_optimal_uncertainty_reduction

def plot_optimal_uncertainty_reduction(results_for_exp, results_for_exp_inftau):
    """ Plot the percentage of uncertainty reduction of the optimal classifiers.

    :param results_for_exp: The results of one experiment as 4-D array of the
        shape (metrics, z-values, tau-values, experimental repetitions).
    :type results_for_exp: 4-D array
    :param result_list_inftau: The results of one experiment for `tau = inf` as
        3-D array of the shape (metrics, z-values, experimental repetitions).
    :type results_for_exp_inftau: 3-D array.
    """
    plt.ylim(0, 1)

    plot_param_per_metric_and_z(
        sp.mean(sp.amax(results_for_exp, axis=2), axis=2),
        sp.std(sp.amax(results_for_exp, axis=2), axis=2))
    plot_param_per_metric_and_z(sp.mean(results_for_exp_inftau, axis=2), c='g')
开发者ID:jgosmann,项目名称:spyke-metrics-extra,代码行数:16,代码来源:section3.2.1.py


示例19: test_late_pore_and_throat_filling

def test_late_pore_and_throat_filling():
    phys.models.add(propname='pore.fractional_filling',
                    model=OpenPNM.Physics.models.multiphase.late_pore_filling,
                    Pc=0,
                    Swp_star=0.2,
                    eta=1)
    mod = OpenPNM.Physics.models.multiphase.late_throat_filling
    phys.models.add(propname='throat.fractional_filling',
                    model=mod,
                    Pc=0,
                    Swp_star=0.2,
                    eta=1)
    phys.regenerate()
    drainage.setup(invading_phase=water, defending_phase=air,
                   pore_filling='pore.fractional_filling',
                   throat_filling='throat.fractional_filling')
    drainage.set_inlets(pores=pn.pores('boundary_top'))
    drainage.run()
    data = drainage.get_drainage_data()
    assert sp.amin(data['invading_phase_saturation']) == 0.0
    assert sp.amax(data['invading_phase_saturation']) < 1.0

    drainage.return_results(Pc=5000)
    assert 'pore.occupancy' in water.keys()
    assert 'throat.occupancy' in water.keys()
    assert 'pore.partial_occupancy' in water.keys()
    assert 'throat.partial_occupancy' in water.keys()
开发者ID:TomTranter,项目名称:OpenPNM,代码行数:27,代码来源:test_drainage_algorithm.py


示例20: Problem3Real

def Problem3Real():
    beta = 0.9
    N = 1000
    u = lambda c: sp.sqrt(c)
    W = sp.linspace(0,1,N)
    X, Y = sp.meshgrid(W,W)
    Wdiff = sp.transpose(X-Y)
    index = Wdiff <0
    Wdiff[index] = 0
    util_grid = u(Wdiff)
    util_grid[index] = -10**10
    
    Vprime = sp.zeros((N,1))
    psi = sp.zeros((N,1))
    delta = 1.0
    tol = 10**-9
    it = 0
    max_iter = 500
    
    while (delta >= tol) and (it < max_iter):
        V = Vprime
        it += 1;
        #print(it)
        val = util_grid + beta*sp.transpose(V)
        Vprime = sp.amax(val, axis = 1)
        Vprime = Vprime.reshape((N,1))
        psi_ind = sp.argmax(val,axis = 1)
        psi    = W[psi_ind]
        delta = sp.dot(sp.transpose(Vprime - V),Vprime-V)
    
    return psi
开发者ID:davidreber,项目名称:Labs,代码行数:31,代码来源:solutionstester.py



注:本文中的scipy.amax函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python scipy.amin函数代码示例发布时间:2022-05-27
下一篇:
Python scipy.allclose函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap