normal-distribution

Fast incremental update of the mean and covariance in Python

巧了我就是萌 提交于 2020-01-02 07:49:08
问题 I have a Python script where I need to frequently update the mean and co-variance matrix. What I am currently doing is that each time I get a new data point $x$ (a vector), I recompute the mean and covariance as follows: data.append(x) # My `data` is just a list of lists of floats (i.e., x is a list of floats) self.mean = np.mean( data, axis=0) # self.mean is a list representing the center of data self.cov = np.cov( data, rowvar=0) The problem is that is not fast enough for me. Is there

normality test of a distribution in python

我的梦境 提交于 2020-01-01 02:40:38
问题 I have some data I have sampled from a radar satellite image and wanted to perform some statistical tests on. Before this I wanted to conduct a normality test so I could be sure my data was normally distributed. My data appears to be normally distributed but when I perform the test Im getting a Pvalue of 0, suggesting my data is not normally distributed. I have attached my code along with the output and a histogram of the distribution (Im relatively new to python so apologies if my code is

when generating normally-distributed random values, what is the most efficient way to define the range?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 00:43:11
问题 FYI: random == pseudo-random A. when generating uniformly-random numbers, I can specify a range, i.e.: (Math.random()-Math.random())*10+5 //generates numbers between -5 and 15 B. generating a set of random values with a version of Gaussian-esque normal randomness: //pass in the mean and standard deviation function randomNorm(mean, stdev) { return Math.round((Math.random()*2-1)+(Math.random()*2-1)+(Math.random()*2-1))*stdev+mean); } //using the following values: { mean:400, standard_deviation

Separate mixture of gaussians in Python

随声附和 提交于 2019-12-31 08:39:23
问题 There is a result of some physical experiment, which can be represented as a histogram [i, amount_of(i)] . I suppose that result can be estimated by a mixture of 4 - 6 Gaussian functions. Is there a package in Python which takes a histogram as an input and returns the mean and variance of each Gaussian distribution in the mixture distribution? Original data, for example: 回答1: This is a mixture of gaussians, and can be estimated using an expectation maximization approach (basically, it finds

Ellipse around the data in MATLAB

半腔热情 提交于 2019-12-28 11:53:43
问题 I would like to reproduce the following figure in MATLAB: There are two classes of points with X and Y coordinates. I'd like to surround each class with an ellipse with one parameter of standard deviation, which determine how far the ellipse will go along the axis. The figure was created with another software and I don't exactly understand how it calculates the ellipse. Here is the data I'm using for this figure. The 1st column is class, 2nd - X, 3rd - Y. I can use gscatter to draw the points

pseudorandom number generation from truncated normal distribution in FORTRAN [closed]

旧街凉风 提交于 2019-12-27 01:45:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am trying to draw pseudo random numbers from a left-truncated normal distribution using FORTRAN. I want the function to return values with the same dimension as inputs: FUNCTION (MU, SIGMA) ; mu=N x 1 and SIGMA = N X 1 Can someone help please? Thanks in advance 回答1: Perhaps use the GNU Scientific Library and

Inverse Mills Ratio in Matlab

感情迁移 提交于 2019-12-25 01:44:50
问题 I am trying to program in Matlab a conditional expectation of the form: E[x|A<=x<=B] where X~N(u,s^2) (sorry, apparently the math editing here isn't what I am used to) In Matlab, I have written up the following code: Y=u+s*(normpdf(A,u,s)-normpdf(B,u,s))/(normcdf(B,u,s)-normcdf(A,u,s)) the problem is that it breaks down at higher values of A and B. For example, let u=0, s=1, A=10 and B=11. Simple logic says the answer should be between 10 and 11, but Matlab gives me back Inf because the

3D Plot of normal distribution in R around a (x,y) point

和自甴很熟 提交于 2019-12-24 12:16:52
问题 I want to plot a univariate normal density function of the normal distribution onto a (x,y,z) coordinate system. The code I am using is: library(rgl) open3d() x <- seq(0, 10, length=100) y <- seq(0, 10, length=100) z = outer(x,y, function(x,y) dnorm(x,2.5,1)*dnorm(y,2.5,1)) persp3d(x, y, z,col = rainbow(100)) The problem I an encountering is that I want the normal distribution not to be around its mean only but also to be on a straight line or a circle. In latter case, I would expect the

NORMDIST function is not giving the correct output

限于喜欢 提交于 2019-12-24 01:26:00
问题 I'm trying to use NORMDIST function in Excel to create a bell curve, but the output is strange. My mean is 0,0000583 and standard deviation is 0,0100323 so when I plug this to the function NORMDIST(0,0000583; 0,0000583; 0,0100323; FALSE) I expect to get something close to 0,5 as I'm using the same value as the mean probability of this value should be 50% , but the function gives an output of 39,77 which is clearly not correct. Why is it like this? 回答1: A probability cannot have values greater

example algorithm for generating random value in dataset with normal distribution?

…衆ロ難τιáo~ 提交于 2019-12-23 21:20:58
问题 I'm trying to generate some random numbers with simple non-uniform probability to mimic lifelike data for testing purposes. I'm looking for a function that accepts mu and sigma as parameters and returns x where the probably of x being within certain ranges follows a standard bell curve, or thereabouts. It needn't be super precise or even efficient. The resulting dataset needn't match the exact mu and sigma that I set. I'm just looking for a relatively simple non-uniform random number