# Why is WeightedData slow?

I have been using WeightedData with Histogram, HistogramList, DensityHistogram, HistogramDistribution and SmoothKernelDistribution, with 1D and 2D data, and have noticed that those functions are much slower when the same data is represented with WeightedData instead of an unweighted data list.

This can be seen here:

d=RandomVariate[NormalDistribution[0,1],10^5];
w=ConstantArray[1,Length[d]];
wd=WeightedData[d,w];
HistogramList[d,{.1}]//Timing//First
HistogramList[wd,{.1}]//Timing//First


The unweighted histogram takes 0.05s and the weighted one takes 3.4s.

What makes these functions be slower with WeightedData?

• Wow, that's bad performance. This is a question for support! I can hardly imagine any good reason for this. Nov 4 '21 at 10:38
• Yeah. Most of my use has been with SmoothKernelDistribution, and it would take about 20 minutes for a 2D dataset of about 20000 weighted entries. I was blaming already SmoothKernelDistribution for being so slow. It never crossed my mind that the weighted data wouldn't be faster than the plain full dataset. Nov 4 '21 at 10:46
• I sent Wolfram a report about the issue. I'll post here any update. Nov 9 '21 at 10:16