Skip to content

Commit 0a5f4c1

Browse files
committed
util_stat
1 parent 8de5170 commit 0a5f4c1

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/_util_stat.jl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ X = rand(n, p)
418418
Y = rand(n, 3)
419419
w = pweight(rand(n))
420420
421+
corm(X)
422+
corm(X, Y)
423+
421424
corm(X, w)
422425
corm(X, Y, w)
423426
```
@@ -454,6 +457,8 @@ The Frobenius norm of `X` is:
454457
455458
The weighted Frobenius norm is:
456459
* sqrt(tr(X' * D * X)), where D is the diagonal matrix of vector `weights.values`.
460+
461+
See function `frob2`.
457462
"""
458463
frob(X::AbstractMatrix{Q}) where Q <: AbstractFloat = sqrt(frob2(X))
459464

@@ -466,7 +471,24 @@ Squared Frobenius norm of a matrix.
466471
* `X` : A matrix (n, p).
467472
* `weights` : Weights (n) of the observations. Object of type `ProbabilityWeights` (e.g., generated by function `pweight`).
468473
469-
See function `frob`.
474+
The squared Frobenius norm of `X` is:
475+
* tr(X' * X).
476+
477+
The squared weighted Frobenius norm is:
478+
* tr(X' * D * X), where D is the diagonal matrix of vector `weights.values`.
479+
480+
## Examples
481+
```julia
482+
using Jchemo
483+
484+
n, p = 5, 6
485+
X = rand(n, p)
486+
w = pweight(rand(n))
487+
488+
frob2(X)
489+
490+
frob2(X, w)
491+
```
470492
"""
471493
frob2(X::AbstractMatrix{Q}) where Q <: AbstractFloat = sum(colnorm2(X))
472494

0 commit comments

Comments
 (0)