kernel-density

Colorbar for seaborn.kdeplot

烂漫一生 提交于 2019-12-13 20:03:56
问题 I want to create a Kernel-Density-Estimation with Seaborn.kdeplot with a colorbar on the side. import matplotlib.pyplot as plt import seaborn as sns import numpy as np; np.random.seed(10) import seaborn as sns; sns.set(color_codes=True) mean, cov = [0, 2], [(1, .5), (.5, 1)] x, y = np.random.multivariate_normal(mean, cov, size=50).T sns.kdeplot(x,y,shade=True) plt.show() While the Kernel-Density-Estimation is created, I do not have a clue how to create the colorbar. I tried using plt.colorbar

KDE in python with different mu, sigma / mapping a function to an array

筅森魡賤 提交于 2019-12-13 12:11:25
问题 I have a 2-dimensional array of values that I would like to perform a Gaussian KDE on, with a catch: the points are assumed to have different variances. For that, I have a second 2-dimensional array (with the same shape) that is the variance of the Gaussian to be used for each point. In the simple example, import numpy as np data = np.array([[0.4,0.2],[0.1,0.5]]) sigma = np.array([[0.05,0.1],[0.02,0.3]]) there would be four gaussians, the first of which is centered at x=0.4 with σ=0.05. Note:

Issue pasing arguments to kernel functions through `density.ppp`

老子叫甜甜 提交于 2019-12-13 03:23:47
问题 I am currently working intensively with the density.ppp function, calling it with different kernel functions of my own design. For this, I need to pass some arguments through density.ppp to my kernel functions via the ... arglist. There is one case in which this does not work, namely if I want to calculate at = "points" with edge correction. In densitypointsengine it says # evaluate edge correction weights at points if(edge) { win <- x$window if(isgauss && is.null(varcov) && win$type ==

How can I get the value of a kernel density estimate at specific points?

£可爱£侵袭症+ 提交于 2019-12-12 07:13:13
问题 I am experimenting with ways to deal with overplotting in R, and one thing I want to try is to plot individual points but color them by the density of their neighborhood. In order to do this I would need to compute a 2D kernel density estimate at each point. However, it seems that the standard kernel density estimation functions are all grid-based. Is there a function for computing 2D kernel density estimates at specific points that I specify? I would imagine a function that takes x and y

Seaborn distplot: y axis problems with multiple kdeplots

♀尐吖头ヾ 提交于 2019-12-12 06:18:27
问题 I am currently plotting 3 kernel density estimations together on the same graph. I assume that kdeplots use relative frequency as the y value, however for some of my data the kdeplot has frequencies way above 1. code I'm using: sns.distplot(data1, kde_kws={"color": "b", "lw": 1.5, "shade": "False", "kernel": "gau", "label": "t"}, hist=False) Does anyone know how I can make sure that the kdeplot either makes y value relative frequency, or allow me to adjust the ymax axis limit automatically to

How to extract values from a 3D kernel density plot built in R using 'ks' and 'rgl'

倖福魔咒の 提交于 2019-12-11 22:53:50
问题 I've been using the 'ks' package along with the 'rgl' package to produce 3D kernel density estimates and 3D plots of these. This first part has worked out fine (brief example below). What I can't figure out is if it's possible to extract the values of the kernels for the given xyz locations used to build the kernels in the first place. In other words, extract the values for points in a 3D plot, akin to the extract command used for 2D surfaces in the 'raster' package. Does anyone have

Optimize computation time for PDF approximation based on Kernel Density Estimation

佐手、 提交于 2019-12-11 17:38:33
问题 I have a code to find the pdf's approximation of a vector based on the formula for kernel estimation: I implemented this formula in the code below (see previous question). However, that code takes long time to run (two loops are used). Could you see the below code and help me to make it faster? This is the code: function pdf_est=KDE() close all; %%Random values of 20 pixels, range=[1 256] data=randi([1 256],1,20)-1; %// changed: "-1" %% Estimate histogram%%%%% pdf_est=zeros(1,256); z=256; for

Standardising Kernel Density Plot's Width & Legend Scale

血红的双手。 提交于 2019-12-11 16:44:10
问题 I have the following 4 kernel density plots, but would like the legend scale as well as the plot width/height to be the same across all 4 for comparison. My codes are: kde_pipit_2014_bw <- density(Pipit_ppp_2016, sigma=4.18, edge=TRUE, kernel="gaussian") kde_pipit_2015_bw <- density(Pipit_ppp_2016, sigma=4.18, edge=TRUE, kernel="gaussian") kde_pipit_2016_bw <- density(Pipit_ppp_2016, sigma=4.18, edge=TRUE, kernel="gaussian") kde_pipit_2016_bw <- density(Pipit_ppp_2016, sigma=4.18, edge=TRUE,

2D (kde2d) contour plots with conditions

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 07:39:48
问题 I have 4 variables x1,x2 y1,y2 (365 values for each variable). I want to plot the 2d kernel density with specific contour levels. I need to overlay the density plots (x1 vs y1) and (x2 vs y2). x1 <- c(772.522, 1806.75, 2388.73, 2619.04, 2695.6, 2747.14, 2772.58, 2773.86, 2812.93, 3338.98, 3299.18, 3269.85, 3179.74, 3185.36, 3274.99, 3391.08, 3541.91, 3563.56, 3551.63, 3626.92, 3602.07, 3535.31, 3482.09, 3567.54, 3502.1, 3440.78, 3437.95, 3722.05, 3702.45, 3636.89, 3565.1, 3485.51, 3398.42,

Can I convert kernel density plots to raster and then overlay them using map algebra?

回眸只為那壹抹淺笑 提交于 2019-12-11 06:15:19
问题 I am currently exploring three shapefiles, each with point data, and all confined to the same window. I also have them in ppp format which I've used to create kernel density maps. plot(density.ppp(smktppp, 0.5, edge=T), main="Supermarket Density") plot(density.ppp(tptppp, 0.5, edge=T), main="Transport Density") plot(density.ppp(farmppp, 0.5, edge=T), main="Urban Farm Density") I would like to overlay these plots, using map algebra, or fuzzy logic, etc, to create one output map showing the