Spec-Zone.ru › Octave 7

21.4 Примеры использования

Следующее можно использовать для решения системы линейных уравнений A*x = b с помощью LU-разложения с выбором главного элемента:

[L, U, P] = lu (A); ## now L*U = P*A
  x = U \ (L \ P) * b;

Вот один из способов нормализовать столбцы матрицы X до единичной нормы:

s = norm (X, "columns");
  X /= diag (s);

То же самое можно сделать с помощью вещания (см. Вещание):

s = norm (X, "columns");
  X ./= s;

Следующее выражение — способ эффективного вычисления знака перестановки, заданной вектором перестановки p. Оно будет работать и в более ранних версиях Octave, но медленнее.

det (eye (length (p))(p, :))

Наконец, вот как решить систему линейных уравнений A*x = b с регуляризацией Тихонова (регрессия с гребнем) с использованием SVD (только скелет):

m = rows (A); n = columns (A);
  [U, S, V] = svd (A);
  ## determine the regularization factor alpha
  ## alpha = …
  ## transform to orthogonal basis
  b = U'*b;
  ## Use the standard formula, replacing A with S.
  ## S is diagonal, so the following will be very fast and accurate.
  x = (S'*S + alpha^2 * eye (n)) \ (S' * b);
  ## transform to solution basis
  x = V*x;

© 1996–2022 The Octave Project Developers
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://docs.octave.org/v7.2.0/Example-Code.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API