3
$\begingroup$

I have data points which is mydata = {{0, 0}, {1, 1}, {2, 0}};

From this data, I need to do the least squares approximation by using Bernstein polynomials to produce a set of Bezier points. Before the approximation, I define the uniform parameter values. And now I'm stuck on how to implement the Bernstein polynomial to get the normal equation. I have to use the Bernstein polynomial in order to find define the bezier points.

   mydata = {{0, 0}, {1, 1}, {2, 0}};

   data = mydata;
   numdata = Length[data];

   Print["Input numdata =", numdata];
   Print["Data = ", MatrixForm[data]];

   uniformparams[numdata_] := (
   Do[
    params[[i + 1]] = (i/(numdata - 1)),
    {i, 0, numdata - 1}
    ]; 
   Print["Uniform params = ", params // N];
   );

   approx[n_, params_, data_] := (

   mat1 = Table[params[[1 - i]], {i, 1, numdata}];
   Print["mat1", MatrixForm[mat1]];

   mat2 = Table[params[[i]], {i, numdata}];
   Print["mat2", MatrixForm[mat2]];

   A = {mat1};
   B = {mat2};
   (*C={A,B};*)
   combine = Transpose[{A, B}];
   Print["complete mat", MatrixForm[combine]];

   rhsx = Take[{data}, All, 1];
   Print["rhs", MatrixForm[rhsx]];

   );
$\endgroup$
  • $\begingroup$ its not really clear what you are asking.. is this useful? reference.wolfram.com/language/ref/BernsteinBasis.html $\endgroup$ – george2079 Oct 3 '16 at 0:56
  • 1
    $\begingroup$ I'm asking on how to implement the Bernstein polynomial to the datapoints that I have. It is useful. $\endgroup$ – BayWilson Oct 3 '16 at 2:06
  • $\begingroup$ You may also find this link useful. $\endgroup$ – m_goldberg Oct 3 '16 at 2:08
  • $\begingroup$ the question seems overly broad, and i cant see what the posted code has to do with the question. fwiw your mat1 table is invalid referencingparams[[0]] $\endgroup$ – george2079 Oct 3 '16 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.