If I have a 1D sequence of complex numbers with real and imaginary parts, how can I compute the histogram of this sequence? Do I separately compute the histogram of both the real and imaginary parts?

Moreover, if I get a 2D histogram of a sequence of complex numbers, how do I apply goodness of fit tests (such as the $chi^2$ test) to compare two histograms of complex numbers?

Is there a good reference book on the computation of histograms of complex numbers?

How would such a histogram of complex numbers be visually represented?

**Contents**hide

#### Best Answer

If I have a 1D sequence of complex numbers with real and imaginary parts, how can I compute the histogram of this sequence? Do I separately compute the histogram of both the real and imaginary parts?

A complex number is just an ordered pair of real numbers (i.e., a two-element vector of real numbers) with extended definitions of arithmetic operators like addition, multiplication, etc. Visualisation of a data set of complex numbers can be done just like any other data-set consisting of bivariate vectors of real numbers. It is important to treat the values as bivariate values, to retain any statistical relationships between the parts, so it is not generally a good idea to construct separate histograms of the real and imaginary parts.

The best way to visualise a vector of complex numbers is to generate the kernel density estimator (KDE) of this data and then visualise this using either a surface plot, a contour plot, or a heat plot, taken over the two-dimensions of the complex numbers. (A histogram is just a clunky version of a KDE; you are better off using a KDE with a smooth kernel that does not depend on arbitrary bin choices.) If you use a contour plot or heat plot you can easily superimpose a scatterplot of the data values, which allows you to see the raw data, plus the estimated density of that data. This is what I would recommend.

Here is an example of what this looks like when implemented in `R`

. In this code we generate some random complex data, and plot a scatterplot of the data with contours from the KDE using the `ggalt`

package. This gives a clear visualisation of the raw data, plus giving an outline of the contours of its estimated density.

`#Generate random vector X consisting of n complex values set.seed(1) n <- 100; ARG <- 2*pi*runif(n); MOD <- rgamma(n, shape = 2, scale = 10) + rgamma(n, shape = 5, scale = 12); X <- complex(modulus = MOD, argument = ARG); #Generate scatterplot with KDE contours library(ggplot2); library(ggalt); DATA <- data.frame(Real = Re(X), Imaginary = Im(X)); THEME <- theme(plot.title = element_text(hjust = 0.5, size = 14, face = 'bold'), plot.subtitle = element_text(hjust = 0.5, face = 'bold'), axis.title.x = element_text(hjust = 0.5, face = 'bold'), axis.title.y = element_text(hjust = 0.5, face = 'bold')); ggplot(DATA, aes(x = Real, y = Imaginary)) + THEME + geom_point(size = 4, alpha = 0.4) + geom_bkde2d(bandwidth = c(20, 20)) + ggtitle('Scatterplot of complex data values with kernel density contours'); `

### Similar Posts:

- Solved – Are real and imaginary components of frequency element of fft correlated
- Solved – Calculating 2D Confidence Regions from MCMC Samples
- Solved – Calculating 2D Confidence Regions from MCMC Samples
- Solved – what means to be outside unit circle
- Solved – How to create a QQ plot compared to a function I define