Harsha Vats asked . 2022-05-23

Noise samples of gaussian mixture distribution

I'm new to matlab. I want to generate noise samples of Gaussian mixture with PDF= sqrt((u.^3)./pi).*exp(-u.*(x.^2)) + sqrt((1-u)^3/pi).*exp(-(1-u).*x.^2);
 
The length of noise sample is (1,200) Please help me out.

signal processing , noise samples , Continuous Distributions , Inverse Gaussian Distribution

Expert Answer

Prashant Kumar answered . 2024-05-17 18:28:16

Ok, so you have formulated what seems to me to be a rather strange mixture model.
 
You have two modes, with variances that are related to each other, the mean of both terms is zero.
 
So, if the PDF is:
 
PDF = sqrt((u.^3)./pi).*exp(-u.*(x.^2)) + sqrt((1-u)^3/pi).*exp(-(1-u).*x.^2)

So we have two terms there.

syms u positive
syms x real

Look at the first term:

pdf1 = sqrt((u.^3)./pi).*exp(-u.*(x.^2));
int(pdf1,x,[-inf,inf])
ans =
u

So, it integrates to u. The second term is similar,

pdf2 = sqrt(((1-u).^3)./pi).*exp(-(1-u).*(x.^2));
int(pdf2,x,[-inf,inf])
ans =
piecewise([u == 1, 0], [1 < u, Inf*1i], [u < 1, 1 - u])
For u <= 1, it integrates to 1-u.
 
So the integral of the sum is indeed 1, therefore it is a valid PDF.
 
Essentially, you have two Gaussian modes, such that the variances are 2/u and 2/(1-u) respectively. You have chosen the mixture parameter as the inverse of those variances. Effectively, when u is small (or very near 1), you have a mixture distribution that rarely, you will generate large outliers. When u is exactly 1/2, this reduces to a standard normal distribution, with a unit variance.
 
I'm not sure why, but I suppose that is not really important. Normally, one would choose a mixture parameter that is independent of the variances.
 
The solution is simple.
 
1. Pick some value for u. u determines both variances for each Gaussian mode, as well as the mixture coefficient.
2. For a sample size of N, pick N uniformly distributed random numbers. These will determine which mode you will sample from. Then just use a classical tool like randn to do the sampling.
 
For a sample size of 1e7, and some arbitrary value for u, say 1/100. I've picked a tiny value for u to make the result clear. I've also chosen a large sample to make it easier to see as a histogram.
 
 
N = 10000000;
u = 0.01;

% random mixture selection
% Here s will be 1 if the element is sampled from first pdf.
%      s will be 0 if the element is sampled from second pdf.
s = rand(1,N) < u;

% sample using randn, with a unit variance initially
x = randn(1,N);;

% now scale each element based on the desired variance
x(s) = x(s)*sqrt(2/u);
x(~s) = x(~s)*sqrt(2/(1-u));

hist(x,1000)
So, for this fairly tiny value of u, see that the histogram looks much like a traditional Gaussian, BUT with very wide tails.
I'll next plot the separate pieces of the PDF, split into two parts. Here I've chosen u as 0.25.
 
pdf1 = @(x,u) sqrt((u.^3)./pi).*exp(-u.*(x.^2));
pdf2 = @(x,u) sqrt(((1-u).^3)./pi).*exp(-(1-u));

h1 = ezplot(@(x) pdf1(x,0.25),[-10,10]);
hold on
h2 = ezplot(@(x) pdf2(x,0.25),[-10,10]);
title 'pdf1 and pdf2, split apart'
So, the sampling was rather simple. No need to do anything strenuous. I still have no idea why you want this distribution, but whatever floats your boat is a good thing.


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.