I want to
- Generate a bivariate data set (X,Y) of m*m
- Arrange each row with respect to X
- Note the order of Y associated with X
- From the first row, pick the first element order of X, along with Y and their orders as well (Y order is random from 1,2,..m). From second row 2nd order with respect to X, along with Y and their orders...similarly from mth row m order with respect to X, along with Y and their orders.
I have done this with the following code:
m = 3;
dist = BinormalDistribution[{1, 2}, {0.5, 0.5}, 0.5];
data1 = RandomVariate[dist, {m, m}];
data2 = Table[Sort[data1[[i]], #1[[1]] < #2[[1]] &], {i, 1, m}]
data20 = Table[Table[data2[[j, i, 1]], {i, 1, m}], {j, 1, m}];
data21 = Table[Table[data2[[j, i, 2]], {i, 1, m}], {j, 1, m}];
data210 = Table[Table[RankedMin[data21[[j]], i], {i, 1, m}], {j, 1, m}]
data4 = {1, 2, 3};
data24 = Table[
Table[{data20[[j, i]], data4[[i]]}, {i, 1, m}], {j, 1, m}]
data212 =
Table[Table[{data210[[j, i]], data4[[i]]}, {i, 1, m}], {j, 1, m}]
data51 = Table[
Table[If[{data2[[1, 1, 2]]} == {data212[[j, i, 1]]},
data212[[j, i]], {}], {i, 1, m}], {j, 1, 3}] //. {} :>
Unevaluated[## &[]];
data52 = Table[
Table[If[{data2[[2, 2, 2]]} == {data212[[j, i, 1]]},
data212[[j, i]], {}], {i, 1, m}], {j, 1, 3}] //. {} :>
Unevaluated[## &[]];
data53 = Table[
Table[If[{data2[[3, 3, 2]]} == {data212[[j, i, 1]]},
data212[[j, i]], {}], {i, 1, m}], {j, 1, 3}] //. {} :>
Unevaluated[## &[]];
data61 = {{data24[[1, 1]], data51 // Flatten}, {data24[[2, 2]],
data52 // Flatten}, {data24[[3, 3]], data53 // Flatten}}
Although it is working but this is huge and quite boring, I need suggestions/solution for quick and short code. As this is only one step have to do alot with that.