probability-density

Matconvnet output of deep network's marix is uniform valued instead of varying values?

[亡魂溺海] 提交于 2019-12-04 21:19:37
Im trying to achieve a density map from network output of dimension 20x20x1x50. Here 20x20 is the output map and 50 is the batch size. The issue is that the value of output X is equal 0.098 across each output matrix..20x20. There is no gaussian shape like density map but a flat similar valued output map 20x20x1x50. The issue is shown in the figure attached. What am i missing here? The euclidean loss for backpropagation is given as: case {'l2loss'} res=(c-X); n=1; if isempty(dzdy) %forward Y = sum((res(:).^2))/numel(res); else Y_= -1.*(c-X); Y = 2*single (Y_ * (dzdy / n) ); end Found the

confusion on 2 dimension kernel density estimation in R

大兔子大兔子 提交于 2019-12-04 20:31:16
A kernel density estimator is used to estimate a particular probability density function (see mvstat.net and sckit-learn docs for references) My confusion is about what exactly does kde2d() do? Does it estimate the joint distribution probability density function of two random variables f(a,b) in the below example? And what does the color mean? Here is the code example I am referring to. b <- log10(rgamma(1000, 6, 3)) a <- log10((rweibull(1000, 8, 2))) density <- kde2d(a, b, n=100) colour_flow <- colorRampPalette(c('white', 'blue', 'yellow', 'red', 'darkred')) filled.contour(density, color

How do I calculate PDF (probability density function) in Python?

有些话、适合烂在心里 提交于 2019-12-04 13:29:15
问题 I have the following code below that prints the PDF graph for a particular mean and standard deviation. http://imgur.com/a/oVgML Now I need to find the actual probability, of a particular value. So for example if my mean is 0, and my value is 0, my probability is 1. This is usually done by calculating the area under the curve. Similar to this: http://homepage.divms.uiowa.edu/~mbognar/applets/normal.html I am not sure how to approach this problem import numpy as np import matplotlib import

How to generate random numbers with predefined probability distribution?

孤街醉人 提交于 2019-12-04 12:59:33
问题 I would like to implement a function in python (using numpy ) that takes a mathematical function (for ex. p(x) = e^(-x) like below) as input and generates random numbers, that are distributed according to that mathematical-function's probability distribution. And I need to plot them, so we can see the distribution. I need actually exactly a random number generator function for exactly the following 2 mathematical functions as input, but if it could take other functions, why not: 1) p(x) = e^(

Beta Binomial Function in Python

偶尔善良 提交于 2019-12-04 03:36:20
问题 I would like to calculate the probability given by a binomial distribution for predetermined x(successes), n(trials), and p(probability) - the later of which is given by a probability mass function Beta(a,b). I am aware of scipy.stats.binom.pmf(x,n,p) - but I am unsure how I can replace p with a probability function. I am also wondering whether I could use the loc argument of scipy.stats.binom.pmf to emulate this behaviour. 回答1: Wiki says that the compound distribution function is given by f

Calculating the derivative of cumulative density function in Python

孤人 提交于 2019-12-04 02:53:49
Is it the case that the exact derivative of a cumulative density function is the probability density function (PDF)? I am calculating the derivative using the numpy.diff() , is this correct? See below code below: import scipy.stats as s import matplotlib.pyplot as plt import numpy as np wei = s.weibull_min(2, 0, 2) # shape, loc, scale - creates weibull object sample = wei.rvs(1000) shape, loc, scale = s.weibull_min.fit(sample, floc=0) x = np.linspace(np.min(sample), np.max(sample)) plt.hist(sample, normed=True, fc="none", ec="grey", label="frequency") plt.plot(x, wei.cdf(x), label="cdf") plt

Exact kernel density value for any point in R [duplicate]

ε祈祈猫儿з 提交于 2019-12-03 20:39:00
This question already has answers here : Closed 2 years ago . Find the probability density of a new data point using “density” function in R (3 answers) Density Value for each Return (3 answers) I was wondering if there is a R base way to obtain the exact kernel density at any point desired? As an example, how can I get the exact kernel density at the 3 following points -2, 0, +2 on X-Axis in a plot like below? set.seed(2937107) plot( density(rnorm(1e4)) ) Use linear interpolation to find it. d <- density(rnorm(10000)) approx(d$x, d$y, xout = c(-2, 0, 2)) The precision of interpolation can be

Generate random variables from a distribution function using inverse sampling

天大地大妈咪最大 提交于 2019-12-03 13:45:57
I have a specific density function and I want to generate random variables knowing the expression of the density function. For example, the density function is : df=function(x) { - ((-a1/a2)*exp((x-a3)/a2))/(1+exp((x-a3)/a2))^2 } From this expression I want to generate 1000 random elements with the same distribution. I know I should use the inverse sampling method. For this, I use the CDF function of my PDF which is calculated as follows: cdf=function(x) { 1 - a1/(1+exp((x-a3)/a2)) The idea is to generate uniformly distributed samples and then map them with my CDF functions to get an inverse

R: Generate data from a probability density distribution

别说谁变了你拦得住时间么 提交于 2019-12-03 02:57:56
Say I have a simple array, with a corresponding probability distribution. library(stats) data <- c(0,0.08,0.15,0.28,0.90) pdf_of_data <- density(data, from= 0, to=1, bw=0.1) Is there a way I could generate another set of data using the same distribution. As the operation is probabilistic, it need not exactly match the initial distribution anymore, but will be just generated from it. I did have success finding a simple solution on my own. Thanks! Your best bet is to generate the empirical cumulative density function, approximate the inverse, and then transform the input. The compound expression

calculate area of overlapping density plot by ggplot using R

醉酒当歌 提交于 2019-12-01 19:50:23
How can I get the area under overlapping density curves? How can I solve the problem with R? (There is a solution for python here: Calculate overlap area of two functions ) set.seed(1234) df <- data.frame( sex=factor(rep(c("F", "M"), each=200)), weight=round(c(rnorm(200, mean=55, sd=5), rnorm(200, mean=65, sd=5))) ) (Source: http://www.sthda.com/english/wiki/ggplot2-density-plot-quick-start-guide-r-software-and-data-visualization ) ggplot(df, aes(x=weight, color=sex, fill=sex)) + geom_density(aes(y=..density..), alpha=0.5) "The points used in the plot are returned by ggplot_build(), so you can