If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.
Special Thanks To:
Aaron Holmes
Aaron Wheeler
Adam Horden
Alan Scrimgeour
Andre
Andrew Haynes
Anonymous000
asabase
Austin Weil
barney
Barry
Bert Hickman
Bill Kukowski
Blitzorn
Brandon Paradelas
Bruce Bowling
BubeeMike
Byong Park
Cesiumsponge
Chris F.
Chris Hooper
Corey Worthington
Derek Woodroffe
Dalus
Dan Strother
Daniel Davis
Daniel Uhrenholt
datasheetarchive
Dave Billington
Dave Marshall
David F.
Dennis Rogers
drelectrix
Dr. John Gudenas
Dr. Spark
E.TexasTesla
eastvoltresearch
Eirik Taylor
Erik Dyakov
Erlend^SE
Finn Hammer
Firebug24k
GalliumMan
Gary Peterson
George Slade
GhostNull
Gordon Mcknight
Graham Armitage
Grant
GreySoul
Henry H
IamSmooth
In memory of Leo Powning
Jacob Cash
James Howells
James Pawson
Jeff Greenfield
Jeff Thomas
Jesse Frost
Jim Mitchell
jlr134
Joe Mastroianni
John Forcina
John Oberg
John Willcutt
Jon Newcomb
klugesmith
Leslie Wright
Lutz Hoffman
Mads Barnkob
Martin King
Mats Karlsson
Matt Gibson
Matthew Guidry
mbd
Michael D'Angelo
Mikkel
mileswaldron
mister_rf
Neil Foster
Nick de Smith
Nick Soroka
nicklenorp
Nik
Norman Stanley
Patrick Coleman
Paul Brodie
Paul Jordan
Paul Montgomery
Ped
Peter Krogen
Peter Terren
PhilGood
Richard Feldman
Robert Bush
Royce Bailey
Scott Fusare
Scott Newman
smiffy
Stella
Steven Busic
Steve Conner
Steve Jones
Steve Ward
Sulaiman
Thomas Coyle
Thomas A. Wallace
Thomas W
Timo
Torch
Ulf Jonsson
vasil
Vaxian
vladi mazzilli
wastehl
Weston
William Kim
William N.
William Stehl
Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
So I'm feeling pretty dumb right now; I've been out of school for mere months and I've already lost my edge:
I'm doing some DFT in visual basic; borrowed code, not mine. What I want to do is use my FT as a sort of curve fit; I'd like to be able to extrapolate a function based on the fourier coefficients that I find for the given data.
My problem is... I don't remember what to do with these coefficients. I keep confusing myself with which indexes represent the time and frequency domain (not to mention all my programmatic indexes for good measure).
Registered Member #29
Joined: Fri Feb 03 2006, 09:00AM
Location: Hasselt, Belgium
Posts: 500
Hi Andrew,
The coefficients are the weights for the complex exponentials..
f(x) = Sum(c_n * exp(2*pi*I*n*x/N)) (this may be off by a constant scaling factor.. Check a text on the exact scaling.. I'm recounting this off the top of my head..)
N = # of FT bins I = sqrt(-1) c_n = coefficient n
Your function can be recovered by computing the sum of the complex exponentials (this is the inverse DFT..which the inverse FFT will perform very rapidly).. remember that the "negative" frequency coefficients appear for n>N/2..
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
Yes, that helps... just a little more though if you please
c_n is the complex coefficient? I'm doing this in vb which balks at imaginary numbers, so my coefficients are stored in two arrays, one for the real half and one for ther imaginary half. I'm not sure how to produce that sum without being able to define /i/
Also, N is the number of FT bins... what does that mean? If I feed my DFT function an array j data points, it will produce a set (real and imaginary) of coefficients also with j members. Is N= j?
Registered Member #65
Joined: Thu Feb 09 2006, 06:43AM
Location:
Posts: 1155
FFT/DFT can get somewhat impractical if writing time critical code. Often, even though companies like Analog Devices offer products that support both real and unreal variables for some sensor front-end chips. However, most programmers only utilize the estimated real solution that’s auto generated as the code is simpler to implement.
VB is kind of a bad language as it does not support operator overloading to create new operations or custom variable types like C based languages. However, VB does allow OLE, media support, and simplified network connectivity. Many people tend to write DLLs (including GPL dedicated math libraries) for the math in C++ and import the functions into VB.
Likewise, small utility programs (often in C, Java, VB) will often simply connect with a network or system resource provided by Mathematica (see zip file) or Maple etc.
Registered Member #32
Joined: Sat Feb 04 2006, 08:58AM
Location: Australia
Posts: 549
Andrew wrote ...
c_n is the complex coefficient? I'm doing this in vb which balks at imaginary numbers, so my coefficients are stored in two arrays, one for the real half and one for ther imaginary half. I'm not sure how to produce that sum without being able to define /i/
If you're too lazy to study complex numbers again, the summation is incredibly simple. Sum all the real parts in the real array to get the real part of whole sum. The imaginary part of the sum is simply the sum of all the imaginary parts.
wrote ...
Also, N is the number of FT bins... what does that mean? If I feed my DFT function an array j data points, it will produce a set (real and imaginary) of coefficients also with j members. Is N= j?
Yes, that's what N traditionally is.
Carbon Rod: I guess you're right but VB is hardly the first thing that comes to mind when designing time critical code, either.
Andrew, could you tell us more about your problem? You're trying to use the FT for extrapolation? I have a funny feeling about that since, theoretically, the DFT works as if the data you're transforming is periodic. In other words, if you use the DFT for extrapolation, you'd just as well take the data you've got and repeat it like a looped tape.
Registered Member #49
Joined: Thu Feb 09 2006, 04:05AM
Location: Bigass Pile of Penguins
Posts: 362
Simon: The plan is to check IF the data is periodic by computing the DFT for a given (large) set of the data and the extrapolating to view the correlation (if any) with the rest of the data... I see what you mean about looping the data I've got, but what if I only have 1/3 of a period? I'm hoping the DFT will allow me to reconstruct the rest...
now that you put it to me, I can't actually recall if the FT behaves as I'd like it to... Shit. Someone know so I don't have to generate data sets just to check out how it behaves?
I haven't digested the rest of the info in this thread yet, but thanks guys, ill keep you posted.
Registered Member #72
Joined: Thu Feb 09 2006, 08:29AM
Location: UK St. Albans
Posts: 1659
What exactly are you trying to do? DFT may not be the best way to approach it, especially if not sure what you're doing.
Quote <sort of curve fit ... Extrapolate a function, based on FT coefficients that you find for the given data>
Are you extrapolating a function, or a data series? Are the data measurements, or samples from a process, are they noisy, is there a well-defined underlying model? Is the curve fit to the best curves over the interval of the data, to what order, with what base - complex exponentials direct from the DFT, or polynominals, or Tcheby polynominals? People very rarely lose an eye doing interpolation, but extrapolation is all set up to end in tears.
Registered Member #30
Joined: Fri Feb 03 2006, 10:52AM
Location: Glasgow, Scotland
Posts: 6706
The DFT/FFT starts by assuming the data is periodic. So I don't think you'll have much luck using it to tell if something's periodic or not. I'm not too sure exactly what the problem is you're trying to solve, but my gut feeling is that autocorrelation might be more useful to you than FFTs. I see Neil is kind of hinting at Kalman filtering too.
Registered Member #32
Joined: Sat Feb 04 2006, 08:58AM
Location: Australia
Posts: 549
Andrew wrote ...
Simon: The plan is to check IF the data is periodic by computing the DFT for a given (large) set of the data and the extrapolating to view the correlation (if any) with the rest of the data... I see what you mean about looping the data I've got, but what if I only have 1/3 of a period? I'm hoping the DFT will allow me to reconstruct the rest...
I'm not sure you quite see what I mean about looping.
The DFT won't allow you to reconstruct the rest. Looping isn't some bright idea, it's theoretically inherent in the DFT. If you use the DFT to extrapolate, you'll get looping.
I'm afraid there's no way around it. If you want to test if something is periodic, you have to collect data for long enough to see it repeat, unless you have some specific knowledge for the application.
Once you have a few periods worth of data there are plenty of ways to find the periods and I'd probably base an algorithm on the FFT. Autocorrelation can be done with an FFT (FFT: O(nlogn), autocorrelation: O(n^2)) and if you do an FFT, that should be good enough to see periodicity by itself.
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.