hrk0531 / sappy

BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Compute unique variance #10

Open hrk0531 opened 1 month ago

hrk0531 commented 1 month ago

unique variance の求め方がわからない

def unique_variances(x: np.ndarray[Any, Any])-> np.ndarray[Any, Any]:
    _, eigvals_idx, eigvecs_idx = eig_sort(x)

    # Step 1: Compute the product of the transpose of eigenvectors and eigenvectors
    product = eigvecs_idx.T @ eigvecs_idx

    # Step 2: Compute the inverse of this product
    inv_product = np.linalg.inv(product)

    # Step 3: Extract the diagonal elements to form a diagonal matrix
    psi_sq = np.diag(np.diag(inv_product))

    # Step 4: The diagonal elements of this matrix represent the unique variances
    unique_variance = np.diag(psi_sq)

    return unique_variance
で試したが結果が`[1., 1.]`になる。Step3あたりが悪さをしているように見えるが、解決策が浮かばない。
yanagikad commented 1 month ago

@hrk0531

def unique_variances(x: np.ndarray[Any, Any])-> np.ndarray[Any, Any]:
    _, eigvals_idx, eigvecs_idx = eig_sort(x) # TODO Write type hint

    # Step 1: Compute the product of the transpose of eigenvectors and eigenvectors
    product = eigvecs_idx.T @ eigvecs_idx # TODO same above

    # Step 2: Compute the inverse of this product
    inv_product = np.linalg.inv(product) # TODO same above

    # Step 3: Extract the diagonal elements to form a diagonal matrix
    psi_sq = np.diag(np.diag(inv_product)) # TODO same above

    # Step 4: The diagonal elements of this matrix represent the unique variances
    unique_variance = np.diag(psi_sq) # TODO same above

    return unique_variance

まずこれで型チェック。各ステップごとにprint checkもして各変数の振る舞いを見る

yanagikad commented 1 month ago

unique varianceって誤差だから、引き算なり、割り算なり、誤差を図る対象があるはずだけど、それが見当たらないね

↑ここの部分について、unique varianceの説明がちゃんとできるか、確認してみて

hrk0531 commented 1 month ago
y_{i} = \lambda_{j1}f_{i1} + \lambda_{j2}f_{i2} + \cdots + \lambda_{jm}f_{im} + d_{j}u_{ij}

があって、共通性$h_{j}$について

h_{j}^{2} = \lambda_{j1}^{2} + \cdots + \lambda_{jm}^{2} + d_{j}^{2}

ってのがあった気がするんだけどこれを図る対象にしちゃだめかな

yanagikad commented 1 month ago

@hrk0531 自分がそれで良いと思った理由と、懸念材料を書いて欲しい。意図が見えない。

yanagikad commented 1 month ago

コメントのレビューをしていますが、大体テストフェーズに乗る前の設計段階では

を必ずかけと昔殴られていたので 書こう!何においても。

あと、確認してみてという提案をしたので、それに対する調査結果/自分の認識も記述しといて。