# MethodError: no method matching Weights(::Array{Any,1}, ::Float64)

**URL:** <https://discourse.julialang.org/t/methoderror-no-method-matching-weights-array-any-1-float64/62551>\
**Category:** General Usage\
**Tags:** question, array, type\
**Created:** [June 8, 2021, 1:24am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-weights-array-any-1-float64/62551 "2021-06-08T01:24:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebastian\_Mena](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastian_mena/32/22819_2.png) [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Post date:** [June 8, 2021, 1:24am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-weights-array-any-1-float64/62551/1 "2021-06-08T01:24:03Z")

</div>

Hi,

I’m trying to do a sample of a string array, incorporating weights for each of the elements of the array. Specifically,

```julia
new_name_event = sample(events,Weights(dict_betas_choices[string(new_player)][new_zone][string(new_time)][string(new_loc)][string(new_res)]))

>ERROR:
MethodError: no method matching Weights(::Array{Any,1}, ::Float64)
Closest candidates are:
  Weights(!Matched::var"#18#V", ::var"#16#S") where {var"#16#S"<:Real, var"#17#T"<:Real, var"#18#V"<:AbstractArray{var"#17#T",1}} at C:\Users\semed\.julia\packages\StatsBase\ZxhK8\src\weights.jl:13
  Weights(::Any) at C:\Users\semed\.julia\packages\StatsBase\ZxhK8\src\weights.jl:16

Stacktrace:
 [1] Weights(::Array{Any,1}) at C:\Users\semed\.julia\packages\StatsBase\ZxhK8\src\weights.jl:16
 [2] top-level scope at .\In[22]:62
 [3] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

```

Where,

```julia
println(events, typeof(events))
>["Shot", "Duel", "Pass"]Array{String,1}

```

And,

```julia
pesos = dict_betas_choices[string(new_player)][new_zone][string(new_time)][string(new_loc)][string(new_res)]
println(pesos, typeof(pesos), typeof(pesos[1]))
>Any[0.00114591, 0.69774462, 0.30110947] Array{Any,1} Float64

```

**I would appreciate if someone could help me.**
