normal-distribution

R - multivariate normal distribution in R

你离开我真会死。 提交于 2019-12-08 05:45:58
问题 I would like to simulate a multivariate normal distribution in R. I've seen I need the values of mu and sigma. Unfortunately, I don't know how obtain them. In the following link you will find my data in a csv file "Input.csv". Thanks https://www.dropbox.com/sh/blnr3jvius8f3eh/AACOhqyzZGiDHAOPmyE__873a?dl=0 Please, could you show me an example? Raúl 回答1: Your link is broken, but I understand that you want to generate random samples from empirical multivariate normal distribution. You can do it

Creating a normal distribution graph with JFreeChart

倾然丶 夕夏残阳落幕 提交于 2019-12-08 03:15:04
问题 I am trying to make a normal distribution graph using the JFreeChart library. I am successful if I try to get one area under the graph. However I did not find a way on how get 2 areas under the graph. Here is the code for one side : public GrafHujungKanan() { Function2D normal = new NormalDistributionFunction2D(0.0, 1.0); dataset = DatasetUtilities.sampleFunction2D(normal, -4, 4, 100, "Normal"); XYSeries fLine = new XYSeries("fLine"); fLine.add(nilaiKritikal, 0); fLine.add(4, 0); (

Transform data to fit normal distribution

隐身守侯 提交于 2019-12-07 18:16:59
问题 I have a rather easy-to-understand question. I have a set of data and I want to estimate how good this data fit a standard normal distribution . To do so, I start with my code: [f_p,m_p] = hist(data,128); f_p = f_p/trapz(m_p,f_p); x_th = min(data):.001:max(data); y_th = normpdf(x_th,0,1); figure(1) bar(m_p,f_p) hold on plot(x_th,y_th,'r','LineWidth',2.5) grid on hold off Fig. 1 will look like the one below: Easy to see that the fit is quite poor, altough the bell-shape can be spotted. The

evaluate multivariate Normal/Gaussian Density in c++

最后都变了- 提交于 2019-12-06 12:52:21
问题 Right now I have the following function to evaluate the Gaussian density: double densities::evalMultivNorm(const Eigen::VectorXd &x, const Eigen::VectorXd &meanVec, const Eigen::MatrixXd &covMat) { double inv_sqrt_2pi = 0.3989422804014327; double quadform = (x - meanVec).transpose() * covMat.inverse() * (x-meanVec); double normConst = pow(inv_sqrt_2pi, covMat.rows()) * pow(covMat.determinant(), -.5); return normConst * exp(-.5* quadform); } This is just transcribing the formula. However I get

Drawing decision boundary of two multivariate gaussian

断了今生、忘了曾经 提交于 2019-12-06 12:33:59
I am trying to plot something similar to below: I am using Matlab. I achieved drawing contour plots. However I could not draw the discriminant. Can anyone show a sample Matlab code or give some idea to draw the discriminant? If you know the probability density function of each of the gaussian for a given point (x,y) , lets say its pdf1(x,y) and pdf2(x,y) then you can simply plot the contour line of f(x,y) := pdf1(x,y) > pdf2(x,y) . So you define function f to be 1 iff pdf1(x,y)>pdf2(x,y) . This way the only contour will be placed along the curve where pdf1(x,y)==pdf2(x,y) which is the decision

creating a single colored point over a normal distribution in ggplot

怎甘沉沦 提交于 2019-12-06 12:06:55
问题 I was looking to plot a normal distribution in ggplot, and at the suggestion of @nrussell I have used ggplot(data.frame(x = c(-5, 5)), aes(x)) + stat_function(fun = dnorm) I am wondering if there is any way to, within the context of stat_function , layer a single colored point directly onto the curve. For example, if I wanted to put a dot where the x axis is marked 2. I have experimented with geom_point but this appears to be better at creating scatterplots: I can't seem to pipe in the

Transform data to fit normal distribution

♀尐吖头ヾ 提交于 2019-12-06 03:23:54
I have a rather easy-to-understand question. I have a set of data and I want to estimate how good this data fit a standard normal distribution . To do so, I start with my code: [f_p,m_p] = hist(data,128); f_p = f_p/trapz(m_p,f_p); x_th = min(data):.001:max(data); y_th = normpdf(x_th,0,1); figure(1) bar(m_p,f_p) hold on plot(x_th,y_th,'r','LineWidth',2.5) grid on hold off Fig. 1 will look like the one below: Easy to see that the fit is quite poor, altough the bell-shape can be spotted. The main problem resides therefore in the variance of my data. To find out the proper number of occurrances my

Vectorizing the multivariate normal CDF (cumulative density function) in Python

淺唱寂寞╮ 提交于 2019-12-06 02:31:23
问题 How can I vectorize the multivariate normal CDF (cumulative density function) in Python? When looking at this post, I found out that there is a Fortran implementation of the multivariate CDF that was "ported" over to Python. This means I can easily evaluate the CDF for one specific case. However, I'm having a lot of trouble efficiently applying this function to multiple entries. Specifically speaking, the function I need to "vectorize" takes 4 arguments: the lower bounds of integration(vector

Determine a normal distribution given its quantile information

我的未来我决定 提交于 2019-12-05 18:14:51
I was wondering how I could have R tell me the SD (as an argument in the qnorm() built in R) for a normal distribution whose 95% limit values are already known? As an example, I know the two 95% limit values for my normal are 158, and 168, respectively. So, in the below R code SD is shown as "x". If "y" (the answer of this simple qnorm() function) needs to be (158, 168), then can R tell me what should be x ? y <- qnorm(c(.025,.975), 163, x) A general procedure for Normal distribution Suppose we have a Normal distribution X ~ N(mu, sigma) , with unknown mean mu and unknown standard deviation

Getting high precision values from qnorm in the tail

对着背影说爱祢 提交于 2019-12-05 06:32:29
The problem I am looking for high precision values for the normal distribution in the tail (1e-10 and 1 - 1e-10) , as the R package that I am using sets any number which is out of this range to these values and then calls the qnorm and qt function. What I have noticed is that the qnorm implementation in R is not symmetric when looking at the tails. This is quite surprising to me, as it is well known that this distribution is symmetric, and I have seen implementations in other languages that are symmetric. I have checked the qt function and it is also not symmetric in the tails. Here are the