当前位置: 首页>>代码示例>>Python>>正文


Python scipy.linspace方法代码示例

本文整理汇总了Python中scipy.linspace方法的典型用法代码示例。如果您正苦于以下问题:Python scipy.linspace方法的具体用法?Python scipy.linspace怎么用?Python scipy.linspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy的用法示例。


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

示例1: m_circles

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def m_circles(mags, phase_min=-359.75, phase_max=-0.25):
    """Constant-magnitude contours of the function Gcl = Gol/(1+Gol), where
    Gol is an open-loop transfer function, and Gcl is a corresponding
    closed-loop transfer function.

    Parameters
    ----------
    mags : array-like
        Array of magnitudes in dB of the M-circles
    phase_min : degrees
        Minimum phase in degrees of the N-circles
    phase_max : degrees
        Maximum phase in degrees of the N-circles

    Returns
    -------
    contours : complex array
        Array of complex numbers corresponding to the contours.
    """
    # Convert magnitudes and phase range into a grid suitable for
    # building contours
    phases = sp.radians(sp.linspace(phase_min, phase_max, 2000))
    Gcl_mags, Gcl_phases = sp.meshgrid(10.0**(mags/20.0), phases)
    return closed_loop_contours(Gcl_mags, Gcl_phases) 
开发者ID:python-control,项目名称:python-control,代码行数:26,代码来源:nichols.py

示例2: _draw_horizontal_guides_

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def _draw_horizontal_guides_(self, canvas, axis_color=pyx.color.cmyk.Gray):
        """
        draws horizontal guides
        """
        p = self.grid_box.params
        if p['horizontal_guides']:
            line = pyx.path.path()
            nr = p['horizontal_guide_nr']
            for y in scipy.linspace(self.grid_box.y_top, self.grid_box.y_bottom, nr):
                xt1 = self._give_trafo_x_(self.grid_box.x_left, y)
                yt1 = self._give_trafo_y_(self.grid_box.x_left, y)
                xt2 = self._give_trafo_x_(self.grid_box.x_right, y)
                yt2 = self._give_trafo_y_(self.grid_box.x_right, y)
                line.append(pyx.path.moveto(xt1, yt1))
                line.append(pyx.path.lineto(xt2, yt2))
            canvas.stroke(line, [pyx.style.linewidth.normal, pyx.style.linestyle.dotted,
                                 p['u_axis_color']])
            self.ref_block_lines.append(line) 
开发者ID:lefakkomies,项目名称:pynomo,代码行数:20,代码来源:nomo_wrapper.py

示例3: _draw_vertical_guides_

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def _draw_vertical_guides_(self, canvas, axis_color=pyx.color.cmyk.Gray):
        """
        draws vertical guides
        """
        p = self.grid_box.params
        if p['vertical_guides']:
            line = pyx.path.path()
            nr = p['vertical_guide_nr']
            for x in scipy.linspace(self.grid_box.x_left, self.grid_box.x_right, nr):
                xt1 = self._give_trafo_x_(x, self.grid_box.y_top)
                yt1 = self._give_trafo_y_(x, self.grid_box.y_top)
                xt2 = self._give_trafo_x_(x, self.grid_box.y_bottom)
                yt2 = self._give_trafo_y_(x, self.grid_box.y_bottom)
                line.append(pyx.path.moveto(xt1, yt1))
                line.append(pyx.path.lineto(xt2, yt2))
            canvas.stroke(line, [pyx.style.linewidth.normal, pyx.style.linestyle.dotted,
                                 p['wd_axis_color']])
            # take handle
            self.ref_block_lines.append(line) 
开发者ID:lefakkomies,项目名称:pynomo,代码行数:21,代码来源:nomo_wrapper.py

示例4: SIS_process

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def SIS_process(G, degree_prob, tmax, tau, gamma):
    N=G.order() 
    plt.figure(5)
    plt.clf()
    plt.figure(6)
    plt.clf()
    for index, starting_node in enumerate([x*N/10. for x in range(10)]):
        plt.figure(5)
        t, S, I = EoN.fast_SIS(G, tau, gamma, initial_infecteds = [starting_node], tmax = tmax)
        #print(I[-1])
        subt = scipy.linspace(0, tmax, 501)
        subI = EoN.subsample(subt, t, I)
        plt.plot(subt,subI)
        if I[-1]>100:
            plt.figure(6)
            shift = EoN.get_time_shift(t, I, 1000)
            plt.plot(subt-shift, subI)
    plt.figure(5)
    plt.savefig('sw_SIS_epi_N{}_p{}_k{}_tau{}.pdf'.format(N, p, k, tau))
    plt.figure(6)
    plt.savefig('sw_SIS_epi_N{}_p{}_k{}_tau{}_shifted.pdf'.format(N, p, k, tau)) 
开发者ID:springer-math,项目名称:Mathematics-of-Epidemics-on-Networks,代码行数:23,代码来源:fig11p7.py

示例5: star_graph_lumped

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def star_graph_lumped(N, tau, gamma, I0, tmin, tmax, tcount):
    times = scipy.linspace(tmin, tmax, tcount)
    #    [[central node infected] + [central node susceptible]]
    #X = [Y_1^1, Y_1^2, ..., Y_1^{N}, Y_2^0, Y_2^1, ..., Y_2^{N-1}]
    X0 = scipy.zeros(2*N)  #length 2*N of just 0 entries
    X0[I0]=I0*1./N #central infected, + I0-1 periph infected prob
    X0[N+I0] = 1-I0*1./N #central suscept + I0 periph infected
    X = EoN.my_odeint(star_graph_dX, X0, times, args = (tau, gamma, N))
    #X looks like [[central susceptible,k periph] [ central inf, k-1 periph]] x T

    central_inf = X[:,:N]
    central_susc = X[:,N:]

    I = scipy.array([ sum(k*central_susc[t][k] for k in range(N))
            + sum((k+1)*central_inf[t][k] for k in range(N))
            for t in range(len(X))])
    S = N-I
    return times, S, I 
开发者ID:springer-math,项目名称:Mathematics-of-Epidemics-on-Networks,代码行数:20,代码来源:fig2p11.py

示例6: process_degree_distribution

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def process_degree_distribution(N, Pk, color, Psi, DPsi, symbol, label, count):
    report_times = scipy.linspace(0,30,3000)
    sums = 0*report_times
    for cnt in range(count):
        G = generate_network(Pk, N)
        t, S, I, R = EoN.fast_SIR(G, tau, gamma, rho=rho)
        plt.plot(t, I*1./N, '-', color = color, 
                                alpha = 0.1, linewidth=1)
        subsampled_I = EoN.subsample(report_times, t, I)
        sums += subsampled_I*1./N
    ave = sums/count
    plt.plot(report_times, ave, color = 'k')
    
    #Do EBCM    
    N= G.order()#N is arbitrary, but included because our implementation of EBCM assumes N is given.
    t, S, I, R = EoN.EBCM_uniform_introduction(N, Psi, DPsi, tau, gamma, rho, tmin=0, tmax=10, tcount = 41)
    plt.plot(t, I/N, symbol, color = color, markeredgecolor='k', label=label)

    for cnt in range(3):  #do 3 highlighted simulations
        G = generate_network(Pk, N)
        t, S, I, R = EoN.fast_SIR(G, tau, gamma, rho=rho)
        plt.plot(t, I*1./N, '-', color = 'k', linewidth=0.1) 
开发者ID:springer-math,项目名称:Mathematics-of-Epidemics-on-Networks,代码行数:24,代码来源:fig1p2.py

示例7: star_graph_lumped

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def star_graph_lumped(N, tau, gamma, I0, tmin, tmax, tcount):
    times = scipy.linspace(tmin, tmax, tcount)
    #    [[central node infected] + [central node susceptible]]
    #X = [Y_1^1, Y_1^2, ..., Y_1^{N}, Y_2^0, Y_2^1, ..., Y_2^{N-1}]
    X0 = scipy.zeros(2*N)  #length 2*N of just 0 entries
    #X0[I0]=I0*1./N #central infected, + I0-1 periph infected prob
    X0[N+I0] = 1#-I0*1./N #central suscept + I0 periph infected
    X = EoN.my_odeint(star_graph_dX, X0, times, args = (tau, gamma, N))
    #X looks like [[central susceptible,k periph] [ central inf, k-1 periph]] x T

    central_susc = X[:,N:]
    central_inf = X[:,:N]
    print(central_susc[-1][:])
    print(central_inf[-1][:])
    I = scipy.array([ sum(k*central_susc[t][k] for k in range(N))
              + sum((k+1)*central_inf[t][k] for k in range(N))
              for t in range(len(X))])
    S = N-I
    return times, S, I 
开发者ID:springer-math,项目名称:Mathematics-of-Epidemics-on-Networks,代码行数:21,代码来源:fig3p2.py

示例8: sim_and_plot

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def sim_and_plot(G, tau, gamma, rho, tmax, tcount, ax):
    t, S, I = EoN.fast_SIS(G, tau, gamma, rho = rho, tmax = tmax)
    report_times = scipy.linspace(0, tmax, tcount)
    I = EoN.subsample(report_times, t, I)
    ax.plot(report_times, I/N, color='grey', linewidth=5, alpha=0.3)
    
    t, S, I, = EoN.SIS_heterogeneous_meanfield_from_graph(G, tau, gamma, rho=rho, 
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N, '--')    
    t, S, I = EoN.SIS_compact_pairwise_from_graph(G, tau, gamma, rho=rho,
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N)
 
    t, S, I = EoN.SIS_homogeneous_pairwise_from_graph(G, tau, gamma, rho=rho, 
                                                    tmax=tmax, tcount=tcount)
    ax.plot(t, I/N, '-.') 
开发者ID:springer-math,项目名称:Mathematics-of-Epidemics-on-Networks,代码行数:18,代码来源:fig5p4.py

示例9: generate_data

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def generate_data(N, S, L):

        # generate genetics
        G = 1.0 * (sp.rand(N, S) < 0.2)
        G -= G.mean(0)
        G /= G.std(0) * sp.sqrt(G.shape[1])

        # generate latent phenotypes
        Zg = sp.dot(G, sp.randn(G.shape[1], L))
        Zn = sp.randn(N, L)

        # generate variance exapleind
        vg = sp.linspace(0.8, 0, L)

        # rescale and sum
        Zg *= sp.sqrt(vg / Zg.var(0))
        Zn *= sp.sqrt((1 - vg) / Zn.var(0))
        Z = Zg + Zn

        return Z, G 
开发者ID:fpcasale,项目名称:GPPVAE,代码行数:22,代码来源:gp.py

示例10: makehistogram

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def makehistogram(indata, histlen, binsize=None, therange=None):
    """

    Parameters
    ----------
    indata
    histlen
    binsize
    therange

    Returns
    -------

    """
    if therange is None:
        therange = [indata.min(), indata.max()]
    if histlen is None and binsize is None:
        thebins = 10
    elif binsize is not None:
        thebins = sp.linspace(therange[0], therange[1], (therange[1] - therange[0]) / binsize + 1, endpoint=True)
    else:
        thebins = histlen
    thehist = np.histogram(indata, thebins, therange)
    return thehist 
开发者ID:bbfrederick,项目名称:rapidtide,代码行数:26,代码来源:stats.py

示例11: upsample

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def upsample(inputdata, Fs_init, Fs_higher, method='univariate', intfac=False, debug=False):
    starttime = time.time()
    if Fs_higher <= Fs_init:
        print('upsample: target frequency must be higher than initial frequency')
        sys.exit()

    # upsample
    orig_x = sp.linspace(0.0, (1.0 / Fs_init) * len(inputdata), num=len(inputdata), endpoint=False)
    endpoint = orig_x[-1] - orig_x[0]
    ts_higher = 1.0 / Fs_higher
    numresamppts = int(endpoint // ts_higher + 1)
    if intfac:
        numresamppts = int(Fs_higher // Fs_init) * len(inputdata)
    else:
        numresamppts = int(endpoint // ts_higher + 1)
    upsampled_x = np.arange(0.0, ts_higher * numresamppts, ts_higher)
    upsampled_y = doresample(orig_x, inputdata, upsampled_x, method=method)
    initfilter = tide_filt.noncausalfilter(filtertype='arb', usebutterworth=False, debug=debug)
    stopfreq = np.min([1.1 * Fs_init / 2.0, Fs_higher / 2.0])
    initfilter.setfreqs(0.0, 0.0, Fs_init / 2.0, stopfreq)
    upsampled_y = initfilter.apply(Fs_higher, upsampled_y)
    if debug:
        print('upsampling took', time.time() - starttime, 'seconds')
    return upsampled_y 
开发者ID:bbfrederick,项目名称:rapidtide,代码行数:26,代码来源:resample.py

示例12: n_circles

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def n_circles(phases, mag_min=-40.0, mag_max=12.0):
    """Constant-phase contours of the function Gcl = Gol/(1+Gol), where
    Gol is an open-loop transfer function, and Gcl is a corresponding
    closed-loop transfer function.

    Parameters
    ----------
    phases : array-like
        Array of phases in degrees of the N-circles
    mag_min : dB
        Minimum magnitude in dB of the N-circles
    mag_max : dB
        Maximum magnitude in dB of the N-circles

    Returns
    -------
    contours : complex array
        Array of complex numbers corresponding to the contours.
    """
    # Convert phases and magnitude range into a grid suitable for
    # building contours
    mags = sp.linspace(10**(mag_min/20.0), 10**(mag_max/20.0), 2000)
    Gcl_phases, Gcl_mags = sp.meshgrid(sp.radians(phases), mags)
    return closed_loop_contours(Gcl_mags, Gcl_phases)


# Function aliases 
开发者ID:python-control,项目名称:python-control,代码行数:29,代码来源:nichols.py

示例13: plot_nullcline

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def plot_nullcline(self, nullc, style, lw=1, N=100, marker='', figname=None):
        if not self.do_display:
            return
        self.setup(figname)
        x_data = nullc.array[:,0]
        y_data = nullc.array[:,1]
        xs = np.sort( np.concatenate( (np.linspace(x_data[0], x_data[-1], N), x_data) ) )
        ys = nullc.spline(xs)
        pp.plot(xs, ys, style, linewidth=lw)
        if marker != '':
            pp.plot(x_data, y_data, style[0]+marker)
        self.teardown() 
开发者ID:robclewley,项目名称:compneuro,代码行数:14,代码来源:phaseplane.py

示例14: plot_models

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def plot_models(x, y, models, fname, mx=None, ymax=None, xmin=None):

    plt.figure(num=None, figsize=(8, 6))
    plt.clf()
    plt.scatter(x, y, s=10)
    plt.title("Web traffic over the last month")
    plt.xlabel("Time")
    plt.ylabel("Hits/hour")
    plt.xticks(
        [w * 7 * 24 for w in range(10)], ['week %i' % w for w in range(10)])

    if models:
        if mx is None:
            mx = sp.linspace(0, x[-1], 1000)
        for model, style, color in zip(models, linestyles, colors):
            # print "Model:",model
            # print "Coeffs:",model.coeffs
            plt.plot(mx, model(mx), linestyle=style, linewidth=2, c=color)

        plt.legend(["d=%i" % m.order for m in models], loc="upper left")

    plt.autoscale(tight=True)
    plt.ylim(ymin=0)
    if ymax:
        plt.ylim(ymax=ymax)
    if xmin:
        plt.xlim(xmin=xmin)
    plt.grid(True, linestyle='-', color='0.75')
    plt.savefig(fname)

# first look at the data 
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:33,代码来源:analyze_webstats.py

示例15: plotSoundWave

# 需要导入模块: import scipy [as 别名]
# 或者: from scipy import linspace [as 别名]
def plotSoundWave(rate, sample):
    """
        Plots a given sound wave.
    """

    t = scipy.linspace(0, 2, 2*rate, endpoint=False)
    pylab.figure('Sound wave')
    T = int(0.0001*rate)
    pylab.plot(t[:T], sample[:T],)
    pylab.show() 
开发者ID:Agerrr,项目名称:Automated_Music_Transcription,代码行数:12,代码来源:first_peaks_method.py


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