Pages

Jun 10, 2011

Exceptions

Before writing the final post on Wiener deconvolution, I decided to share a little code snippet. It occurred to me that from time to time I write an exception class. Mostly they are the same, so why not make it public ... It can be derived of course to provide further specialization, but for the current project I'm working on (which is a console application) it's enough.

So here goes the code:
http://codepad.org/KGvqarqa

May 15, 2011

Filters and such

This is a continuation of the "Delta spectrum" post, so we start from there. I've realized that if not done incrementally, to obtain a convolution of two signals in the time domain, would be more computationally consuming, than to do it in the frequency domain.

FFT is with complexity, against the complexity of time domain convolution. So I'm going to explore this a little bit.

We start with a signal defined as:
Here H is the frequency response of our system, N is additive noise, X is the real (original signal) and Y is the observed, convoluted signal with noise. We would like to find a function G such as:
Whereas is an estimate of the original signal, which should minimize the mean square error.

Without going into further details, the operation is assumed to be carried out in the frequency domain as follows:
Taking into consideration that G is the Wiener filter defined as:

Now going back and accounting for our original signal and our frequency response, which are correspondingly a delta function and a Gaussian, the last equation is simplified enormously. For the impulse response we have:


And for the original signal one can write:


Where j is the imaginary unit.

The noise could be estimated by doing lowpass filtering and converging to a state where the mean square deviation from the original signal would be minimal. The parameters alpha and tau can be automatically estimated from the signal peaks, by doing nonlinear Gaussian fit in the time domain. The whole point of doing such a complicated process would be to try finding merged energy peaks, low intensity peaks, or estimating Doppler shift in the spectrum.

May 2, 2011

Read me, write me

Recently I've came up with a timeless problem ... imagine what happens if you try to read from and write to a file simultaneously - junk. Let's say that you are in a single process space, you have the option to synchronize threads and go around the problem, but for more than one process it becomes tricky. From what I can tell there are two options, firstly one can devise a scheme with interprocess communication (IPC) to serialize the read-writes. Unfortunately if you're aiming for platform independence, it won't work, not that it's impossible, but it would take quite an effort to do it. You'd have to implement the IPC for every platform you are going to support.

I've thought about this some time now, and I've came up concluding that there is simpler, easier and portable way to do it - file server. It's not a classical ftp type server per se, but more of a simplistic network oriented file management server. One would create a daemon which listens to some port, and use a simple protocol to communicate with it. The daemon itself would be able to list/create/delete/read/write files on the host machine. Aside from a small overhead, it can work on the local computer (through local port), as well as on a remote machine, which gives it the flexibility I'm looking for. It's not something new in the world of programming, but gives a way to implement file operations serialization primitive which is portable.

The purpose of all this, is a project I have a plan on starting in the near future. And since it would need both network client-server connectivity and local file locking primitive, I've decided to merge the two concepts and use serialization for both cases.