Distribution ...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Distribution ...

Arman Ali Anwar

I need to genrate 2D normal distributions ...

I need to specify specific means and variances ...

could someone please tell me how to do this :-)

Thanks in ADVANCE :-)

please send all responses to [hidden email]

Arman.

   **********************************************************************
  *  ***********************************************  *********************
 *  *           o                                   *  * Arman Ali Anwar   *
*   *         o o    ooooo   o    o    oo    o    o  * *  [hidden email]*
 *  *       o   o   o    o  oo  oo   o  o   oo   o    *                    *
*   *     o     o  o    o  o oo o  o    o  o o  o     * Opportunity often  *
 *  *    ooooooo  ooooo   o    o  oooooo  o  o o      * presents itself in *
*   *   o     o  o   o   o    o  o    o  o   oo      * * the form of  VERY *
 *  *  o     o  o    o  o    o  o    o  o    o      *  * HARD WORK !!      *
  *  ***********************************************  *********************
   **********************************************************************


Reply | Threaded
Open this post in threaded view
|

Re: Distribution ...

Ted.Harding
( Re Message From: Arman Ali Anwar )

>
>
> I need to genrate 2D normal distributions ...
>
> I need to specify specific means and variances ...
>
> could someone please tell me how to do this :-)
>
> Thanks in ADVANCE :-)
>
> please send all responses to [hidden email]
>
> Arman.
>
Let mx, my, vx, vy and cxy be the desired means, variances, and covariance.
Let rxy = cxy/sqrt(vx*vy) be the correlation.
Let a = sqrt( abs(rxy)/(1-abs(rxy)) )), sx = sqrt(vx), sy = sqrt(vy).

    rand('normal');
    U = rand(N,1); V = rand(N,1); W = rand(N,1);
    X = mx + (U + a*W)*sx/sqrt(1+a*a);
    Y = my + (V (+/-) a*W)*sy/sqrt(1+a*a);

                  ^
                  |
( + for positive correlation, - for negative).

That's it.

Ted.                                     ([hidden email])