# shrinkage::MultivariateGaussian

Shrinkage for Rust · 0.3.0

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
pub struct MultivariateGaussian<'a>
```

Gaussian loss `||Y - predictor||_F² / (2 * nobs)`. 

Responses and predictors store each response column contiguously: entry `(observation, response)` has index `response * nobs + observation`. The loss sums over responses and averages over observations, so separable fits use the same penalty strengths as independent [`Gaussian`](<8f2aa89a892fb708e0e09c276910730b91ed3cb252a10cacd0a458cfbe59be13>) fits. Each response has its own optional unpenalized intercept, enabled by default. 

<a id="impl-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

## Inherent implementation

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
impl<'a> MultivariateGaussian<'a>
```

<a id="method-fit_intercept-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `fit_intercept`

```rust
pub fn fit_intercept(self, enabled: bool) -> Self
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Enable or disable the free intercept for every response. Explicit feature centering can still induce original-scale intercepts. 

<a id="method-fits_intercept-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `fits_intercept`

```rust
pub fn fits_intercept(&self) -> bool
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Whether fitting includes a free intercept for each response. 

<a id="method-gradient-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `gradient`

```rust
pub fn gradient(
    &self,
    predictor: &[f64],
    output: &mut [f64]
) -> Result<(), FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Write `(predictor - Y) / nobs` in response-major order. 

<a id="method-gradient-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2-documentation-errors"></a>

#### Errors

Reject invalid dimensions, nonfinite entries, or nonfinite arithmetic. Output is unspecified after an error. 

<a id="method-new-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `new`

```rust
pub fn new(response: &'a [f64], nobs: usize, nresponses: usize) -> Self
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Borrow response-major observations with explicit dimensions. Dimensions and entries are checked during loss evaluation or fitting. 

<a id="method-nobs-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `nobs`

```rust
pub fn nobs(&self) -> usize
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Number of observations per response. 

<a id="method-nresponses-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `nresponses`

```rust
pub fn nresponses(&self) -> usize
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Number of response columns. 

<a id="method-response-799289df722a92d78935273113547b7c4953ada0bb87b21207ef8f47393282d2"></a>

### `response`

```rust
pub fn response(&self) -> &[f64]
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

Borrow response columns in response-major order. 

<a id="impl-6af22eef7e8037822aec1e731a54c657b550f835cdc85af0600d5e4b17702d8e"></a>

## Implementation of Clone

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
impl<'a> Clone for MultivariateGaussian<'a>
```

<a id="method-clone-6af22eef7e8037822aec1e731a54c657b550f835cdc85af0600d5e4b17702d8e"></a>

### `clone`

```rust
fn clone(&self) -> Self
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

<a id="impl-8828b6000f2a7a8054d73e11a7d6ef3797da814c3991833fb942522cebfcb56e"></a>

## Implementation of Copy

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
impl<'a> Copy for MultivariateGaussian<'a>
```

<a id="impl-cfd0b61e0db351c6bfee407b028f49c366af1f21f8222dffab0bc494090c2485"></a>

## [Implementation of Datafit](<9d16367f3210bbbb9bf039290cf9c94f447e51d4ea33aea446a7f30e965d873a>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
impl Datafit for MultivariateGaussian<'_>
```

<a id="associated-type-Error-cfd0b61e0db351c6bfee407b028f49c366af1f21f8222dffab0bc494090c2485"></a>

### `Error`

```rust
type Error = FitError;
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

<a id="method-value-cfd0b61e0db351c6bfee407b028f49c366af1f21f8222dffab0bc494090c2485"></a>

### `value`

```rust
fn value(&self, predictor: &[f64]) -> Result<f64, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

<a id="impl-42617f86280314e73a80b47b762752984f3ad22a7783ef7915df58792dcecfc9"></a>

## Implementation of Debug

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

```rust
impl<'a> Debug for MultivariateGaussian<'a>
```

<a id="method-fmt-42617f86280314e73a80b47b762752984f3ad22a7783ef7915df58792dcecfc9"></a>

### `fmt`

```rust
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/datafit/multivariate.rs>)

<a id="impl-bacbcb8259c76a88b4314192038715ddfdf3231b14fc185f524350e8fa4c5098"></a>

## [Implementation of NullModelDatafit](<12ebbf9584faa968bb3fcbf1175e4e131dd6c7466b719c62ad9d7628739d9dac>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/path/datafit.rs>)

```rust
impl NullModelDatafit for shrinkage::MultivariateGaussian<'_>
```

<a id="method-deviance-bacbcb8259c76a88b4314192038715ddfdf3231b14fc185f524350e8fa4c5098"></a>

### `deviance`

```rust
fn deviance(&self, predictor: &[f64]) -> Result<Option<f64>, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/path/datafit.rs>)

<a id="method-null_intercepts-bacbcb8259c76a88b4314192038715ddfdf3231b14fc185f524350e8fa4c5098"></a>

### `null_intercepts`

```rust
fn null_intercepts(&self) -> Result<Vec<f64>, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/path/datafit.rs>)

<a id="impl-b7949c840d14e9b436f0e9487ccc6459e42df422f3b3a8f61b49e97673744797"></a>

## Implementation of Freeze

```rust
impl<'a> Freeze for MultivariateGaussian<'a>
```

<a id="impl-e05791e026a0f5d182bb98d43e1444a3ad532799994197edf492ed276060038a"></a>

## Implementation of RefUnwindSafe

```rust
impl<'a> RefUnwindSafe for MultivariateGaussian<'a>
```

<a id="impl-33b48d488b23eeaa193db41216580269d85645d9e613a485d0c0cf1bb2fb7277"></a>

## Implementation of Send

```rust
impl<'a> Send for MultivariateGaussian<'a>
```

<a id="impl-f1a1da535af905c3cf19d0ae7dcefb2ce04b1aefe0ae69434ef5e486fda64a1c"></a>

## Implementation of Sync

```rust
impl<'a> Sync for MultivariateGaussian<'a>
```

<a id="impl-21ce687a48f7f982b1019ff9b9d365c6768c177566181be44ef3262b0a124085"></a>

## Implementation of Unpin

```rust
impl<'a> Unpin for MultivariateGaussian<'a>
```

<a id="impl-3766e5abd7acd78198e99b0e6426bb906101c7f931839f4cfbd31be99f881cb6"></a>

## Implementation of UnsafeUnpin

```rust
impl<'a> UnsafeUnpin for MultivariateGaussian<'a>
```

<a id="impl-df7aeb7a81a3ce9599f78d840a6fabf7032548de4432b7b0e620e9efb3e350da"></a>

## Implementation of UnwindSafe

```rust
impl<'a> UnwindSafe for MultivariateGaussian<'a>
```

<a id="impl-1e5682dc18e03c648aa9b125290c107c1e8d96ce8a179a8532e4057da4daf0cd"></a>

## Implementation of Any

```rust
impl<T> Any for T where T: 'static + ?Sized
```

<a id="impl-6c0b25c2c92cdb117802d9c0a4c70afc9a8bfb0da875bc6e66191e2349fcdf3f"></a>

## Implementation of Borrow

```rust
impl<T> Borrow<T> for T where T: ?Sized
```

<a id="impl-796e80d926348273a22b04d8e84f510693b11c06ec57c3c3e2e8c1524094a85c"></a>

## Implementation of BorrowMut

```rust
impl<T> BorrowMut<T> for T where T: ?Sized
```

<a id="impl-8360e4092e7ec4a05a26dd304cd739398f0cacc50c8d08dd5be0223d1a08d02e"></a>

## Implementation of ByRef

```rust
impl<T> ByRef<T> for T
```

<a id="impl-dbb1293b7b5dd80c4d9a98cfdd6843dc7470224c0b1387731cd418da07046d7b"></a>

## Implementation of CastableFrom

```rust
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized
```

<a id="impl-97b65e7dfc44b5ecaa495a3a19fe737914a1e9f8532200cf8f46191314e7d777"></a>

## Implementation of CastableFrom

```rust
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized
```

<a id="impl-86d7da2bfd1140cc1675dfe6a975e6a2762338ab32731152da0723858ef3aa81"></a>

## Implementation of CloneToUninit

```rust
impl<T> CloneToUninit for T where T: Clone
```

<a id="impl-c22bdd3b1b677b66eb32d1c182cc1410c7f0c46491dd74e6a659647c238d19ec"></a>

## Implementation of From

```rust
impl<T> From<T> for T
```

<a id="impl-5adf6ca1830f30fbbac655ab8ff394d254954df7ededc7cc833c72fdc87d6f00"></a>

## Implementation of Imply

```rust
impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized
```

<a id="impl-85eec431edd188129f88290bbcb748e4d2fdc97f7efef3c162b8c252286ffec0"></a>

## Implementation of Into

```rust
impl<T, U> Into<U> for T where U: From<T>
```

<a id="impl-c40268dd59dd3329202d3c0544c62372e98ff3baa8ec442ec00752e024ec1d06"></a>

## Implementation of IntoEither

```rust
impl<T> IntoEither for T
```

<a id="impl-5655b1ef858b34a584cb80104f040c8a4063ced0d281311a0833ed12aefde86e"></a>

## Implementation of Pointable

```rust
impl<T> Pointable for T
```

<a id="impl-8cc2aa01198fc9fa44f08b889f62988d70d2a7f4f0f11f4666d4c08bdaddb22a"></a>

## Implementation of Read

```rust
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized
```

<a id="impl-5ea09131039c62dd92b119d480a35c7e2b33d2b81dccf0b849f6b1f19f4bda24"></a>

## Implementation of Same

```rust
impl<T> Same for T
```

<a id="impl-7ee6ff38d6674f5edfe4734359062c2a67a572cff5899a89704764822b931c7f"></a>

## Implementation of SupersetOf

```rust
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>
```

<a id="impl-a8ef6e94191301c3685488478f4905086c47137bac2d606ea4d09631d5472b06"></a>

## Implementation of ToOwned

```rust
impl<T> ToOwned for T where T: Clone
```

<a id="impl-83960135d00d98080c95a08867729696e36811280c2dd9cf34c1b4fe21c81e18"></a>

## Implementation of TryFrom

```rust
impl<T, U> TryFrom<U> for T where U: Into<T>
```

<a id="impl-1cc495bcaa5112ffb304e7f0de674feca391fd97f47bec86033a9225b72ac05c"></a>

## Implementation of TryInto

```rust
impl<T, U> TryInto<U> for T where U: TryFrom<T>
```
