Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covariance #5

Closed
Beakerboy opened this issue Jul 15, 2016 · 2 comments
Closed

Covariance #5

Beakerboy opened this issue Jul 15, 2016 · 2 comments

Comments

@Beakerboy
Copy link
Contributor

Your Statistics/Descriptive class has variance. Where would you like to put Covariance? Are you planning on keeping single variable statistics in Descriptive, and multi-factor statistics in either another class, or in Regression?

Bigger picture question...Are you planning on making all your methods static, and is there a reason for this choice? Would it be easier for users to code more like:

$data = [[1,2],[2,3],[5,7]];
$regression = new Regression($data); // load the data and calculate regression parameters
$parameters = $regression->getParameters();  // returns[beta, alpha]
$residuals = $regression->getResiduals(); // an array of the residuals
$regression->evaluate(2.5);    // get yhat at x=2.5
@markrogoyski
Copy link
Owner

Hi,
Thanks for the interest and in helping out. I appreciate it.

Covariance is in Math\Statistics\RandomVariable. See if that does what you want.

For static vs object methods, a lot of math functions are input and output, so it makes sense to be static. However, whenever I get to linear algebra, I was planning on having classes for Vector and Matrix etc. and they would have object methods to do various matrix operations. Basically, any time where you would want to do multiple operations on the same data, I think it makes sense to make an object.

I see what you are thinking with Regressions. I think that would be a good design change, especially considering there are functions to evaluate for y based on the regression parameters.

@markrogoyski
Copy link
Owner

I've refactored Regressions into individual classes that are instantiated, which extend a base Regression class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants