# Trivariate Distribution 3D Interactive Calculator

## Instructions

• Requirements - modern web-browser with HTML and JavaScript support
• See the SOCR Bivariate Normal Distribution Activity
• Click the Graph Settings button to open an overlay window for controlling the distribution parameters.
• You can control the distribution graphs clicking and dragging on the graph, zooming in and out, as well as taking a picture
• Probability Results are reported in the Probability section
• For the Joint Trivariate Distribution PDF graph the probability P is reflected in the shade of the point. The redder the point the closer the probability is to its maximum value of 0
• For the Joint Trivariate Distribution CDF graph the probability P is reflected in the shade of the point. The redder the point the closer the probability is to 1.
• Note: due to the limitations of Plotly, only 0 of 0 points could be shown. All cropped points have a probability of less than 0
• Note: sometimes the points may be too faint to see, even if they are rendered
• In the event of Plotly crashing the page needs to be hard-reloaded. Press CTRL+F5 do do this on Windows, or Command+Shift+R while on a Mac
• This graphical bivariate Normal probability calculator shows visually the correspondence between the graphical area representation and the numeric (PDF/CDF) results. However, the reported probabilities are approximate (accuracy 10-3 for Results section and the 2D graph, 10-2 for 3D bivariate plot) due to the finite viewing window of the infinitely supported Normal distribution, and the limited numerical precision of the inputs (domain) and outputs (range). Users that require high-precision calculations are encouraged to use the SOCR high-precision numerical probability calculators
• Also see the first verison and the second verison of the bivariate Normal (BVN) Distribution Calculator.

## Methodology

The Joint Trivariate Distribution is formed by using the Gaussian copula that combines the X and Y distributions. The steps taken by the calculator are outlined below:

• All continuous distribution are discretized, turning into discrete arrays with 100 points
• Intermediate variables "a", "b" and "c" are calculated using the individual cumulative distributions and the inverse error function (erf-1) using the following formula:
• $a(x) = \sqrt 2 * {erf}^{-1} \{F_x (x)\} \;;\; b(y) = \sqrt 2 * {erf}^{-1} \{F_y (y)\} \;;\; c(z) = \sqrt 2 * {erf}^{-1} \{F_z (z)\}$
• Using the values for "a", "b" and "c", the Joint Bivariate PDF "b" for each variable pair is calculated using the following formula:
• $b(x,y) = f_x(x)*f_y(y)* \frac{1}{\sqrt{1-\rho^2}} * \exp {\{- \frac {\rho^2 (a^2+b^2) - 2 \rho a b} {2*(1-\rho^2)}\}}$
• The Joint Bivariate CDF for each variable pair is calculated from the corresponding Bivariate PDF by integration.
• Also using the values for "a", "b" and "c", the Joint Trivariate PDF is calculated using the following formula:
• $TVN(x,y,z) = f_x(x)*f_y(y)*f_z(z)*\frac{1}{\sqrt{1-\rho_{xy}^2-\rho_{xz}^2-\rho_{yz}^2+2\rho_{xy}\rho_{xz}\rho_{yz}}} * \exp {\{- \frac{2\rho_{xy}\rho_{xz}\rho_{yz}(a^2+b^2+c^2)-a^2(\rho_{xy}^2+\rho_{xz}^2)-b^2(\rho_{xy}^2+\rho_{yz}^2)-c^2(\rho_{xz}^2+\rho_{yz}^2) + 2(ab(\rho_{xy}-\rho_{xz}\rho_{yz})+ac(\rho_{xz}-\rho_{xy}\rho_{yz})+bc(\rho_{yz}-\rho_{xy}\rho_{xz}))}{2(\rho_{xy}^2+\rho_{xz}^2+\rho_{yz}^2-2\rho_{xy}\rho_{xz}\rho_{yz}-1)} \}}$
• The Gaussian copula equations were taken from here
• The Joint Trvariate PDF is calculated using the following formula found here
• The Joint Trivariate CDF for each variable pair is calculated from the trivariate PDF by integration

## Calculator Rules

• This calculator has been tested for accuracy and the following results were obtained:
• Marginal Distributions: accurate to within 0.001. Main error contributing factor: discretization of continuous functions
• Conditional Distributions: accurate to within 0.001. Main error contributing factor: copula calculations
• Joint Distributions (P(X ∩ Y ∩ Z)): accurate to within 0.001. Main error contributing factor: copula calculations
• The calculator has certain limitations on the variables and min/max values, so if those limitats are exceeded then calculator will restore the incorrect values to default
• Each distribution's limits are described under the Rules section in the Graph Settings tab
• The calculator supports up to 4 different variables for all distributions X, Y and Z. Some of those variables are not used for every distribution, so an "N/A" will appear instead of an entry field. For example, the normal distribution only needs 2 variables to be entered, so the other two will be N/A for entry

## Instructions

• Use the Distribution type section to select what distributions you would like to be displayed
• Use the Variable Settings section to input the distribution parameters and correlation coefficient
• Use the Control section to input appropriate bivariate limits for X, Y and Z variables
• Use the Graph Settings sections to indicate what type of Marginal Distribution and Joint Bivariate Distribution to view. You can select to view either the Marginal functions of each variable, the Conditional distributions at the limits of variables, or the CDF functions for the Marginal Distribution graph, while the PDF, conditional PDF and the CDF are available for the Joint Bivariate Distribution plot.
• Please note that the "Trivariate Isosurface PDF" may take a long time to generate!
• Once done, click the X button to close the Graph Settings Section. The graph may take a few seconds to update.

## Rules

• Normal Distribution: mean can take any value, but the standard deviation must be greater than 0
• Poisson Distribution limits: the value of lambda must be a non-negative number. Also, the X or Y limits must also be non-negative
• Gamma Distribution: both the shape (k) and the scale (θ) values must be greater than 0. Also, the X or Y limits must also be non-negative
• Chi-Square Distribution: the number of degrees of freedom must be a natural number. Also, the X or Y limits must also be non-negative
• Student's t-distribution: the number of degrees of freedom must be a positive number
• F-distribution: the values for the degrees of freedom D1 and D2 must be positive integers. Also, the X or Y limits must also be non-negative
• Beta Distribution: the values for α and β must be positive numbers. Also, the limits must be within the 0 to 1 range
• Weibull Distribution: the values for the shape (k) and scale (λ) must be greater than 0. Also, the X or Y limits must also be non-negative
• Pareto distribution: the values for the shape (α) and scale (Xm or Ym or Zm) must be greater than 0. Also, the X or Y limits must also be non-negative
• Logistic distribution: while the value for the location (μ) may be any real number, the value for s must be greater than 0
• Log-normal distribution: μ must be a non-negative value and σ must be breater than 0. Also, the X or Y limits must also be non-negative
• Gumbel distribution: while the value for the location (μ) may be any real number, the value for scale (β) must be greater than 0
• Uniform distribution: while the values for both a and b can be any real number, b must be greater than a. Also, the limits for X or Y must be no less than a-2 and no greater than b+2
• Birthday distribution: the value for days and sample must be a positive integer. Also, The limits for X or Y must be non-negative
• U-Quadratic distribution: while the values for a and b can be any real number, b must be greater than a
• Arcsine distribution: the X or Y limits must be between 0 and 1
• Semicircle distribution: the value for the radius (R) must be greater than 0
• Max Distance Walked distribution: the value for N must be a positive integer. Also, the X or Y limits must be non-negative
• Final Position on a Walk distribution: the value for N must be a positive integer. Also, the X or Y limits must be non-negative
• Cauchy distribution: the value for scale (γ) must be a positive number. Also, the X or Y limits must be non-negative
• Hyperbolic Secant distribution: while the value for the location may be any real number, the value for scale must be greater than 0
• Irwin-Hall distribution: the value for N must be a positive integer. Also, the X or Y limits must be non-negative
• Laplace distribution: while the value for the location (μ) may be any real number, the value for scale (b) must be greater than 0
• Benford-Mantissa distribution: the value for b must be greater than 2. Also, the X or Y limits must be non-negative
• Exponential-Logarithmic distribution: the value for p must be greater than 0 but less than 1, while the value for β must be greater than 0. Also, the X or Y limits must be non-negative
• Beta Prime distribution: the values for α and β must be positive numbers. Also, the X or Y limits must be non-negative
• Zeta distribution: the value for s must be an integer greater than 1. Also, the X or Y limits must be non-negative
• Log Logistic distribution: the values for α and β must be positive numbers. Also, the X or Y limits must be non-negative
• Maxwell–Boltzmann distribution: the value for a must be greater than 0. Also, the X or Y limits must be non-negative
• Logarithmic distribution: the value for p must be greater than 0 but less than 1. Also, the X or Y limits must be non-negative
• Binomial distribution: the value for Prob must be greater than 0 but less than 1, while the value for N must be a positive integer. Also, the X or Y limits must be non-negative
• Negative Binomial distribution: the value for Prob must be greater than 0 but less than 1, while the value for K must be a positive integer. Also, the X or Y limits must be non-negative
• Hypergeometric distribution: the value for N (population size) must be a positive integer, while the values for k and n must be positive integers no greater than N. Also, the X or Y limits must be non-negative
• Polya: the value for r (number of successes) must be a positive integer, while the values for p must be between 0 and 1. Also, the X or Y limits must be non-negative
• Finite Order distribution: the value for m (population size) must be a positive integer, the value for n must be a positive integer no greater than m, and the value for k must be a positive integer no greater than n. Also, the X or Y limits must be non-negative
• Matching Hats distribution: the value for the number of hats must be a positive integer. Also, the X or Y limits must be non-negative
• Triangular distribution: while all of the parameters can be any real number, Right must be greater than Left, while Middle must be in between Left and Right.
• Coupon Collector distribution: both m and k must be positive integers, but k must be no greater than m. Also, the X or Y limits must be non-negative
• Benford's Digit distribution: the value for b must be greater than 1. Also, the X or Y limits must be non-negative
• Beta Binomial distribution: the value for n must be a positive integer, while a and b must be positive real numbers. Also, the X or Y limits must be non-negative
• Beta Negative Binomial distribution: the value for k must be a positive integer, the value for a must be greater than 2 while b must be a positive real number. Also, the X or Y limits must be non-negative and greater than k

Distribution X
Distribution Y
Distribution Z

## Variable Settings

ρXY = ρXZ = ρYZ =
μX = μY = μZ =
σX = σY = σZ =
N/A N/A N/A
N/A N/A N/A

< X <
< Y <
< Z <

## Marginal Distribution Settings

Marginal of X Marginal of Y Marginal of Z
Bivariate Conditional of
Trivariate Conditional of
CDF of X CDF of Y CDF of Z

## Joint Bivariate Distribution

Bivariate XY PDF Bivariate XZ PDF Bivariate YZ PDF
Bivariate XY CDF Bivariate XZ CDF Bivariate YZ CDF
Trivariate Conditional of

## Joint Trivariate Distribution

Trivariate Point Cloud PDF Trivariate Isosurface PDF Trivariate CDF

• This generates a text file with 3 Marginal Distribution PDFs (X, Y and Z), 3 Bivaiate PDFs (XY, YZ and XZ) and the Trivariate PDF.
• No conditional distributions are downloaded. The text file will have the settings used at the top of the file.
• Note: This text file is very large and may take a while to download.

### Generate Settings

• This generates a URL in the textarea below that can be pasted to the address bar to load the page with custom settings
• The text string consists of the following: (xdistType ? rhoxy ? parameter1X ? parameter2X ? parameter3X ? parameter4X ? xmin ? xmax) repeated for each distribution
• Please note: a URL string that does not produce valid settings will be ignored and the page will load with standard normal distributions

### Copy Settings

• This copies the entire URL to clipboard
• This can also be done by manually copying from the textarea

## Version History

### 1.4.1

• Various bug fixes

### 1.4

• Increased the number of shells generated to 25
• Finalized the enlarged graph sizes and linked them to window width and height

### 1.3.1

• Renamed "Trivariate PDF" into "Trivariate Point Cloud PDF"
• Renamed "Trivariate PDF Cloud" into "Trivariate Isosurface PDF"

### 1.3

• Added "Trivariate PDF Cloud" which displays an ellipsoid cloud of probabilities instead of individual points
• Added Enlarge functionality to the graphs

### 1.2

• Added Copy Settings to automatically copy the URL to clipboard
• Converted all formulas to TeX format