[R] Split a matrix for mixture distribution

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Feb 24 19:51:10 CET 2008



Evgenia wrote:
> Hello,
>  I have a matrix with 4000 rows and 8 columns with 1 and zeros 
> Every 1000 rows comes for a different rule, f1,f2,f3,f4.
> 
> 1 1 1 1 0 0 0 0
> 1 1 1 1 0 0 0 0 
> ....
> 0 0 0 0 1 1 1 1
> 0 0 0 0 1 1 1 1
> ...
> 1 1 0 0 1 1 0 0
> 1 1 0 0 1 1 0 0
> ...
> 0 0 1 1 0 0 1 1 
> 0 0 1 1 0 0 1 1
> 
> How can I extract 4 matrices each one containes 1000 elements from a certain
> rule,since i want to 
> a) choose between f1, f2, f3 and f4 at random according to the
>    probabilities p1, p2, p3 ,p4 (it is assumed p1+p2+p3=1).
> b) sample 1 value from whichever of f1, f2, f3 ,f4 was chosen

I guess we need some better explanations or examples - at least I do not 
understand your aims.

Uwe Ligges

> Thanks a lot
> Evgenia
>



More information about the R-help mailing list