Skip to content

Commit 7a4fe11

Browse files
Volodymyr OrlovVolodymyr Orlov
authored andcommitted
fix: ridge regression, formatting
1 parent ca3a3a1 commit 7a4fe11

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/linalg/stats.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ pub trait MatrixStats<T: RealNumber>: BaseMatrix<T> {
6969

7070
/// Computes the standard deviation along the specified axis.
7171
fn std(&self, axis: u8) -> Vec<T> {
72-
7372
let mut x = self.var(axis);
7473

7574
let n = match axis {
7675
0 => self.shape().1,
7776
_ => self.shape().0,
7877
};
7978

80-
for i in 0..n {
79+
for i in 0..n {
8180
x[i] = x[i].sqrt();
8281
}
8382

@@ -141,16 +140,13 @@ mod tests {
141140

142141
#[test]
143142
fn var() {
144-
let m = DenseMatrix::from_2d_array(&[
145-
&[1., 2., 3., 4.],
146-
&[5., 6., 7., 8.]
147-
]);
143+
let m = DenseMatrix::from_2d_array(&[&[1., 2., 3., 4.], &[5., 6., 7., 8.]]);
148144
let expected_0 = vec![4., 4., 4., 4.];
149145
let expected_1 = vec![1.25, 1.25];
150146

151147
assert!(m.var(0).approximate_eq(&expected_0, std::f64::EPSILON));
152148
assert!(m.var(1).approximate_eq(&expected_1, std::f64::EPSILON));
153-
}
149+
}
154150

155151
#[test]
156152
fn scale() {

0 commit comments

Comments
 (0)