Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- evalPoly <- function( x, coeff ) {
- if ( length( coeff ) < 1 ) return( c(0) )
- termSum <- 0
- for ( i in 1:length(coeff) ) {
- termSum <- termSum + coeff[i] * x^(i-1)
- }
- return( termSum )
- }
- soTest <- function() {
- coeff <- c( 1, 2, -3, 4 )
- x <- 1:8
- y <- evalPoly( x, coeff )
- plot( x, y )
- text( 2, 1600, parse( text="1+2*x-3*x^2+4*x^3" ), adj=0 )
- text( 2, 1400, parse( text="Model: y = 1+2*x-3*x^2+4*x^3" ), adj=0 )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement