Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. CC[m_, t_] := Module[{n, M, a},
  2.  
  3. n = Dimensions[m][[1]] - 1;
  4. M = Table[0, {i, 0, n}, {j, 0, n - i}];
  5. a = Table[" ", {i, 0, n + 1}];
  6. M[[1]] = m;
  7. a[[1]] = ListPlot[m, Joined -> True, DisplayFunction -> Identity];
  8.  
  9. For[i = 1, i <= n, i++,
  10. For[j = 1, j <= n - i + 1, j++,
  11. M[[i + 1, j]] = t*M[[i, j + 1]] + (1 - t)*M[[i, j]]];
  12. a[[i + 1]] =
  13. ListPlot[M[[i + 1]], Joined -> True,
  14. PlotStyle -> RGBColor[i/n, 0, 1 - i/n],
  15. DisplayFunction -> Identity]];
  16. a[[n + 1]] =
  17. ListPlot[M[[n + 1]], PlotStyle -> PointSize[0.05],
  18. DisplayFunction -> Identity];
  19. a[[n + 2]] =
  20. ParametricPlot[
  21. Sum[Binomial[n, k]*s^k*(1 - s)^(n - k)*m[[k + 1]], {k, 0, n}], {s,
  22. 0, t}, PlotStyle -> {RGBColor[1, 0, 0], Thickness[0.02]},
  23. DisplayFunction -> Identity];
  24. Show[a, DisplayFunction -> $DisplayFunction,
  25. AspectRatio -> Automatic, PlotRange -> All, Axes -> False]]
  26. (test)
  27. m = {{0, 0}, {0, 1}, {1, 1}, {2, 0}, {3, 1}};
  28. Animate[CC[m, t], {t, 0.01, 1}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement