Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

Matlab-Guassian Function

Posted on 2003-04-01
Medium Priority
1,198 Views
Hello Experts,
I have a random data been generated and i would like to know any sites which explain built in functions of Matlab to read my randomly generated data (rand) for one pattern and obtain similar patterns using Guassian Function.Any Help is greatly appreciated.
Thanks
Michael
0
Question by:michael306
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

Expert Comment

ID: 8249157
In matlab, there is a function called "randn" which generated random number following Guassian distribution.

0

Expert Comment

ID: 8265038
Not sure if this will directly apply, but here is a link to the random number chapter in the Matlab text book that I learned from:

http://www.mathworks.com/moler/random.pdf

On a side note, Cleve Moler wrote this book, and taught my class. If you don't know, he is the founder of Matlab.

-Brian
0

Author Comment

ID: 8266335
Hi expert Brian,
It was great site, but i already have a randomly generated data as mentioned and would like to generate rest of the patterns by applying normal distribution to the first data and get 10 more similar patterns based on mean, std values.I hope it makes sense.
Michael
0

Expert Comment

ID: 8275532
How about if you try to compute the mean and variance of your data and take them as the parameters for the new Gaussian random numbers? Gaussian distribution are fully determined by mean and variance. If you data size is large enough, the empirical mean and variance should be quite accurate.

-tj
0

Author Comment

ID: 8280132
Hey Tj,
I could have done that, but mine is a raw data.Also its quite big.I can send you the data or can u show me some examples on how we apply guassian at each point for a given wave.
Thanks
Best Regard's
michael
0

Expert Comment

ID: 8288084
Hi, mike:
I'm not quite sure if I grasped your idea.
suppose you have a group of data saved in an array called x.
Then x is a implementation of a random process. But we can asume that x is stationary, and are composed of i.i.d random variable.
we can use mu=mean(x) in matlab to compute the mean value of x (approximately). And sigma2 = var(x) to compute the variance. Then using y = sqrt(sigma2) * randn(size(x)) + mu. We can generate a random vector, y, which has the same length, mean and variance of x. At the same time, y follows Gaussian distribution.
However, if there is some deterministic signal in x, you may have to first figure out the deterministic component in x and then substract it from x.

Is the generate y you wanted? Or you want something else?

-tj
0

Author Comment

ID: 8296615
Hello Tj,
You were very close to what i was asking.Let me make it simple for eg:
.150     .150     .250     .425     .250     .3     .6     .475     .325     .250     .225     .275     .2     .775     .775     .3
.175     .2     .275     .475     .275     .325     .625     .525     .350     .275     .175     .225     .750     .750     .325     .225
.2     .175     .325     .525     .3     .325     .650     .475     .375     .4     .225     .250     .725     .725     .250     .225
.250     .150     .350     .550     .325     .275     .6     .525     .425     .225     .175     .250     .7     .7     .225     .175

As you can see from .150 to .3 first row has 4 different classes and each class has 4 attributes or characteristics. Now we have to apply guassian at each point, that to vertically .150, .175, .2, .250 .And try to generate similar patterns.
I hope it makes sense.
Thanks
Michael

0

Expert Comment

ID: 8304677
Hi, Mike:
I looked at the data and felt that they are multiples of 0.025. So, it's more like that these data are generated using randint and multiplied by 0.025 (a function in communication toolbox) than simply rand or randn functions.
I don't think it is closely related to Guassian, because , as you know, Gaussian variable should be defined as any real number instead of just discrete integers. The possible values of Gaussian random variable are from minus infinity to positive infinity. This is also not your case.
Just FYI, you can also go to www.matlab.com and search randint to find its help file.
-tj
0

Author Comment

ID: 8308788
Hi tj,
well i did not realize that there was so much information to be checked(data) before working on problem.Any suggestions on getting guassian data for 4 different patterns.Mean while i will go thru the site.I do not have access to communication tool box too.
Regard's
michael
0

Expert Comment

ID: 8314442
Hi, mike:
Actually, you can implement randint by your own with available function, just like following way:
x = rand(1,1) % generate a number between 0 and 1.
x = x .* 10;  % suppose we want to generate random integer between 0 to 10.
x = round(x); % round x to the closet integer.

Though this way, x follows uniform distribution. If you substite rand by randn, x then follows some modified version of Gaussin distribution.
However, you can use hist command to view the histogram of your data. If they follows Guassian distribution, the shape should be quite close to a bell. However, I tried your 4 groups of data. Obviously, they are not. (You can use a randn to generate some data and compare the histograms).

-tj
0

Author Comment

ID: 8319880
Hi tj,
As you have seen the data, the idea was to have four different shapes and also to exactly know what would be those points each time i generated them.I tried as you mentioned rand it is working good but i need to capture the points indivually say y1, y2, y3..etc and plot each of y1 with y2, y1 with y3 etc which i am unable to get it thru rand.
Can you generate four different patterns on the same lines of the data above, which follows guassian distribution at each point to.
Regard's
michael
0

Accepted Solution

ID: 8322790
hi, mike:
suppose, we are now coping with row 1, the data in row1 is saved in y1. Then, we can do following:
m1 = mean(y1/0.025) % compute the mean value
v1 = var(y1/0.025)  % compute the variance
x1 = sqrt(v1) * randn(size(y1)) + m1;
% generate a random varianble x1,
% which has the same size, mean,
% and variance as y1/0.025
x1 = round(x1);     % round x1 to closest integer
x1 = x1 * 0.025;    % x1 is in the same range as y1.

you can use hist(x1) and hist(y1) to compare the distribution of the 2 random variables. Although they may have almost the same mean and variance, they may look quite different.

good luck,
-tj
0

Expert Comment

ID: 9474466
michael306:
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I donâ€™t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back toâ€¦R. Â  So â€¦
Whether youâ€™re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This videoâ€¦
Suggested Courses
Course of the Month5 days, 16 hours left to enroll