sigma

facecolor kwarg for Matplotlib stacked histogram

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am having trouble controlling the color and linestyle of histogram plotted using Matplotlib's hist function with stacked=True . For a single non-stacked histogram, I have no trouble: import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(10000) n, bins, patches = P.hist( x0, 20, histtype='stepfilled', facecolor='lightblue' ) However, when I introduce additional histograms, import pylab as P mu, sigma = 200, 25 x0 = mu + sigma*P.randn(10000) x1 = mu + sigma*P.randn(7000) x2 = mu + sigma*P.randn(3000) n, bins, patches = P.hist( [x0,x1

Calculating Probability of a Random Variable in a Distribution in Python

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given a mean and standard-deviation defining a normal distribution , how would you calculate the following probabilities in pure-Python (i.e. no Numpy/Scipy or other packages not in the standard library)? The probability of a random variable r where r < x or r <= x. The probability of a random variable r where r > x or r >= x. The probability of a random variable r where x > r > y. I've found some libraries, like Pgnumerics , that provide functions for calculating these, but the underlying math is unclear to me. Edit: To show this isn't

Apply a function to every row of a matrix or a data frame

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose I have a n by 2 matrix and a function that takes a 2-vector as one of its arguments. I would like to apply the function to each row of the matrix and get a n-vector. How to do this in R? For example, I would like to compute the density of a 2D standard Normal distribution on three points: bivariate.density(x = c(0, 0), mu = c(0, 0), sigma = c(1, 1), rho = 0){ exp(-1/(2*(1-rho^2))*(x[1]^2/sigma[1]^2+x[2]^2/sigma[2]^2-2*rho*x[1]*x[2]/(sigma[1]*sigma[2]))) * 1/(2*pi*sigma[1]*sigma[2]*sqrt(1-rho^2)) } out How to apply the function to

Alternative for scipy.stats.norm.pdf?

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anyone know of an alternative for scipy.stats.norm.pdf()? I'm hosting my python site on Google App Engine and Google doesn't support SciPy. I've tried this function, but that didn't return the same results as scipy: def normpdf(x, mu, sigma): u = (x-mu)/abs(sigma) y = (1/(sqrt(2*pi)*abs(sigma)))*exp(-u*u/2) return y For example: print scipy.stats.norm.pdf(20, 20, 10) print normpdf(20, 20, 10) print scipy.stats.norm.pdf(15, 20, 10) print normpdf(15, 20, 10) print scipy.stats.norm.pdf(10, 20, 10) print normpdf(10, 20, 10) Returns these

Sum-of-Product of subsets

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a name for this operation? And: is there a closed-form expression? For a given set of n elements, and value k between 1 and n, Take all subsets (combinations) of k items Find the product of each subset Find the sum of all those products I can express this in Python, and do the calculation pretty easily: from operator import mul from itertools import combinations from functools import reduce def sum_of_product_of_subsets(list1, k): val = 0 for subset in combinations(list1, k): val += reduce(mul, subset) return val I'm just looking

Gaussian filter in scipy

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to apply a Gaussian filter of dimension 5x5 pixels on an image of 512x512 pixels. I found a scipy function to do that: scipy.ndimage.filters.gaussian_filter(input, sigma, truncate=3.0) How I choose the parameter of sigma to make sure that my Gaussian window is 5x5 pixels? 回答1: Check out the source code here: https://github.com/scipy/scipy/blob/master/scipy/ndimage/filters.py You'll see that gaussian_filter calls gaussian_filter1d for each axis. In gaussian_filter1d , the width of the filter is determined implicitly by the values of

Subscript indices must either be real positive integers or logicals?

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to plot the results of my Matlab programme using a for loop which operates from 1 to 10 in increments of 0.1. However I am getting the following error when I attempt to run my code: Subscript indices must either be real positive integers or logicals. Error in BEM (line 101) store_sigma(:,TSR)=sigma; This is my entire code: % Inputs R=0.4; % Radius of Rotor B=3; % Number of blades U=1.73; % Fluid velocity Rho=998; % Fluid Density N=9; % Number of Blade Elements Cp_estimate=0.5; % Estimate power coefficient Alpha_design=4; % Design

电学 学习笔记

痞子三分冷 提交于 2019-12-03 02:33:40
电介质 一些符号 $\epsilon_r$ 相对介电常数(相对空气而言,空气的$\epsilon_r$是1) $\epsilon_0$ 是个定值 $\epsilon = \epsilon_0\epsilon_r $ 就是个定义。。。(说实话不懂把这些比例系数搞来搞去意义何在) $\sigma_0$ 真空下面电荷密度 $\sigma'$ 束缚面电荷密度(就是电介质被极化出来的) E=$\epsilon_rE_0$ 这是实验得出的结论,然后这个$\epsilon_r$也由实验测得,每个电介质不一样。后面就是把这些比例系数搞来搞去 啊啊 由高斯定理$E=\frac{\sigma_0-\sigma'}{\epsilon_0}$,然后E=$\epsilon_rE_0$,这样就可以把$\sigma'$搞掉了: $$\frac{\sigma_0-\sigma'}{\epsilon_0}=\epsilon_r\frac{\sigma_0}{\epsilon_0}$$,$$\sigma'=(1-\frac{1}{\epsilon_r})\sigma_0$$ 来源: https://www.cnblogs.com/jiecaoer/p/11774042.html

howto get fit parameters from seaborn distplot fit=?

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using seaborn distplot (data, fit=stats.gamma) How do I get the fit parameters returned? Here is an example: import numpy as np import pandas as pd import seaborn as sns from scipy import stats df = pd.read_csv ('RequestSize.csv') import matplotlib.pyplot as plt reqs = df['12 web pages'] reqs = reqs.dropna() reqs = reqs[np.logical_and (reqs > np.percentile (reqs, 0), reqs < np.percentile (reqs, 95))] dist = sns.distplot (reqs, fit=stats.gamma) 回答1: Use the object you passed to distplot : stats.gamma.fit(reqs) 回答2: I confirm the above is

How to force larger steps on scipy.optimize functions?

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a function compare_images(k, a, b) that compares two 2d-arrays a and b Inside the funcion, I apply a gaussian_filter with sigma=k to a My idea is to estimate how much I must to smooth image a in order for it to be similar to image b The problem is my function compare_images will only return different values if k variation is over 0.5 , and if I do fmin(compare_images, init_guess, (a, b) it usually get stuck to the init_guess value. I believe the problem is fmin (and minimize ) tends to start with very small steps, which in my case