0
$\begingroup$

I have a plot of a DensityHistogram from a dataset collected in the lab (stored as {{x1,y1},{x2,y2},...}). The data used to construct the histogram is convolved with the impulse response of the detector in the measurement, and I want to deconvolve the data. Is there a way to extract the underlying data from DensityHistogram as a matrix/list of lists so that I can deconvolve it with ListDeconvolve?

Here is an example with a list of random numbers (I chose about 30% of the size of the dataset I am using to make everything a bit quicker). I am not doing any post-processing and the underlying structure of my data is NOT random, but I think this would be enough to generate a similar sort of plot.

data = RandomVariate[BinormalDistribution[{1000, 1000}, {100, 1000}, 0], 10000];
DensityHistogram[data, {100}, PlotRange -> All, ColorFunction -> "Rainbow"]
$\endgroup$
3
  • $\begingroup$ I am not sure what MWE stands for. $\endgroup$ – Ely Eastman Apr 18 '20 at 1:31
  • $\begingroup$ Yeah I'll do one now. $\endgroup$ – Ely Eastman Apr 18 '20 at 1:34
  • $\begingroup$ Updated question to include my example. $\endgroup$ – Ely Eastman Apr 18 '20 at 1:54
3
$\begingroup$

HistogramList[data, ...] will give you a result of the form

{
  {
    {x1, x2, ..., xM}, 
    {y1, y2, ..., yN}
  },
  {
    {c11, c12, ..., c1N},
    ...
    {cM1, cM2, ..., cMN}
  }
}

where the xi are the boundaries in the x direction, the yi are the dividers in the y direction, and the cij are the counts of elements in the corresponding bins.

$\endgroup$
3
  • 2
    $\begingroup$ (This doesn't help if you only have the plot, but I don't want people thinking this is the only way to get the counts, even when they have the original data.) $\endgroup$ – Brett Champion Apr 18 '20 at 3:21
  • $\begingroup$ How does this differ from something like BinCounts? Obviously there are more options for how you bin the data using HistogramList, and what is returned is different, but if we are considering only the counts section, what is different? $\endgroup$ – Ely Eastman Apr 18 '20 at 17:18
  • $\begingroup$ I've noticed now that BinCounts returns just the c_ij portion that HistogramList returns $\endgroup$ – Ely Eastman Apr 18 '20 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.