python安装mlab库_Python mlab.normpdf方法代码示例
本文整理汇总了Python中matplotlib.mlab.normpdf方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.normpdf方法的具体用法?Python mlab.normpdf怎么用?Python mlab.normpdf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块matplotlib.mlab的用法示例。
在下文中一共展示了mlab.normpdf方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: histogram_demo
点赞 6
# 需要导入模块: 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,
示例2: plot_t_value_hist
点赞 6
# 需要导入模块: 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
示例3: plot_z
点赞 6
# 需要导入模块: 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,
示例4: _fitted_E_plot
点赞 5
# 需要导入模块: 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,
示例5: _rerender
点赞 5
# 需要导入模块: 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,
示例6: render
点赞 5
# 需要导入模块: 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,
示例7: plot_distribution
点赞 5
# 需要导入模块: 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,
示例8: plot_distribution
点赞 5
# 需要导入模块: 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,
示例9: makeSpectre
点赞 5
# 需要导入模块: 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,
示例10: plot_normal
点赞 5
# 需要导入模块: 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,
示例11: plot_hist
点赞 4
# 需要导入模块: 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,
注:本文中的matplotlib.mlab.normpdf方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
python安装mlab库_Python mlab.normpdf方法代码示例相关推荐
- python连接redis哨兵_Python redis.sentinel方法代码示例
本文整理汇总了Python中redis.sentinel方法的典型用法代码示例.如果您正苦于以下问题:Python redis.sentinel方法的具体用法?Python redis.sentine ...
- python程序异常实例_Python werkzeug.exceptions方法代码示例
本文整理汇总了Python中werkzeug.exceptions方法的典型用法代码示例.如果您正苦于以下问题:Python werkzeug.exceptions方法的具体用法?Python wer ...
- python中geometry用法_Python geometry.Point方法代码示例
本文整理汇总了Python中shapely.geometry.Point方法的典型用法代码示例.如果您正苦于以下问题:Python geometry.Point方法的具体用法?Python geome ...
- python re 简单实例_Python re.search方法代码示例
本文整理汇总了Python中re.search方法的典型用法代码示例.如果您正苦于以下问题:Python re.search方法的具体用法?Python re.search怎么用?Python re. ...
- python中config命令_Python config.config方法代码示例
本文整理汇总了Python中config.config方法的典型用法代码示例.如果您正苦于以下问题:Python config.config方法的具体用法?Python config.config怎么 ...
- python中fact用法_Python covariance.EllipticEnvelope方法代码示例
本文整理汇总了Python中sklearn.covariance.EllipticEnvelope方法的典型用法代码示例.如果您正苦于以下问题:Python covariance.EllipticEn ...
- python 求 gamma 分布_Python stats.gamma方法代码示例
本文整理汇总了Python中scipy.stats.gamma方法的典型用法代码示例.如果您正苦于以下问题:Python stats.gamma方法的具体用法?Python stats.gamma怎么 ...
- python messagebox弹窗退出_Python messagebox.showinfo方法代码示例
本文整理汇总了Python中tkinter.messagebox.showinfo方法的典型用法代码示例.如果您正苦于以下问题:Python messagebox.showinfo方法的具体用法?Py ...
- python关于messagebox题目_Python messagebox.askokcancel方法代码示例
本文整理汇总了Python中tkinter.messagebox.askokcancel方法的典型用法代码示例.如果您正苦于以下问题:Python messagebox.askokcancel方法的具 ...
- python class def 格式_Python symbol.classdef方法代码示例
# 需要导入模块: import symbol [as 别名] # 或者: from symbol import classdef [as 别名] def _get_forbidden_symbols ...
最新文章
- 查看Linux服务器下的内存使用情况
- 开启ntp服务_Linux入门:Linux自有服务及软件包
- c语言使单片机输出低电平,单片机开发中的一些实用技巧
- mysql select 40001_【转】关于 SELECT /*!40001 SQL_NO_CACHE */ * FROM 的解惑
- [OS复习]进程互斥与同步2
- jdbc mysql 远程数据库_jdbc 连接远程mysql数据库的有关问题
- Android注册BroadcastReceiver的两种办法及其区别
- Makefile.am
- Hadoop视频教程资源链接
- Python字符串index()方法应用案例一则
- python datetime 加一个月_Python日期的加减等操作的示例
- 基于linux桌面3d面打印机,基于DLP技术的桌面级3D打印机研发
- 读书节第三日丨产品大咖荐读直播齐上阵,学院超级会员限时开抢!
- 汇编语言将正负数复制到不同的数组
- odoo13 订单模板设置_ERP输出嵌入公章的采购订单电子档,其实真的不难
- sql数据库置疑解决办法
- Word 2019 插入参考文献
- Netbeans使用问题整理
- 基于等级保护梳理服务器安全合规基线
- .net ref java_Java URL.getRef方法代碼示例