kernel-density

PCL Gaussian Kernal example

限于喜欢 提交于 2019-12-24 02:04:19
问题 I need help in applying a Gaussian Kernel on my points cloud to smooth the cloud. I could not figure out how I should write the code and I could not find any plain examples. Update: I am using Point Cloud Library (pcl): pcl::io::loadPCDFile ("/home/..../2240.pcd", *raw_cloud); Eigen::VectorXf horizontal; //Set up the Gaussian Kernel pcl::GaussianKernel<pcl::PointXYZRGB> gaussianKernel; gaussianKernel.compute(5,horizontal,40); pcl::filters::Convolution<pcl::PointXYZRGB> conv; conv

ggplot2 - Modify geom_density2d to accept weights as a parameter?

痴心易碎 提交于 2019-12-23 19:14:35
问题 This is my first post to the R-community, so pardon me if it is silly. I would like to use the functions geom_density2d and stat_density2d in ggplot2 to plot kernel density estimates, but the problem is that they can't handle weighted data. From what I understand, these two functions call the function kde2d from package MASS to make the kernel density estimate. And the kde2d doesn't take data weights as a parameter. Now, I have found this altered version of kde2d http://www.inside-r.org/node

Estimate pdf of a vector using Gaussian Kernel

懵懂的女人 提交于 2019-12-23 18:59:26
问题 I am using Gaussian kernel to estimate a pdf of a data based on the equation where K(.) is Gaussian kernel, data is a given vector. z is bin from 1 to 256. size of bin is 1. I implemented by matlab code. However, the result show the amplitude of my pdf estimation (blue color) is not similar with real pdf of data. Could you see my code and give me some comment about my code? MATLAB CODE function pdf_est=KDE() close all; %%Random values of 20 pixels, range=[1 256] data=randi([1 256],1,20); %%

How to fit a curve to a histogram

痴心易碎 提交于 2019-12-23 12:46:48
问题 I've explored similar questions asked about this topic but I am having some trouble producing a nice curve on my histogram. I understand that some people may see this as a duplicate but I haven't found anything currently to help solve my problem. Although the data isn't visible here, here is some variables I am using just so you can see what they represent in the code below. Differences <- subset(Score_Differences, select = Difference, drop = T) m = mean(Differences) std = sqrt(var

Density plots with multiple groups

牧云@^-^@ 提交于 2019-12-21 17:49:48
问题 I am trying to produce something similar to densityplot() from the lattice package , using ggplot2 after using multiple imputation with the mice package. Here is a reproducible example: require(mice) dt <- nhanes impute <- mice(dt, seed = 23109) x11() densityplot(impute) Which produces: I would like to have some more control over the output (and I am also using this as a learning exercise for ggplot). So, for the bmi variable, I tried this: bar <- NULL for (i in 1:impute$m) { foo <- complete

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

孤者浪人 提交于 2019-12-21 06:05:12
问题 This question already has answers here : Find the probability density of a new data point using “density” function in R (3 answers) Density Value for each Return (3 answers) Closed 2 years ago . 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)) ) 回答1: Use linear interpolation to

Overlay density and histogram plot with ggplot2 using custom bins

扶醉桌前 提交于 2019-12-20 03:17:22
问题 So I have some data - gene expression in several samples - that I want to plot as an histogram binned in a way that makes sense, and then overlaying a density curve. Something along the lines of this plot: Plotting_distributions_(ggplot2) ggplot(df, aes(x=rating)) + geom_histogram(aes(y=..density..), # Histogram with density instead of count on y-axis binwidth=.5, colour="black", fill="white") + geom_density(alpha=.2, fill="#FF6666") # Overlay with transparent density plot but with the bins

The difference between geom_density in ggplot2 and density in base R

 ̄綄美尐妖づ 提交于 2019-12-18 08:57:26
问题 I have a data in R like the following: bag_id location_type event_ts 2 155 sorter 2012-01-02 17:06:05 3 305 arrival 2012-01-01 07:20:16 1 155 transfer 2012-01-02 15:57:54 4 692 arrival 2012-03-29 09:47:52 10 748 transfer 2012-01-08 17:26:02 11 748 sorter 2012-01-08 17:30:02 12 993 arrival 2012-01-23 08:58:54 13 1019 arrival 2012-01-09 07:17:02 14 1019 sorter 2012-01-09 07:33:15 15 1154 transfer 2012-01-12 21:07:50 where class(event_ts) is POSIXct . I wanted to find the density of bags at each

Tools to use for conditional density estimation in Python [closed]

隐身守侯 提交于 2019-12-18 07:31:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 months ago . I have a large data set that contains 3 attributes per row: A,B,C Column A: can take the values 1, 2, and 0. Column B and C: can take any values. I'd like to perform density estimation using histograms for P(A = 2 | B,C) and plot the results using python. I do not need the code to do it, I can try and figure

Integrate 2D kernel density estimate

梦想与她 提交于 2019-12-17 18:58:54
问题 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 file. data = np.loadtxt('data.dat', unpack=True) m1, m2 = data[0], data[1] xmin, xmax = min(m1), max(m1) ymin, ymax = min(m2), max(m2) # Perform a kernel density estimate (KDE) on the data x, y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np