Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the mode of an array in Julia?

Tags:

julia

I have an array defined as the following:

julia> a = [5, 6, 7, 8, 10, 12, 12, 17, 67, 68, 69, 72, 74, 74, 92, 93, 100, 105, 110, 120, 124]
21-element Vector{Int64}:
   5
   6
   7
   8
  10
  12
  12
  17
  67
  68
   ⋮
  74
  74
  92
  93
 100
 105
 110
 120
 124

I am able to calculate the standard deviation but there does not seem to be a mode function built into Julia like there is with the std() function.

like image 265
logankilpatrick Avatar asked Dec 05 '25 14:12

logankilpatrick


1 Answers

While there is no built in function to do this, the mode function does exist in the StatsBase package:

julia> using StatsBase

julia> mode(a)
12
like image 100
logankilpatrick Avatar answered Dec 07 '25 14:12

logankilpatrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!