How to calculate the statistics/ percentile in julia

Hello,

I’m new in Julia and I would like to do some statistics.
How can I calculate a percentile of a matrix?
I installed the using StatsBase package and I’m doing:
percentile(mymatrix, 25), however I get an error

Try

percentile(vec(mymatrix), 25)

as mymatrix is 2D and percentile expects a 1D vector. The vec(...) operation should not incur any performance penalty.

Hello,
I think that this is not what I want.
This returns only a single value, and what I want to obtain is the percentile of the complete matrix. In fact what I’m searching is the equivalent of matlab function “prcntile”
Thank you in advance.

The way how the question is posted is somewhat ambiguous, because the meaning of “a percentile of a matrix” depends on how the values stored inside the matrix are interpreted.

That would be percentile.(eachcol(mymatrix), 25). the key thing to realize here is that in Julia unlike Matlab, a Matrix and a list of lists are fairly different.

1 Like

Thank you Oscar, this worked for me!