forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 11:18 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Help needed for sine wave fit
PostPosted: Wed Jun 27, 2012 1:08 pm 
Offline

Joined: Wed Jun 27, 2012 12:57 pm
Posts: 1
In VB.net, I need to fit data to a sine wave and extract the phase. The x,y data is in an array. I've never done any fitting like this before, but I feel ALGLIB has the tools to do it. I have not found any examples of this problem, but I'm sure its fairly common. Any help would be greatly appreciated. Thanks.


Top
 Profile  
 
 Post subject: Re: Help needed for sine wave fit
PostPosted: Thu Jun 28, 2012 8:33 am 
Offline

Joined: Tue Jun 19, 2012 9:27 am
Posts: 10
Hi, So I think you try to find the parameters A and phi of the sinefunction y=f(t)=A*sin(2pi*f*x+phi). In the manual you should look at examples with lsfitcreatef function or lsfitcreatefg function. There it is explained very good.
So you have to choose: x=x[0], A=c[0], phi=c[1].
Dim x(,) As Double = New Double(,){{-1},{-0.8},{-0.6},{-0.4},{-0.2},{0},{0.2},{0.4},{0.6},{0.8},{1.0}} here you have to insert your x-data.
Dim y() As Double = New Double(){0.223130,0.382893,0.582748,0.786628,0.941765,1.000000,0.941765,0.786628,0.582748,0.382893,0.223130} and here the y-data

Dim c() As Double = New Double(){1,1} here you have to insert the startvalue {A,phi}.Here you have to choose values that are near to the expected A, phi. So if A is 50, an phi is 120 try with New Double(){40,100}.

I recommend you to take a sinefunction with some parameters (for example A=2 and phi= 100°) and calculate 10 values (x,y). With these values you let the programm calculate your parameters A,phi and so you can compare them to what you expect.
ok?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 29 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group