# Fitting values in a vector to separate Onlinestats Univariate statistics

**URL:** <https://discourse.julialang.org/t/fitting-values-in-a-vector-to-separate-onlinestats-univariate-statistics/115664>\
**Category:** Statistics\
**Tags:** question, onlinestats\
**Created:** [June 14, 2024, 5:16pm UTC](https://discourse.julialang.org/t/fitting-values-in-a-vector-to-separate-onlinestats-univariate-statistics/115664 "2024-06-14T17:16:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dario\_Sarra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dario_sarra/32/9338_2.png) [@Dario\_Sarra](https://discourse.julialang.org/u/Dario_Sarra)\
**Post date:** [June 14, 2024, 5:16pm UTC](https://discourse.julialang.org/t/fitting-values-in-a-vector-to-separate-onlinestats-univariate-statistics/115664/1 "2024-06-14T17:16:16Z")

</div>

My final goal was to compute N separate Means after vectorizing a CircularBuffer Matrix and update the means after a certain number of steps of the Circular buffer. I know how to get separate calculations using LinearAlgebra.eachrow or LinearAlgebra.eachcol from a Matrix, but it appears that this solution doesn’t work for Matrix with dimensions (n,1)

```julia
using OnlineStats, LinearAlgebra, DataStructures

mat = rand(10,5)
resh = reshape(mat, (size(mat,1) * size(mat,2), 1))
g = length(resh) * Mean()
fit!(g, LinearAlgebra.eachrow(resh))

```

In this example, the Means() end up taking 50 inputs each instead of 1

---

<div class="post-metadata">

**Author:** ![Dario\_Sarra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dario_sarra/32/9338_2.png) [@Dario\_Sarra](https://discourse.julialang.org/u/Dario_Sarra)\
**Post date:** [June 15, 2024, 11:16am UTC](https://discourse.julialang.org/t/fitting-values-in-a-vector-to-separate-onlinestats-univariate-statistics/115664/2 "2024-06-15T11:16:22Z")

</div>

For anyone interested, the solution I found was to pass a view on the first row and all columns of the matrix, instead of LinearAlgebra.eachrow

```julia
mat = rand(10,5)
resh = reshape(mat, (size(mat,1) * size(mat,2), 1))
g = length(resh) * Mean()
fit!(g, view(resh, :, 1))

```
