0

Regarding the answer by MRocklin on his own question "Multivariate polynomial regression with numpy", could anyone please explain how to understand the output "beta" in the function multipolyfit(xs, y, deg, full=False, model_out=False, powers_out=False) of core.py?

For example if xs has two independent variables a, b and y is the dependent variable, suppose I do

beta = multiplotfit(xs,y,2)

then what should be beta[0], beta[1], ...? Which is constant term, which is the coefficient of x, and so on? Thank you so much!

Community
  • 1
  • 1
  • I edited your question for you, please take care to examine differences. It happens that I saw reasons of your question, and knew what you're talking about, but you should make sure yourself that your question can be understood standalone. Ambiguous questions without detail tends to be instantly downvoted here on SO. – alko Dec 09 '13 at 22:27

1 Answers1

0

For variables you provided, a and b, multipolifit calculates combinations of its powers with sum or powers not exceeding deg, and returns coefficients for linear approximation of y with resulting data.

If called as

beta, powers = multiplotfit(xs,y,2)

beta will contain coefficients for powers, which are in case of two variables

>>> powers
[array([2, 0, 0]), array([1, 1, 0]), array([1, 0, 1]), array([0, 2, 0]), array([0, 1, 1]), array([0, 0, 2])]

where first power stands for constant, i.e. 1, second for a power, third for b power).

For example, beta = [1, 0, 0, 1, 0, 1] can be translated as expression 1 + a**2 + b**2.

alko
  • 46,136
  • 12
  • 94
  • 102