Quantification of cepstral coefficients for speech coder [closed] - matlab

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have been working on Homomorphic speech coder I have obtained the cepstral coefficients of the signal and the next step I have been asked to perform is quantize the coefficients using adaptive quantizer. I am not sure how to quantize the coefficients as its value ranges from -1.5 to 1.5, if i quantise it I just get 0 and 1 which i'm sure is wrong. What is the right way to quantise it.

I think when you are being asked to quantize the coefficients, you are being asked to set a resolution and quantize to that resolution. For example if you are to quantize to a 32-bit number, this would mean you would divide your range into 2^32 bins and quantize your values into those bins. For example:
offset = 1.5;
input_range = 3;
output_range = 2^32
quantized_value = round((value + offset) / input_range * output_range);
If you are being asked to use an adaptive quantizer that would mean that the resolution of the bins would be dynamic or the output bit width is variable. You would need to do more work to find what your goals are if you are going to write an adaptive algorithm for the quantization.

Related

Is there a Matlab function or codes to calculate SNRdB of 5D signal? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am doing a 5D data reconstruction from 5D noisy data. I am looking for any MATLAB codes or functions to calculate the SNR (in dB) in order to compare the noisy data with the original 5D data. Is there any way to do this using MATLAB?
Use: r = snr(x,y)
From Matlab documentation: r = snr(x,y) returns the signal-to-noise ratio (SNR) in decibels of a signal, x, by computing the ratio of its summed squared magnitude to that of the noise, y. y must have the same dimensions as x. Use this form when the input signal is not necessarily sinusoidal and you have an estimate of the noise.

Multiple linear system, same solution [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I know how to solve the problem
Ax=B
with matlab, I just use mldivide to obtain x: x=A\B
But what if I have multiple basis A_i and multiple data B_i but the nature of the problem suggests me that the solution x must be the same for every i?
You could try stacking the A matrices and B vectors to obtain a larger least squares system. That is, form
A = (A_1)
...
(A_n)
and
B = (B_1)
...
(B_n)
and then solve
A*x = B
in the least squares sense
The solution x to such a system will be the value that minimises
Sum{ || A_i*x - B_i ||^2 }
If I understand correctly, this is an image "unmixing" problem, which requests the solution of a (highly) overdetermined system of W x H equations (image area) in K unknowns (number of end members).
One wants to solve
X1.U1ij + X2.U2ij + X3.U3ij = Vij
(assuming K=3) where i, j cover the whole image.
The standard solutions will be least-squares minimization, with two caveats:
if there are outliers the results canbe badly biased and robust methods should be preferred;
if this is really a mixture problem, then the coefficients are constrained to be positive and the question should be recast as a linear programming problem.

Why does the randn function return a number larger than 1? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I thought randn returns a random number which belongs to a normal distribution with mean 0 and standard deviation 1. Therefore, I expect to get a number in the range (0, 1). But what I get is a number not in the range (0,1).
What am I doing wrong?
You are thinking of a uniform distribution. A normal distribution can, in theory, have very big numbers, with very low probability.
randn has a mean of 0 and standard deviation of 1. The normal distribution is the bell-curve / Gaussian shape, with the highest probability at the mean and probability falling off relative to the standard deviation.
What you are looking for is rand, which "samples" from a uniform random distribution, which gives numbers bounded between 0 and 1 with even probability at all points.
You're confusing the normal distribution with the uniform distribution.
Another possible source of confusion:
A normal distribution with mean 0 and variance 1 is often denoted N(0,1). This is sometimes called the standard normal distribution and implies that samples are drawn from all real numbers, i.e., the range (−∞,+∞), with a mean 0 and variance 1. The standard deviation is also 1 in this case, but this notation specifies the variance (many screw this up). The transformation N(μ,σ2) = μ + σ N(0,1), where μ is the mean, σ2 is the variance, and σ is the standard deviation, is very useful.
Similarly, a continuous uniform distribution over the open interval (0,1) is often denoted U(0,1). This is often called a standard uniform distribution and implies that samples are drawn uniformly from just the range (0,1). Similarly, the transformation U(a,b) = a + (b − a) U(0,1), where a and b represent the edges of a scaled interval, is useful.
Note that the 0's and 1's in these two cases do not represent the same things at all other than being parameters that describe each distribution. The ranges that these two distributions are sampled from are called the support.

Creat Log-normal Random Variable in MATLAB [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have trouble with the probability density function (p.d.f) of a log-normal distribution. I really need your help. As defined by wikipedia:
http://en.wikipedia.org/wiki/Log-normal_distribution#Probability_density_function
The probability density function of a log-normal distribution is:
My problem is, how to define x variable in MATLAB? Thanks for your help!
If you have the Stats toolbox, you can just use lognpdf:
y = lognpdf(x,mu,sigma);
Though this is a very simple function - fully vectorized, it's effectively just:
y = exp(-0.5*((log(x)-mu)./sigma).^2)./(x.*sqrt(2*pi).*sigma);
But you may want to check that x > 0 and sig > 0. To create this plot on the Wikipedia article that you cited, you can do:
mu = 0;
sigma = [1;0.5;0.25];
x = 0:0.01:3;
y = lognpdf([x;x;x],mu,sigma(:,ones(1,length(x))));
figure; plot(x,y);
When your question asks about defining x, maybe you're actually looking for log-normally distributed random variables, i.e., you want to sample randomly from the log-normal PDF/distribution? In that case you can use lognrnd:
r = lognrnd(mu,sigma);
I'm confused, like you can do this in a one-liner,
fun = #(x,mu,sigma) (1./(x*sigma*sqrt(2*pi))).*exp( -(power((log(x)-mu),2))/(2*power(sigma,2)))
x is any value that satisfies x > 0, the pdf tells you via Wikipedia
In probability theory, a probability density function (pdf), or
density of a continuous random variable, is a function that describes
the relative likelihood for this random variable to take on a given
value.
So any value x given to the log-normal pdf tells you tel relative likelihood that a random variable could be that value.
Consider this toy example:
mu = 1;
sigma = 10;
x = logspace(-2,0,10);
plot( x, fun(x,1,10) )
From this plot as x gets closer to zero, it's relative likelihood of actually taking on that value increases. DISCLAIMER I just threw that function together, it needs to be checked for accuracy, the preceding was for illustration only.

Implementing a derivative filter in MATLAB [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a task to implement a 3x3 x-derivative image filter that makes use of central difference and performs at the same time a Gaussian smoothing in the y direction.
I have a formula for that task in the x-direction (h=1), and I am not sure whether I understand it correctly:
(f(x+h;y)-f(x-h;y)) / 2*h
Relative from my current pixel (x), I take the pixel value +1 ahead of my current pixel and subtract the value from the pixel on the position -1 behind my current pixel. Is this value divided by 2 then more or less my first order derivation in the x direction? Isn't my actual current pixel value used at all?
Traditionally for images, the center isn't used for a derivative filter. The reasoning can be found as follows.
The purpose of most image processing filters is to find things in the original image, and to identify them. Thus, a good kernel (*) will be centered at the same location as the change.
The derivative should be zero meaned. If you add all of the pixels from the kernel, they should add up to zero.
Given these two points, and especially the first one, it is evident that the kernel should have an odd number of elements, and the center should be 0. Essentially, if the kernel is odd, then it will tend to preserve the original edge.
Taking a 1 dimensional example, and apply the formula you provided, trimming the edges (Forcing them to 0), will result as follows:
[0 1 3 2 10 12 8 11];
[0 -2 -1 -7 -10 2 1 0 ];
Note that the two highest magnitude values are right at the peak. Try playing with other kernels, including some that don't have the center value be 0, and see what results.
(*) Kernel represents the function you are performing. In the case you have provided, the kernel is [1 0 -1]