Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
metoduchka ІТАС_.doc
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
25.85 Mб
Скачать

Іv. Контрольні запитання

  1. В чому полягає постановка задачі інтерполювання функцій?

  2. В чому полягає геометричний смисл задачі інтерполювання функцій?

  3. Що являє собою лінійна інтерполяція?

  4. Що являє собою квадратична інтерполяція?

  5. Що таке параболічне інтерполювання?

  6. Який вигляд має інтерполяційна формула Лагранжа?

  7. Що таке екстраполювання функцій?

  8. Які засоби інтерполювання функцій є системі Mathcad?

Лабораторна робота № 15-16

Тема: «Наближення функцій методом найменших квадратів за допомогою СКМ»

Питання:

1. Постановка задачі наближення функцій.

2. Метод найменших квадратів наближення функцій.

3. Засоби наближення функцій в системах комп’ютерної математики.

І. Теоретичний матеріал

1. Засоби наближення функцій в системі комп’ютерної математики Mathcad

За допомогою довідки пакету Mathcad (розділ Statistics) можна знайти основні функції, які надають можливість розв’язувати задачу наближення функцій однієї змінної.

1.1. Лінійна регресія (Linear regression)

slope(vx,vy) and intercept(vx,vy)

These functions find the slope and the intercept of a set of data points.

Slope and intercept

slope(vx,vy) Slope of line that best fits data in vx and vy.

intercept(vx,vy) Intercept of line that best fits data in vx and vy.

Arguments:

vx is a vector of real data values. vx is a vector of real data values for the slope function. The values in vx correspond to the x values.

vy is a vector of real data values. These correspond to the y values. The number of elements is the same as vx.

Notes:

  • The slope and intercept functions are useful not only when your data is inherently linear but when it is exponential as well.

  • The equation of the line that best fits your data in vx and vy is y=m.x+b where m is the result from slope and b is the result from intercept.

The example below illustrates how to do linear regression using the slope and intercept functions. For a short-cut function, use line or medfit instead.

На рис. 1. показано приклад використання лінійної регресії.

1.2. Поліноміальная регресія (Polynomial regression)

regress(vx,vy,k)

Finds the polynomial that best fits a set of data points.

Polynomial regression

regress(vx,vy,k) Returns a vector which interp uses to find the kth order polynomial that best fits the x and y data values in vx and vy.

interp(vs,vx,vy,x) Returns interpolated y value corresponding to x. You get vs from regress.

Arguments:

vx is a vector of real data values in ascending order. These correspond to the x values.

vy is a vector of real data values. These correspond to the y values. The number of elements is the same as vx.

vs is a vector generated by regress.

k is a positive integer specifying the order of the polynomial you want to use to fit the data. Usually you’ll want k < 5.

x is the value of the independent variable at which you want to evaluate the regression curve.

Notes:

  • Regress is useful when you have a set of measured y values corresponding to x values and you want to fit a single polynomial of any order to those y values.

  • You should always use interp after using the regress function.

  • Since regress tries to accomodate all your data points using a single polynomial, it will not work well when your data does not behave like a single polynomial. Use the loess function to perform a more localized regression.

  • If you want to fit a surface to x, y, and z data, use regress for multivariate polynomial regression.

Рис. 1. Приклад використання лінійної регресії

Рис. 2. Приклад використання поліноміальної регресії

loess(vx,vy,span)

Finds the set of second order polynomials that best fit particular neighborhoods of data points.

loess(vx,vy,span) Returns a vector which interp uses to find a set of second order polynomials that best fit a neighborhood of the x and y data values in vx and vy. span controls the size of the neighborhood.

interp(vs,vx,vy,x) Returns interpolated y value corresponding to x. You get vs from loess or regress.

Arguments:

vx is a vector of real data values in ascending order. These correspond to the x values.

vy is a vector of real data values. These correspond to the y values. The number of elements is the same as vx.

vs is a vector generated by loess.

span is a positive real number for specifying how big a neighborhood you want to use. Use larger values of span when the data behaves very differently over different ranges of x. A good default value is span=0.75.

x is the value of the independent variable at which you want to evaluate the regression curve.

Multivariate polynomial regression

regress(Mxy,vz,k)

Finds the polynomial surface that best fits a set of points.

loess(Mxy,vz,span)

Finds the set of second order polynomials that best fits a particular neighborhoods of data points.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]