## Topic: Converting Frequency Distributions (Read 2708 times)previous topic - next topic

0 Members and 1 Guest are viewing this topic.
• ExUser
Converting Frequency Distributions
##### 24 April, 2004, 06:36:20 PM
I don't know how to phrase my question properly, so I'll try and explain what my intent is.

In a thread a while back, I mentioned an idea of mine: If you find the distribution of the PCM data in a file, altering that distribution could fix some dynamic compression problems, albeit with an increase in harmonic distortion.

So, what would be a method for converting the known, arbitrary distribution of PCM data to another arbitrary distribution, ie the normal distribution?

• ErikS
Converting Frequency Distributions
##### Reply #1 – 25 April, 2004, 01:41:19 PM
Should be easy in matlab for example. Check out the histeq function first.

• ExUser
Converting Frequency Distributions
##### Reply #2 – 26 April, 2004, 10:33:15 PM
Quote
Should be easy in matlab for example. Check out the histeq function first.

Hmm... if I were only working in Matlab...

May look into that more, may just hack with the math. I don't know a lot about summation operators though.

Thanks for the idea at very least.

• ErikS
Converting Frequency Distributions
##### Reply #3 – 26 April, 2004, 11:03:53 PM
Ok then. So maybe a short description of what histeq does is in place?

You need a function to map input values between -32k and +32k to the same output range. First you have to find the PDF by counting the occurances of each value, and then dividing by the total number of samples. Then a function to turn this into a uniform distribution use this as your mapping function: T(x) = (sum(pdf(i), i=-32 to x) - 0.5 ) * 64k

Then to turn a uniform pdf into a normal there is a fixed function, lets call it N. Compose these two functions, (N o T) and apply it to your data.

Edit: crappy autoformatting turned my variable into ® ...

Oh, and by the way... why not try your idea in matlab before coding in in C or something? It's much faster way of testing, and if it turns out it doesn't work, much less work down the drain. And if it does work you have a good prototype before you start writing c code.

Edit2: Just found that N is normally called Box-Muller transform. Google it.

• cabbagerat
Converting Frequency Distributions
##### Reply #4 – 27 April, 2004, 05:20:50 AM
If you don't have access to Matlab you can try Octave, which is a very similar language and is free. Last time I used it (it develops quickly though) it didn't have the Histeq function, but certainly supports all the primitives that would make one easy to implement. Googling for "octave histeq" also returns a couple of implementations.
Octave's Sourceforge page is a good place to start.

Quote
Oh, and by the way... why not try your idea in matlab before coding in in C or something

This is a very good idea - it means you can seperate the maths from the practicalities. Once you are sure of the maths you are doing, then implementing in C would be simple (look at the fftw and ATLAS libraries for a start).