Questions tagged [kernel-density]

kernel density estimation is a non-parametric way to estimate the probability density function of a random variable.

Kernel density estimation is a fundamental data smoothing problem where inferences about the population are made, based on a finite data sample. Kernel density estimates are closely related to histograms, but can be endowed with properties such as smoothness or continuity by using a suitable kernel

http://en.wikipedia.org/wiki/Kernel_density_estimation

656 questions
3
votes
2 answers

How to return mean value (or expectation value) of a distribution estimated via function KernelDensity of sklearn, in python?

My question is, how to return the mean value and variance of the estimated "kde"? Or is there any other package you known that can easily output mean value or variance value, like print kde.mean() or print kde.get_parameter(mean)? import numpy as…
guorui
  • 871
  • 2
  • 9
  • 21
3
votes
1 answer

Why do stat_density (R; ggplot2) and gaussian_kde (Python; scipy) differ?

I am attempting to produce a KDE based PDF estimate on a series of distributions that may not be normally distributed. I like the way ggplot's stat_density in R seems to recognize every incremental bump in frequency, but cannot replicate this via…
UBHDNNX
  • 61
  • 1
  • 9
3
votes
1 answer

Remove background color in a kernel density plot ( seaborn.kdeplot)

I am trying to plot a Seaborn Kernel density over a map (Shapefile). To generate the Kernel density, I used the following code in the Seaborn Website x, y = np.random.multivariate_normal([0, 0], [[1, -.5], [-.5, 1]], size=300).T cmap =…
3
votes
2 answers

How to not display the pearson's coefficient on seaborn's jointplot?

I'm trying to generate a joint plot from the seaborn library, and I was wondering whether anyone knew how to not display the pearson's coefficient on the plot as it seems to be the default, as shown here: The code that I'm using the generate the…
ach
  • 47
  • 1
  • 4
3
votes
1 answer

How to perform Kernel Density Estimation in Tensorflow

I'm trying to write a Kernel Density Estimation algorithm in Tensorflow. When fitting the KDE model, I am iterating through all the data in the current batch and, for each, I am creating a kernel using the…
3
votes
1 answer

Gaussian summation for 2D scatter plots using python

I am trying to establish what people would loosely refer to as a homemade KDE - I suppose. I am trying to evaluate a density of a rather huge set of datapoints. In particular, having many data points for a scatter, I want to indicate the density…
Fourier
  • 2,795
  • 3
  • 25
  • 39
3
votes
0 answers

SGDClassifier for non linear SVM

l have a huge datasets 1) dataset_1= (13000,2048) #13000 samples and 2048 features each 2) dataset_2= (15000,12000) in order to speed up the computation l used from sklearn from sklearn.linear_model import…
Joseph
  • 343
  • 6
  • 18
3
votes
2 answers

Issue with when plotting `density` objects

I have an issue when trying to plot density objects. Consider for example require(grDevices) set.seed(43) d0 = density(rexp(1e5,rate=1)) d1 = density(rexp(1e5,rate=1.8)) plot(d1, col="white", xlab = "x", ylab="Density", main = "") polygon(d1,…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
3
votes
2 answers

The proper way to plot PDF of a sample of data

I know this must be pretty basic, but what is the proper, accurate way to plot the PDF of some sample data that you know comes from some pop. distribution, like if you generated it using rnorm() or rexp()? The reason I ask is because I know a lot…
Coolio2654
  • 1,589
  • 3
  • 21
  • 46
3
votes
1 answer

Exact kernel density value for any point in R

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(…
rnorouzian
  • 7,397
  • 5
  • 27
  • 72
3
votes
0 answers

Kernel Density Estimation in Spark

I have recently become familiar with both PySpark's in-house KernelDensity function as well as sklearn's KernelDensity function. I am trying to fit a Kernel Density Estimator to my data (some 14,000 data points, about 1.3 MB) so that I can draw…
jmancuso
  • 1,087
  • 8
  • 9
3
votes
0 answers

Density scale difference between stat_bin2d() and stat_density2d(), in R

I'm using R. Why do the densities between these two functions differ? I looked at the help files but ddin't see much to indicate what the reason is. I thought my log stretch might be causing the change given that my stat_bin2d density scale is very…
val
  • 1,629
  • 1
  • 30
  • 56
3
votes
1 answer

Calculate the volume under a plot of kernel bivariate density estimation

I need to calculate a measure called mutual information. First of all, I need to calculate another measure, called entropy, for example, the joint entropy of x and y: -∬p(x,y)·log p(x,y)dxdy So, to calculate p(x,y), I used the kernel density…
3
votes
1 answer

How to normalize Kernel Density Estimation using scikit?

I am using KDE for multi-class classification. I am implementing it using scikit. As mentioned on the website, the KDE for a point x is defined as, Should I normalize the result while comparing different kernel density estimates for different…
lostboy_19
  • 347
  • 3
  • 16
3
votes
1 answer

Manually setting scale_alpha for stat_density2d plot

I want to plot monthly maps of local construction specifically using stat_density2d from ggplot2. I am using the following code: library(ggmap) options(stringsAsFactors=T) mar_2016 <- structure(list(Latitude = c(47.6064785, 47.6086266,…
Stedy
  • 7,359
  • 14
  • 57
  • 77