Skip to content

GaoRy-127/wgauss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

wgauss

Making Normal Gauss Random variable

Problem of using "randn" on matlab

If you use randn to making normal random variable, that will be only half success.
Because randn can't create a matrix with a mean of exact 0 and a standard deviation of exact 1.
Also, it is inconvenient to make variable that has mean and deviation that we want.


Basic Idea

To solve the problems above, We can simply transform variable that made by randn.


Discription

  • First

    Get Matrix A and b.

         function x=wgauss(mx, vx, nx)
    

    Making function.
    mx is 'Average (mean value)' that you want to get.
    vx is 'Variance' that you want.
    nx is 'Number of Variable'.

  • Second

    Transform variable that made by randn.

         x=sqrt(vx).*((k-km)/sqrt(kv))+mx; 
    
  • Third

    Then you can get variable set that has exact value of mean and deviation we want.



Others..

  • I uploaded only function m-file. So, you should write your own script m-file.
  • I am hoping that my code can help other undergraduate students' assignments.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages