Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. evalPoly <- function( x, coeff ) {
  2. if ( length( coeff ) < 1 ) return( c(0) )
  3. termSum <- 0
  4. for ( i in 1:length(coeff) ) {
  5. termSum <- termSum + coeff[i] * x^(i-1)
  6. }
  7. return( termSum )
  8. }
  9.  
  10. soTest <- function() {
  11. coeff <- c( 1, 2, -3, 4 )
  12. x <- 1:8
  13. y <- evalPoly( x, coeff )
  14. plot( x, y )
  15. text( 2, 1600, parse( text="1+2*x-3*x^2+4*x^3" ), adj=0 )
  16. text( 2, 1400, parse( text="Model: y = 1+2*x-3*x^2+4*x^3" ), adj=0 )
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement