Visualizing the Generated Samples Helps

It is a universal truth that visuals better appeal to the human mind than a group of numbers listed out. With visuals, it is easier for us to discern patterns and identify any flaws in the logic behind our mathematical calculations and equations. To visualize the different Discrete Distribution and True Measure Objects, the QMCPy Plot Projections function has been developed. This blog presents the different applications of this function.

What does the Plot Projections Function Do?

A Discrete Distribution or True Measure object with \( d \geq 2 \) dimensions has a maximum of \( d\times(d -1) \) dimensional pairings (for e.g: [2,3] and [3,2] are being considered separate parings). The Plot Projections function (referred to as plot_proj) plots all or a subset of all the possible dimension pairings based on user argument. This function either takes a Discrete Distribution or True Measure Object at a time. It can also display extensibility by passing in a list of successfully larger samples (for e.g: [\(2^{6}\),\(2^{7}\),\(2^{8}\)]).

To display extensibility, plot_proj function uses the default prop_cycle, which is obtained from the rc parameters of Matplotlib. This default prop_cycle contains a list of colors through which the plot_proj function iterates over and displays extensibility. The list of colors is : blue, orange, green, red, purple, brown, pink, grey, yellow, cyan. The colors are stored in this order but in a hexadecimal format.

The parameters and plot examples of this function can be seen in the Plot Projections Notebook.

Setting up the QMCPy environment before utilizing the Plot Projections Function:

import qmcpy as qp

The Different Applications of the Plot Projection Function:

  1. Here we show a two dimensional projection of an IID Object:

    d = 2
    iid = qp.IIDStdUniform(d)
    fig,ax = qp.plot_proj(iid, n = 2**7)
        
    • Figure 1: Uniform IID Object Projection
      IID
  2. Here we show a two dimensional projection of a Gaussian Object and how the axes returned by the plot_proj function can be manipulated by adding a horizontal and vertical line to denote the x and y axis respectively:

    d = 2
    iid = qp.IIDStdUniform(d)
    iid_gaussian = qp.Gaussian(iid,mean =[2,4],covariance=[[9,4],[4,5]])
    fig,ax = qp.plot_proj(iid_gaussian, n = 2**7)
    ax[0,0].axvline(x=0,color= 'k',alpha=.25); #adding vertical line
    ax[0,0].axhline(y=0,color= 'k',alpha=.25); #adding horizontal line
        
    • Figure 2: Gaussian IID Object Projection
      IID Gaussian
  3. Here we show certain specified dimensional projections (dimensions 1 and 2 on the x axes, dimensions 3 and 4 on the y axes) of a Uniform Object with successively increasing numbers of points. The initial points are in blue. The next additional points are in orange. The final additional points are in green:

    d = 4
    halton = qp.Halton(d)
    halton_uniform = qp.Uniform(halton,lower_bound=[1,2,3,4],
    upper_bound=[5,7,9,11])
    fig, ax = qp.plot_proj(halton_uniform, n = [2**6, 2**7, 2**8], 
    d_horizontal = [1,2], d_vertical = [3,4])
        
    • Figure 3: Halton Object Projection
      Halton
  4. Here we show a four dimensional projection of a Halton Object with successively increasing numbers of points. The initial points are in blue. The next additional points are in orange. The final additional points are in green:

    d = 4
    halton = qp.Halton(d)
    fig,ax = qp.plot_proj(halton, n = [2**5, 2**6, 2**7], 
    d_horizontal = range(d), d_vertical = range(d), 
    math_ind = False, marker_size = 15)
        
    • Figure 4: Halton Object Projection (More Points)
      Halton More

How this function benefits us:

In addition to making it easy to see the difference between different Discrete Distribution and True Measure Objects, this function consists of many features that makes it user-friendly and help generate a strong and precise visualization of the different Discrete Distribution and True Measure Object. For instance, the extensibility feature enables us to see how the space of the plot fills up, the marker_size parameter helps make the samples/points bigger when plotting high-dimensional projections, and the math_ind parameter allows the user to either input mathematical or python dimensions for the sampler based on one’s preference. This function could also be developed in the future to support other distributions such as Brownian Motion.

Aadit Jain
+ posts

Aadit Jain is a freshman at the University of California San Diego pursuing his B.S. in Electrical Engineering. He is really passionate about math and statistics and hopes to connect this passion with Electrical Engineering.

Published by Aadit Jain

Aadit Jain is a freshman at the University of California San Diego pursuing his B.S. in Electrical Engineering. He is really passionate about math and statistics and hopes to connect this passion with Electrical Engineering.

Leave a Reply

Discover more from QMCPy

Subscribe now to keep reading and get access to the full archive.

Continue reading