5
$\begingroup$

I have implemented a constraint-based random number generator producing 3 columns with the constraint that each row sums to 1:

0.4 0.3 0.3
0.5 0.2 0.3
0.5 0.3 0.2
0.6 0.1 0.3
0.6 0.3 0.1
0.8 0.1 0.1
0.6 0.2 0.2
0.3 0.4 0.3
0.2 0.5 0.3
0.3 0.5 0.2
0.1 0.6 0.3
0.3 0.6 0.1
0.1 0.8 0.1
0.2 0.6 0.2
0.3 0.3 0.4
0.2 0.3 0.5
0.3 0.2 0.5
0.1 0.3 0.6
0.3 0.1 0.6
0.1 0.1 0.8
0.2 0.2 0.6

I would like to test whether these three columns $X$, $Y$, and $Z$ are exchangeable: that is, are the multivariate distributions of $(X,Y,Z)$ and all its permutations, such as $(Y,X,Z)$ and $(Z,X,Y)$, the same?

E.g., if column 1 can be $0.4$ followed by a $0.3$ in column 2 and $0.3$ in column 3, then is there also an equal chance for column 2 to be $0.4$ and columns 1 and 2 to be $0.3$?

$\endgroup$
  • $\begingroup$ I just can't understand what this question is asking. I think it should be on hold pending clarification by the OP. $\endgroup$ – Dilip Sarwate Feb 20 '14 at 17:21
  • $\begingroup$ @Dilip There may be a language problem here, so let's see what we can do to understand the question. Based on this post and a previous one by the OP, I take this question to be asking how to test whether three univariate datasets are random samples from a common distribution. We may surmise from the examples that the data are discrete; they appear to take on only the values $1/10, 2/10, \ldots, 9/10.$ Another interpretation is it asks how to test whether the three columns are exchangeable. $\endgroup$ – whuber Feb 20 '14 at 17:36
  • 1
    $\begingroup$ @DilipSarwate I have change the question hope its clear. In short I need to proof each column have same probability in terms of the numbers allocation and combination with other column $\endgroup$ – biz14 Feb 20 '14 at 17:37
  • $\begingroup$ @Whuber thank you yes you getting me there just that I need to proof that all 3 column have same probability any idea how to conduct that statistically ? $\endgroup$ – biz14 Feb 20 '14 at 17:38
  • $\begingroup$ Please let us know if my edits might have changed your question. $\endgroup$ – whuber Feb 20 '14 at 17:45
5
$\begingroup$

Not a complete answer, but here are two quick checks. Both need to be fullfilled in order to have the columns exchangeable. That is, if you see that there are differences then the 3 columns cannot be exchanged:

First check is of course whether the 3 columns have the same univariate distributions.

Second check: Generate enough samples and produce a ternary histogram, i.e. count how often each combination of numbers appears and plot that e.g. color coded into a ternary diagram. If the diagram isn't symmetric with respect to the 3 columns (3-fold rotation $C_3$ around 0.5,0.5,0.5 and also 3 $\sigma$ mirror-symmetry) then the distributions cannot be the same.

Here are two examples:

This one has obviously not the same distribution for each colunm:

unqual dist

Whereas this one has:

equal dist

Note: I produced the second set of random numbers by shuffling the rows within each column of the first version of random numbers.


Here's the R code:

require ("plyr")
require ("ggtern")

## make up some data
df <- data.frame (x = rnorm (5000, mean=.4, sd = .3)^2,
                  y = rnorm (5000, mean=.4, sd = .3)^2)

df <- round (df*10) / 10
df$z <- 1 - rowSums (df)
df <- df [df$z >= 0,]

## first quick check
summary (df) 

## 3d histogram
hist3d <- ddply(df,.(x,y,z),nrow)
ggtern (hist3d, aes (x = x, y = y, z = z, col = V1)) + 
   geom_point (size = 10) + 
   scale_color_gradientn (colours = c (low = "darkred", mid = "red", high = "yellow"))

## shuffling within each row (could be done faster by matrix indexing)
df <- t (apply (df, 1, sample))
df <- as.data.frame (df)
colnames (df) <- c ("x", "y", "z")
$\endgroup$
  • $\begingroup$ sorry I am very new to this any tool to conduct this test? Infact in my case I think if I can just proof that each column have the the same possibility e.g column 1 can be 0.4 followed by a 0.3 in column 2 and 0.3 in column 3, then is there also an equal chance for column 2 to be 0.4 and columns 1 and 2 to be 0.3 this will be good enough for me. $\endgroup$ – biz14 Feb 21 '14 at 1:16
  • $\begingroup$ @biz14: I added the R code I used $\endgroup$ – cbeleites supports Monica Feb 21 '14 at 12:48
  • $\begingroup$ under what software is this run and can I just copy the second diagram? What is the theory behind is it purely just ? So this produce using my purely ? What does the legend represent not so clear. Sorry I am very new to this ? $\endgroup$ – biz14 Feb 22 '14 at 1:43
  • $\begingroup$ @biz14: Software is R see r-project.org. The colors/legend are counts: how many times did the row in question occur. Sorry: I don't understand what you mean with "purely" and "purely just". $\endgroup$ – cbeleites supports Monica Feb 22 '14 at 11:46
  • $\begingroup$ @biz14: As to copying the diagram: As SO content it is licensed under the Creative Commons Attribution Share Alike license (CC-BY-SA) . This means you can copy it, adapt it to your needs, but you must attribute the source here (I can send details so you can cite me by my full name). In addition, if you release/publish the result, it must be under the same (CC-BY-SA) license. $\endgroup$ – cbeleites supports Monica Feb 22 '14 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.