All Questions

Filter by
Sorted by
Tagged with
1 vote
5 answers
427 views

How to map the second highest value in each row of a matrix?

I have a matrix with three or more columns called mat. I would like to map the second highest value in each row of mat into its ...
3 votes
2 answers
192 views

Sort sequences by their "randomness"

Example matrix (rows always have equal lengths) ...
5 votes
1 answer
91 views

How to Find a Weighing Matrix of Size n?

Weighting matrices appear in the statistical design of experiments (Weighting Matrices and Statistical Design of Experiments. A weighting matrix is a generalization of Hadamard matrices, e.g., ...
1 vote
2 answers
142 views

How to sample from a `MultinormalDistribution` with a positive semidefinite covariance matrix?

I'm trying to sample from a Gaussian process (GP) following these tutorials: https://peterroelants.github.io/posts/gaussian-process-tutorial/#Sampling-from-prior https://stephens999.github.io/...
1 vote
1 answer
222 views

Manipulating a Haar random unitary matrix and computing probabilities

I am new to Mathematica and its many features. Here is a problem that I was trying to model. Consider a $4 \times 4$ Haar random unitary $U$. Define by $|00\rangle \langle 00|$ the following matrix: \...
2 votes
1 answer
132 views

Speed Up the Gelman-Rubin-History function

A bit of background information I have created a function to calculate the convergence of the Gelman Rubin diagnostic (useful in Bayesian analysis). The function seems to work as I want, however I ...
0 votes
0 answers
43 views

Express symbolic equation of KL Divergence between multivariate distribution succinctly in matrix form using Mathematica

I would like to express the KL Divergence between 2 multi-variate Gaussian distributions in matrix form. I am able to compute the symbolic form but it essentially gives the output fully simplified ...
1 vote
0 answers
116 views

Fixed-Effects Model in Mathematica

I need to fit a model with fixed effects (country and time) to adress the multivariate relation between a dependent variable for 22 countries over 8 years and two independents with the same dimensions....
-3 votes
1 answer
461 views

Need help to convert a Matlab script into a Mathematica script?

I would like to convert a small script but a little technical in Mathematica language. Here is the Matlab script : ...
-1 votes
1 answer
98 views

Can the WishartMatrixDistribution command be used for generating random density matrices?

I am interested in generating random members of two classes of $n \times n$ positive-definite matrices $A$ and $B$--the former symmetric in nature, the latter, Hermitian. The standard (Ginibre-matrix-...
0 votes
0 answers
29 views

Getting MatrixPropertyDistribution::sclrvctr: error from documentation example

I'm new to StackExchange, but I am having a strange error using just downloaded Mathematica 12.1.1.0 (Student version). I'm trying to use the MatrixPropertyDistribution function, but Mathematica gives ...
4 votes
2 answers
555 views

Creating a contingency table

I need help in creating a function for a contingency table... I imagined to create it like this... ...
3 votes
0 answers
154 views

What's the usefulness of SymmetricMatrixQ and PositiveDefiniteQ if they fail with this matrix?

Let's define ...
2 votes
1 answer
406 views

Can't define average for my matrix

I have a list defined as MarsDisk which, in MatrixForm, has 17 rows and 3 columns, which hold information about a photon energy ...
12 votes
1 answer
601 views

How can I reproduce the result of PrincipalComponents

...
2 votes
1 answer
155 views

Compute the potential of confusion between two matrices

I have a problem. Any help will be appreciated. In order to calculate the accuracy, sensitivity, sensibility and F1 score between diseases and their symptoms, I have two matrices with a different ...
2 votes
0 answers
326 views

Noise covariance matrix

I am trying to find the noise covariance matrix of a random vector $\mathbf{x}$ with itself. The elements of this vector represent image pixels and are treated as random variables i.e, $\mathbf{x}=\{...
2 votes
0 answers
51 views

Matrix of deviate scores

I am trying to replicate some steps in Jonathon D. Brown's text "Linear Models in Matrix Form: A Hands-On Approach for the Behavioral Sciences" Brown, 2014, p.12. I am creating a "matrix of deviate ...
2 votes
4 answers
734 views

How to generate a matrix with certain conditions

I want to generate a $n \times n$ matrix. I want the diagonal entries to be all 0 I want a random choice of matrix elements with 0 or 1. The probability of having a 1 as a matrix element is $1/m$ and ...
1 vote
1 answer
99 views

Computing the PDF of a WishartMatrixDistribution. Is this a limitation in the PDF Mathematica function?

I'm trying to compute the pdf of a wishart distribution. Why does PDF[WishartMatrixDistribution[10, IdentityMatrix[4]], 2*IdentityMatrix[4]] not return a ...
1 vote
0 answers
270 views

how to derive a conditional covariance matrix (symbolically)

I have searched the database of the questions asked in this forum but to my surprise I could not find any satisfactory answer to my relatively simple question. Given a vector of random variables <...
1 vote
2 answers
235 views

Calculating the probability of hitting, Fisher linear discriminant

I have 4 data matrix, which are described two parameters. (M1, M2, M3, M4). So I made transition from base parameters to principal components and displayed them in ...
0 votes
1 answer
48 views

How to write a command that produces such a matrix that takes n as an argument, where every node has probability 1/m [closed]

Please help in answering the questions above on mathematica. Which commands do I use to answer the question?
9 votes
3 answers
17k views

How to use a 3×3 covariance matrix to plot an error ellipsoid?

I have a 3×3 error covariance in Mathematica, but I don't know how to use it for plotting the error ellipsoid. It would be great if you can show me how I can do that for the below covariance matrix: <...
2 votes
3 answers
123 views

Find rank of the row nearest to random variable

I have following code dist[a_, b_] = WeibullDistribution[a, b]; data = Table[ j = Table[i = RandomVariate[dist[2, 1], {3, 3}], {i, 1, 4}], {j, 1, 3}] above ...
4 votes
2 answers
189 views

Sample matrix indices in proportion to the matrix element values

I have a 4 by 4 array which has a probability associated with each point. {{0., 0., 0., 0.9}, {0., 0.05, 0., 0.}, {0., 0., 0., 0.}, {0., 0., 0.05, 0.}} I ...
3 votes
2 answers
285 views

Is this a Symmetric Matrix or not?

I've generated the cov matrix in the following way: ...
13 votes
1 answer
4k views

How to interpret the results of PCA

There is a larger matrix (1500 rows x 40 columns), 1500 observations x 40 variables. then I follow the procedures of PCA(Principal components analysis), 1. find correlation 2. find eigenvalues 3. ...
0 votes
2 answers
192 views

Rewriting a given multivariate PDF so that it has the form of multivariate normal

Say, we are given a probability distribution function that we suspect is a multivariate normal. In Mathematica, how can we rewrite such PDF to get its covariance matrix and vector of means? For ...
1 vote
0 answers
108 views

Construct a univariate function pertaining to the space of $2 \times 2$ real matrices [closed]

Consider the space of uniformly distributed $2 \times 2$ real matrices \begin{equation} \left( \begin{array}{cc} a & b \\ c & d \\ \end{array} \right), \end{equation} with the restriction ...
3 votes
1 answer
613 views

Generate a simulated covariance matrix

I am working on a problem where one of the input variables is the level of covariance between the entries in a particular matrix. To simulate this problem in Mathematica, I will need to feed my code ...
1 vote
2 answers
636 views

Generic Matrices

A multivariate Gaussian distribution for $k$ dimensions looks like this: $$\frac{1}{\sqrt{(2\pi)^k|\mathbf \Sigma|}}\mathbf e^{ -\frac 1 2 \mathbf x^T \mathbf \Sigma^{-1}\mathbf x }$$ $\mathbf x$ ...
3 votes
2 answers
280 views

How to form binary matrix with constants and given probability?

I want to create a binary matrix of 6x3 in which six elements (m13,m23, m33, m42, m52, m61) are constant and assigned '0' value; whereas for other twelve elements (m11, m12, m21, m22, m31,m32, m41, ...
5 votes
2 answers
2k views

Total Variation Distance of probability matrix

How can I calculate the Total Variation Distance of a transition Matrix? is there any built in function? I've searched all documentation and haven;t found anything. ** More information: Let me try ...
4 votes
1 answer
929 views

What is the Mathematica equivalent for corr2?

What is the Mathematica equivalent for MATLAB's corr2, which gives the correlation coefficient of two 2D matrices?
1 vote
0 answers
126 views

Sampling from an one-dimensional Wishart [closed]

I searched for a similar question but could not find one. My problem is sampling from an one-dimensional Wishart distribution. The Mathematica specification is ...
4 votes
1 answer
578 views

Calculate the covariance of a large matrix

I have to compute the covariance of 50 very large integer matrices (2500x2000 elements). However, according to my estimation this will take around 10 days. Do you have any ideas how to speed things up?...
2 votes
2 answers
417 views

Measures of association, Concordant and Discordant

I want to calculate concordant and discordant pairs on nx2 tables. ...
2 votes
1 answer
166 views

Extracting Imported Information

What I want to do is to compare the relationship between the consumption of say beer and wine using scatter plots where each point designates the particular country (preferably named). I have tried to ...
0 votes
1 answer
215 views

Discrete 3D plots of median ratios of two 2D matrices of lists of values

Lets say I have 2 2D arrays where each cell contains a list of values: Example: ...
3 votes
0 answers
293 views

Mathematica Complains about Non Symmetric Covariance matrix, when it's not the case

I was doing some fitting with Mathematica7 using NonlinearModelFit. It's quite long the program to do the fit and that's why I am not displaying here ... It goes ok, and I can get the fit parameters ...
4 votes
1 answer
3k views

stationary distribution of a transition matrix

How can I solve the stationary distribution of a finite Markov Chain? In other words, how can I estimate the eigenvectors of a transition matrix?