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


Python mlab.normpdf方法代码示例

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


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

示例1: _rerender

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def _rerender(self):
        nmr_maps = len(self.maps_to_show)
        if self._show_trace:
            nmr_maps *= 2

        grid = GridSpec(nmr_maps, 1, left=0.04, right=0.96, top=0.94, bottom=0.06, hspace=0.2)

        i = 0
        for map_name in self.maps_to_show:
            samples = self._voxels[map_name]

            if self._sample_indices is not None:
                samples = samples[:, self._sample_indices]

            title = map_name
            if map_name in self.names:
                title = self.names[map_name]

            if isinstance(self._nmr_bins, dict) and map_name in self._nmr_bins:
                nmr_bins = self._nmr_bins[map_name]
            else:
                nmr_bins = self._nmr_bins

            hist_plot = plt.subplot(grid[i])
            try:
                n, bins, patches = hist_plot.hist(np.nan_to_num(samples[self.voxel_ind, :]), nmr_bins, normed=True)
                plt.title(title)
                i += 1

                if self._fit_gaussian:
                    mu, sigma = norm.fit(samples[self.voxel_ind, :])
                    bincenters = 0.5*(bins[1:] + bins[:-1])
                    y = mlab.normpdf(bincenters, mu, sigma)
                    hist_plot.plot(bincenters, y, 'r', linewidth=1)

                if self._show_trace:
                    trace_plot = plt.subplot(grid[i])
                    trace_plot.plot(samples[self.voxel_ind, :])
                    i += 1
            except IndexError:
                pass 
开发者ID:robbert-harms,项目名称:MDT,代码行数:43,代码来源:samples.py

示例2: histogram_demo

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def histogram_demo(ax):
    # example data
    mu = 100  # mean of distribution
    sigma = 15  # standard deviation of distribution
    x = mu + sigma * np.random.randn(10000)

    num_bins = 50

    # The histogram of the data.
    _, bins, _ = ax.hist(x, num_bins, normed=1, label='data')

    # Add a 'best fit' line.
    y = mlab.normpdf(bins, mu, sigma)
    ax.plot(bins, y, '-s', label='best fit')

    ax.legend()
    ax.set_xlabel('Smarts')
    ax.set_ylabel('Probability')
    ax.set_title(r'Histogram of IQ: $\mu=100$, $\sigma=15$') 
开发者ID:tonysyu,项目名称:matplotlib-style-gallery,代码行数:21,代码来源:bar-plots.py

示例3: plot_t_value_hist

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_t_value_hist(
	img_path='~/ni_data/ofM.dr/l1/as_composite/sub-5703/ses-ofM/sub-5703_ses-ofM_task-EPI_CBV_chr_longSOA_tstat.nii.gz',
	roi_path='~/ni_data/templates/roi/DSURQEc_ctx.nii.gz',
	mask_path='/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii',
	save_as='~/qc_tvalues.pdf',
	):
	"""Make t-value histogram plot"""

	f, axarr = plt.subplots(1, sharex=True)

	roi = nib.load(path.expanduser(roi_path))
	roi_data = roi.get_data()
	mask = nib.load(path.expanduser(mask_path))
	mask_data = mask.get_data()
	idx = np.nonzero(np.multiply(roi_data,mask_data))
	img = nib.load(path.expanduser(img_path))
	data = img.get_data()[idx]
	(mu, sigma) = norm.fit(data)
	n, bins, patches = axarr.hist(data,'auto',normed=1, facecolor='green', alpha=0.75)
	y = mlab.normpdf(bins, mu, sigma)

	axarr.plot(bins, y, 'r--', linewidth=2)
	axarr.set_title('Histogram of t-values $\mathrm{(\mu=%.3f,\ \sigma=%.3f}$)' %(mu, sigma))
	axarr.set_xlabel('t-values')
	plt.savefig(path.expanduser(save_as)) 
开发者ID:IBT-FMI,项目名称:SAMRI,代码行数:27,代码来源:qc.py

示例4: plot_z

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_z(self,figsize=(15,5)):
        import matplotlib.pyplot as plt
        import seaborn as sns

        if hasattr(self, 'sample'):
            sns.distplot(self.prior.transform(self.sample), rug=False, hist=False,label=self.method + ' estimate of ' + self.name)

        elif hasattr(self, 'value') and hasattr(self, 'std'):
            x = np.linspace(self.value-self.std*3.5,self.value+self.std*3.5,100)
            plt.figure(figsize=figsize)
            if self.prior.transform_name is None:
                plt.plot(x,mlab.normpdf(x,self.value,self.std),label=self.method + ' estimate of ' + self.name)
            else:
                sims = self.prior.transform(np.random.normal(self.value,self.std,100000))
                sns.distplot(sims, rug=False, hist=False,label=self.method + ' estimate of ' + self.name)
            plt.xlabel('Value')
            plt.legend()
            plt.show()

        else:
            raise ValueError("No information on latent variable to plot!") 
开发者ID:RJT1990,项目名称:pyflux,代码行数:23,代码来源:latent_variables.py

示例5: plot_normal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_normal(ax, arr):
    """

    :param ax:
    :param mu:
    :param variance:
    :return:
    """
    mu = arr.mean()
    variance = arr.var()
    sigma = math.sqrt(variance)
    x = np.linspace(mu - 6 * sigma, mu + 6 * sigma, 100)

    if mu != 0 and sigma != 0:
        ax.plot(x, mlab.normpdf(x, mu, sigma)) 
开发者ID:SanPen,项目名称:GridCal,代码行数:17,代码来源:impedances_clustering.py

示例6: _fitted_E_plot

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def _fitted_E_plot(d, i=0, F=1, no_E=False, ax=None, show_model=True,
                   verbose=False, two_gauss_model=False, lw=2.5, color='k',
                   alpha=0.5, fillcolor=None):
    """Plot a fitted model overlay on a FRET histogram."""
    if ax is None:
        ax2 = gca()
    else:
        ax2 = plt.twinx(ax=ax)
        ax2.grid(False)

    if d.fit_E_curve and show_model:
        x = r_[-0.2:1.21:0.002]
        y = d.fit_E_model(x, d.fit_E_res[i, :])
        scale = F*d.fit_E_model_F[i]
        if two_gauss_model:
            assert d.fit_E_res.shape[1] > 2
            if d.fit_E_res.shape[1] == 5:
                m1, s1, m2, s2, a1 = d.fit_E_res[i, :]
                a2 = (1-a1)
            elif d.fit_E_res.shape[1] == 6:
                m1, s1, a1, m2, s2, a2 = d.fit_E_res[i, :]
            y1 = a1*normpdf(x, m1, s1)
            y2 = a2*normpdf(x, m2, s2)
            ax2.plot(x, scale*y1, ls='--', lw=lw, alpha=alpha, color=color)
            ax2.plot(x, scale*y2, ls='--', lw=lw, alpha=alpha, color=color)
        if fillcolor is None:
            ax2.plot(x, scale*y, lw=lw, alpha=alpha, color=color)
        else:
            ax2.fill_between(x, scale*y, lw=lw, alpha=alpha, edgecolor=color,
                             facecolor=fillcolor, zorder=10)
        if verbose:
            print('Fit Integral:', np.trapz(scale*y, x))

    ax2.axvline(d.E_fit[i], lw=3, color=red, ls='--', alpha=0.6)
    xtext = 0.6 if d.E_fit[i] < 0.6 else 0.2
    if d.nch > 1 and not no_E:
        ax2.text(xtext, 0.81, "CH%d: $E_{fit} = %.3f$" % (i+1, d.E_fit[i]),
                 transform=gca().transAxes, fontsize=16,
                 bbox=dict(boxstyle='round', facecolor='#dedede', alpha=0.5)) 
开发者ID:tritemio,项目名称:FRETBursts,代码行数:41,代码来源:burst_plot.py

示例7: render

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def render(d, x, primary, secondary, parameter, norm_and_curve=False):
    fig, ax = plt.subplots()
    fig.suptitle(string.upper("%s vs. %s" % (primary, secondary)), fontsize=14, fontweight='bold')

    n, bins, patches = plt.hist(x, 50, normed=norm_and_curve, facecolor='green', alpha=0.75)

    if norm_and_curve:
        mean = np.mean(x)
        variance = np.var(x)
        sigma = np.sqrt(variance)
        y = mlab.normpdf(bins, mean, sigma)
        l = plt.plot(bins, y, 'r--', linewidth=1)

    ax.set_title('n = %d' % len(x))

    units = PARAMETER_TO_UNITS[parameter] if parameter in PARAMETER_TO_UNITS else PARAMETER_TO_UNITS["sst"]
    ax.set_xlabel("%s - %s %s" % (primary, secondary, units))

    if norm_and_curve:
        ax.set_ylabel("Probability per unit difference")
    else:
        ax.set_ylabel("Frequency")

    plt.grid(True)

    sio = StringIO()
    plt.savefig(sio, format='png')
    d['plot'] = sio.getvalue() 
开发者ID:apache,项目名称:incubator-sdap-nexus,代码行数:30,代码来源:histogramplot.py

示例8: plot_distribution

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_distribution(self, mean, sigma, array):
        vlines = [mean-(1*sigma), mean, mean+(1*sigma)]
        for val in vlines:
            plt.axvline(val, color='k', linestyle='--')

        bins = np.linspace(mean-(4*sigma), mean+(4*sigma), 200)
        plt.hist(array, bins, alpha=0.5)

        y = mlab.normpdf(bins, mean, sigma)
        plt.plot(bins, y, 'r--')
        plt.subplots_adjust(left=0.15)
        plt.show()
        print mean, sigma 
开发者ID:UKPLab,项目名称:acl2017-interactive_summarizer,代码行数:15,代码来源:aggregation.py

示例9: plot_distribution

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_distribution(self, mean, sigma, array):
        vlines = [mean-(1*sigma), mean, mean+(1*sigma)]
        for val in vlines:
            plt.axvline(val, color='k', linestyle='--')

        bins = np.linspace(mean-(4*sigma), mean+(4*sigma), 200)
        plt.hist(array, bins, alpha=0.5)

        y = mlab.normpdf(bins, mean, sigma)
        plt.plot(bins, y, 'r--')
        plt.subplots_adjust(left=0.15)
        plt.show()
        print(mean, sigma) 
开发者ID:UKPLab,项目名称:acl2017-interactive_summarizer,代码行数:15,代码来源:aggregation_new.py

示例10: makeSpectre

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def makeSpectre(transitions, sigma, step):
    """ Build a spectrum from transitions energies. For each transitions a gaussian
    function of width sigma is added in order to mimick natural broadening.
    
        :param transitions: list of transitions for readTransitions()
        :type transititions: list
        :param sigma: gaussian width in eV
        :type sigma: float
        :param step: number of absissa value
        :type step: int
        :return: absissa and spectrum value in this order
        :rtype: list, list
    
    """

    # max and min transition energies
    minval = min([val[0] for val in transitions]) - 5.0 * sigma
    maxval = max([val[0] for val in transitions]) + 5.0 * sigma
 
    # points
    npts   = int((maxval - minval) / step) + 1

    # absice
    eneval = sp.linspace(minval, maxval, npts)

    spectre = sp.zeros(npts)
    for trans in transitions:
        spectre += trans[2] * normpdf(eneval, trans[0], sigma)

    return eneval, spectre 
开发者ID:gVallverdu,项目名称:myScripts,代码行数:32,代码来源:spectre.py

示例11: plot_hist

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import normpdf [as 别名]
def plot_hist(
    image,
    threshold=0.0,
    fit_line=False,
    normfreq=True,
    ## plot label arguments
    title=None,
    grid=True,
    xlabel=None,
    ylabel=None,
    ## other plot arguments
    facecolor="green",
    alpha=0.75,
):
    """
    Plot a histogram from an ANTsImage

    Arguments
    ---------
    image : ANTsImage
        image from which histogram will be created
    """
    img_arr = image.numpy().flatten()
    img_arr = img_arr[np.abs(img_arr) > threshold]

    if normfreq != False:
        normfreq = 1.0 if normfreq == True else normfreq
    n, bins, patches = plt.hist(
        img_arr, 50, normed=normfreq, facecolor=facecolor, alpha=alpha
    )

    if fit_line:
        # add a 'best fit' line
        y = mlab.normpdf(bins, img_arr.mean(), img_arr.std())
        l = plt.plot(bins, y, "r--", linewidth=1)

    if xlabel is not None:
        plt.xlabel(xlabel)
    if ylabel is not None:
        plt.ylabel(ylabel)
    if title is not None:
        plt.title(title)

    plt.grid(grid)
    plt.show() 
开发者ID:ANTsX,项目名称:ANTsPy,代码行数:47,代码来源:plot.py


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