Alejandro Braun
Alejandro Braun

Reputation: 610

MethodError: no method matching /(::Int64,::Array{Int64,1}) when generating random numbers based on Normal Distribution in Julia

I need to construct a multi-element array of random numbers from a normal distribution (using the "Distributions" package for this). I am using the code below.

[rand(Distributions.Normal(0,a[end]+0.5*(1-b[n])),c,length(b[1,:])*d[n]/c) for n=1:length(b)]

where (I am using random numbers for this example):

a=rand(10)
b=rand(5,32)
c=5
d=collect(1:32)

When I run the code I receive the following error message:

MethodError: no method matching /(::Int64,::Array{Int64,1})

Any ideas on how I can get this to work?

Thank you for your help.

-Alejandro Braun

EDIT: I changed d to collect(1:32). I had made an error when typing the question, I apologize for any confusion this may have caused.

Upvotes: 0

Views: 2651

Answers (1)

Alexander Morley
Alexander Morley

Reputation: 4181

Not 100% sure what you are trying to do but if you force the array size to be integers it will give you something (and if you change the size of your array d)... More info?

a=rand(10)
b=rand(5,32)
c=5
d=rand(5,32);

[rand(Normal(0,a[end]+0.5*(1-b[n])),c,floor(Int,length(b[1,:])*d[n]/c)) for n=1:length(b)]

Upvotes: 2

Related Questions