Function Repository Resource:

# NegativeCoordinateMarginalDistribution

Represent a MarginalDistribution permitting negative numbers as indices

Contributed by: Seth J. Chandler
 ResourceFunction["NegativeCoordinateMarginalDistribution"][dist,k] represents a univariate marginal distribution of the kth coordinate from the multivariate distribution dist, where k is allowed to be a negative index. ResourceFunction["NegativeCoordinateMarginalDistribution"][dist,{k1,k2,… }] represents a multivariate marginal distribution of the {k1,k2,…} coordinates, but extending the coordinate values to permit negative indices. ResourceFunction["NegativeCoordinateMarginalDistribution"][dist] represents the last marginal distribution of the distribution dist.

## Details

ResourceFunction["NegativeCoordinateMarginalDistribution"] determines the number of coordinates by considering the length of DistributionDomain applied to the distribution.
ResourceFunction["NegativeCoordinateMarginalDistribution"] can compute anything that MarginalDistribution can compute.

## Examples

### Basic Examples (2)

Get the marginal distribution of a CategoricalDistribution for its last coordinate:

 In[1]:=
 Out[1]=

Get the marginal distribution of a symbolic multivariate normal distribution for its penultimate coordinate:

 In[2]:=
 In[3]:=
 Out[3]=

### Scope (2)

Positive and negative indices can be used together:

 In[4]:=
 Out[4]=

If no index is specified, the last index is used:

 In[5]:=
 Out[5]=

### Applications (7)

A causal graph between anxiety, peer pressure and smoking:

 In[6]:=
 Out[6]=

Determine the effect of changing the probability of peer pressure on the probability of smoking as follows. First, generate categorical distributions for peer pressure and anxiety:

 In[7]:=
 In[8]:=

Assume the two are independent and so one can find their joint distribution using the resource function MixtureCategoricalDistribution as follows:

 In[9]:=
 Out[9]=

To use a CategoricalDistribution as input to another MixtureCategoricalDistribution, it must be univariate:

 In[10]:=
 Out[10]=

Now form the distribution of smoking as a function of whether the person is anxious and subject to peer pressure:

 In[11]:=
 Out[11]=

Use NegativeCoordinateMarginalDistribution to get the probability of smoking as a function of the prevalence of peer pressure:

 In[12]:=
 Out[12]=

Plot the relationship between the prevalence of peer pressure and the probability of smoking:

 In[13]:=
 Out[13]=

### Properties and Relations (2)

NegativeCoordinateMarginalDistribution works the same as MarginalDistribution if a positive number is used for the index:

 In[14]:=
 Out[14]=
 In[15]:=
 Out[15]=

NegativeCoordinateMarginalDistribution[dist] is equivalent to NegativeCoordinateMarginalDistribution[dist,-1]:

 In[16]:=
 Out[16]=

Seth J. Chandler

## Version History

• 1.0.0 – 27 July 2021