Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MathPHP で数学人材を目指す - PHPカンファレンス 2021 1週間前イベント 〜 帰ってきたPHP勉強会@東京

hamakou108
September 25, 2021

MathPHP で数学人材を目指す - PHPカンファレンス 2021 1週間前イベント 〜 帰ってきたPHP勉強会@東京

PHPカンファレンス 2021 1週間前イベント 〜 帰ってきたPHP勉強会@東京の登壇資料です。

hamakou108

September 25, 2021
Tweet

More Decks by hamakou108

Other Decks in Programming

Transcript

  1. 使い方も簡単 - 行列の場合 use MathPHP\LinearAlgebra\Matrix; use MathPHP\LinearAlgebra\MatrixFactory; // 1. Matrix

    クラスのインスタンスを生成 $matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], ]; $A = MatrixFactory::create($matrix); // 2. 行いたい操作に対応するメソッドを呼び出し $Aᵀ   = $A->transpose(); // 転置行列 $D   = $A->diagonal(); // 対角行列 $A⁻¹ = $A->inverse(); // 逆行列
  2. 例. 任意長の整数 use MathPHP\Number\ArbitraryInteger; // 任意長の巨大な整数を作成 $bigInt = new ArbitraryInteger('876937869482938749389832');

    $extremelyBigInt = $bigInt->pow(2); $string = (string) $extremelyBigInt; // "769020026933275716728118484358230957952304988224"
  3. 例. パーセンタイル use MathPHP\Statistics\Descriptive; $numbers = [13, 18, 13, 14,

    13, 16, 14, 21, 13]; // Percentiles $twentieth_percentile = Descriptive::percentile($numbers, 20); // 13.0 $ninety_fifth_percentile = Descriptive::percentile($numbers, 95); // 19.8
  4. 例. 相関係数 r = ​ = s ​ s ​

    x y s ​ xy ​ ​ ​ ​ (x ​ − ) i ∑ n i x ˉ 2 ​ (y ​ − ​ ) i ∑ n i y ˉ 2 ​ (x ​ − )(y ​ − ​ ) i ∑ n i x ˉ i y ˉ use MathPHP\Statistics\Correlation; $X = [1, 2, 3, 4, 5]; $Y = [2, 3, 4, 4, 6]; $r = Correlation::r($X, $Y); // 0.95940322360025