![]() |
|
#1
|
|||
|
|||
C++ Linear Regression with OutliersOK well, for one of my school assignments i have to code a program that performs Linear Regression with Outliers. The professor gave us some functions that we have to program. I have already done a few of them, but i dont know where to even begin on some of them.
I already programmed: int loadFromFile(FILE* fp) reads the abscissa and ordinate from the file pointed to by fp and returns the number of values successfully read from the file. Your function, if it encounters an end of file mark, returns EOF. double getx() const is a query that returns the abscissa. double gety() const is a query that returns the ordinate bool loadFromFile(const char* filename) receives the name of a file in a null-terminated C-style string. The file contains the data points in the set, one abscissa and corresponding ordinate per record. Your function attempts to open the file and returns true if successful; false otherwise. void closeUp() is a modifier that cleans up before the object goes out of scope. const char* label() const is a query that returns the label of the data set. double slope() const is a query that returns the slope of the least-squares line that fits the data points; 0 if there are no data points in the data set. double intercept() const is a query that returns the intercept of the least-squares line that fits the data points; 0 if there are no data points in the data set. double correlation() const is a query that returns the coefficient that describes the correlation between the abscissas and the ordinates of the data set; 0 if there are no data points in the data set. int nPoints() const is a query that returns the number of data points in the data set. DataPoint point(int i) const is a query that returns data point i of the data set. Now the ones that i am having trouble with are: bool operator==(const DataPoint&, const DataPoint&) returns true if the abscissa and ordinate values for two points are equal to one another within a specified tolerance. void include(double tolerance) receives a tolerance for the Chauvenet algorithm used to identify the outliers. void include() accepts all outlier points as valid data points. bool outlier(int) const is a query that receives the index of a data point and returns true if the data point is an outlier, false if not. int outlier() const is a query that returns the number of outlier points. void display() const is a query that inserts into the standard output stream a table of the data values with the outliers identified. bool operator==(const DataSet&, const DataSet&) is a helper that compares two sets of data points and returns true if the two sets hold the same data points, false otherwise |
|
#2
|
|||
|
|||
|
Quote:
So, what's the question? By that, I mean to say that, "I don't even know where to start," is not really a question. A question might be something like, "Here's the code that I wrote trying to implement the overloaded == operator, but it gives the following error '...' Can you tell me what is meant by '...'?" Or, "I have read the text on overloading operators, and don't understand where to put the code for '...' I tried this (show your code), and I got the following error messages (show the exact error messages here). What does '...' mean?" Or some such thing. Since you have already implemented some code manipulating and analyzing data points, you have classes, structs (or some such thing) defined for the points. Show what you have, and ask specific questions about what you would like to know for the next step. If the question is, "How do I determine whether a point is an outlier?" that's a math question, not a programming question. If you know how to determine this mathematically, but have trouble with some aspect of coding it in C++, show what you have, (or at least what you know), and ask specific questions. Regards, Dave |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linear Search | button | C++ Forum | 10 | 26-Apr-2004 22:48 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The