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
13
votes
5 answers

seaborn: Selected KDE bandwidth is 0. Cannot estimate density

import pandas as pd import seaborn as sns ser_test = pd.Series([1,0,1,4,6,0,6,5,1,3,2,5,1]) sns.kdeplot(ser_test, cumulative=True) The above code generates the following CDF graph: But when the elements of the series are modified to: ser_test =…
SaadH
  • 1,158
  • 2
  • 23
  • 38
13
votes
2 answers

Python Gaussian Kernel density calculate score for new values

this is my code: import numpy as np from scipy.stats.kde import gaussian_kde from scipy.stats import norm from numpy import linspace,hstack from pylab import plot,show,hist import re import json attribute_file="path" attribute_values =…
Usi Usi
  • 2,967
  • 5
  • 38
  • 69
12
votes
2 answers

How to plot kernel density plot of dates in Pandas?

I have a pandas dataframe where each observation has a date (as a column of entries in datetime[64] format). These dates are spread over a period of about 5 years. I would like to plot a kernel-density plot of the dates of all the observations, with…
bhackinen
  • 123
  • 1
  • 5
12
votes
2 answers

kernel density score VS score_samples python scikit

I am using scikit learn and python for a few days now and more specially KernelDensity. Once the model is fitted I would like to evaluate the probability of new points. The method score() is made for this but apparently doesn't work as when I put…
Romain
  • 741
  • 4
  • 16
11
votes
2 answers

Python plotting percentile contour lines of a probability distribution

Given a probability distribution with unknown functional form (example below), I like to plot "percentile-based" contour lines, i.e.,those that correspond to regions with an integral of 10%, 20%, ..., 90% etc. ## example of an "arbitrary"…
neither-nor
  • 1,245
  • 2
  • 17
  • 30
11
votes
1 answer

Calculate how a value differs from the average of values using the Gaussian Kernel Density (Python)

I use this code to calculate a Gaussian Kernel Density on this values from random import randint x_grid=[] for i in range(1000): x_grid.append(randint(0,4)) print (x_grid) This is the code to calculate the Gaussian Kernel Density from…
Usi Usi
  • 2,967
  • 5
  • 38
  • 69
11
votes
4 answers

scipy gaussian_kde and circular data

I am using scipys gaussian_kde to get probability density of some bimodal data. However, as my data is angular (it's directions in degrees) I have a problem when values occur near the limits. The code below gives two example kde's, when the domain…
Dave
  • 1,170
  • 3
  • 20
  • 30
11
votes
3 answers

Peak of the kernel density estimation

I need to find as precisely as possible the peak of the kernel density estimation (modal value of the continuous random variable). I can find the approximate value: x<-rlnorm(100) d<-density(x) plot(d) i<-which.max(d$y) d$y[i] d$x[i] But when…
Andy
  • 263
  • 2
  • 5
  • 16
11
votes
1 answer

Getting values from kernel density estimation in R

I am trying to get density estimates for the log of stock prices in R. I know I can plot it using plot(density(x)). However, I actually want values for the function. I'm trying to implement the kernel density estimation formula. Here's what I…
Ruth O'Brien
  • 163
  • 1
  • 1
  • 9
10
votes
2 answers

Compute area under density estimation curve, i.e., probability

I have a density estimate (using density function) for my data learningTime (see figure below), and I need to find probability Pr(learningTime > c), i.e., the the area under density curve from a given number c (the red vertical line) to the end of…
Eric
  • 149
  • 1
  • 1
  • 7
10
votes
3 answers

Integrate 2D kernel density estimate

I have a x,y distribution of points for which I obtain the KDE through scipy.stats.gaussian_kde. This is my code and how the output looks (the x,y data can be obtained from here): import numpy as np from scipy import stats # Obtain data from…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
9
votes
3 answers

How can you create a KDE from histogram values only?

I have a set of values that I'd like to plot the gaussian kernel density estimation of, however there are two problems that I'm having: I only have the values of bars not the values themselves I am plotting onto a categorical axis Here's the plot…
Joe B
  • 912
  • 2
  • 15
  • 36
9
votes
1 answer

python KDE get contours and paths into specific json format leaflet-friendly

I am doing a Kernel Density Estimation in Python and getting the contours and paths as shown below. (here is my sample data: https://pastebin.com/193PUhQf). from numpy import * from math import * import numpy as np import matplotlib.pyplot as…
passion
  • 1,000
  • 6
  • 20
  • 47
9
votes
4 answers

Using scipy.stats.gaussian_kde with 2 dimensional data

I'm trying to use the scipy.stats.gaussian_kde class to smooth out some discrete data collected with latitude and longitude information, so it shows up as somewhat similar to a contour map in the end, where the high densities are the peak and low…
jet
  • 91
  • 1
  • 1
  • 2
9
votes
1 answer

What is the issue in my calculation of Multivariate Kernel Estimation?

My intention is to find its class through Bayes Classifier Algorithm. Suppose, the following training data describes heights, weights, and feet-lengths of various sexes SEX HEIGHT(feet) WEIGHT (lbs) FOOT-SIZE (inches) male 6 …
user366312
  • 16,949
  • 65
  • 235
  • 452
1
2
3
43 44