Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with creating a trend function

Status
Not open for further replies.

dbsquared

Programmer
Nov 7, 2002
175
US
Hi, I am learning VB.NET now, I currently code in VB 6.0 and am looking to upgrade our projects.
I have been tasked by my manager to come up with an alogrythim that has the ability to do a forward looking trend line. Similar to the one in excel except we want to do it all in software and return the value, from the function or class.
I was wondering where would be a good place for me to start or is there a web page that might have done some of this functionality already that I can reuse the code.
Thanks for all your help

dbsquared

To go where no programmer has gone before.
 
dbsquared,

I'm not sure if this is what you are looking for, but you will want to do a search for "Linear Regression" if you are working with linear functions. From the formula that is generated from the regression, you can substitute in a future value for either the x or y variable and then solve for the other.

--Foundry
 
I am not sure if that will work but I will look thank you.

As for what I was looking for I will try to explain.
what I want to do is take say 6 numbers
1,2,3,4,5,6

Then based upon what is fed to the function I get that the next number would be:
7

Then I loop through that and feed the numbers back to the function and based upon that the next number would be :
8

Basicly this is a statistical calculation that takes in a certain amount of data input then takes that and predicts what the next number would be either going up or going down. This is a very rudedmentry example.


Thanks again


To go where no programmer has gone before.
 
If your functions when graphed appear to follow a straight line, the linear regression is what you will want. You will need to compute the slope and the y-intercept of the best fit line from the data and then from there enter in the "next number". You could enter in any number and it would return the "projected" value. If you don't have an answer by this evening, I will look for one when I get home. One question, do you only have two variables or are there more?

--Foundry
 
I will have probably up to 24 this can be variable depending upon how much data is collected. What I was looking for was a function that would calculate the slope and y-intercept and at the same time return the "next number" I will see what I come up with this afternoon.
Thanks for your time.

To go where no programmer has gone before.
 
I tried the look up for Linear Regression and got nothing returned to me, Ialso tried linear, Regression andnd Linear function but none returned any type of information that I was looking for.
Is it maybe called something else?
Linear Function returned the charting VtChScaleTypeLinear for charting linear data but I want to store the data.
Thanks for your help

To go where no programmer has gone before.
 
dbsquared,

My apologies, I meant a search on the net, sorry. Another key word to use is "least squares". My search returned the following site that may be of interest.


Sorry I can't be of much help at the moment, I will be able to help more in a few hours.

Thanks,

Foundry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top