Std() throwing a methodError

question

#1

I am trying to calculate the standard deviation of the array waiting_Time. But, i get the error “MethodError: objects of type Float64 are not callable”. What am I doing wrong?

Here is my code:

using Distributions

function simulation(l, m, s, n)
    tables = 3n ### the total tables each waiter can serve
    departure = zeros(tables)
    waiting_Time = zeros(0)
    sigma = 1 ### the std of waiting_Time; updated in our while loop
    counter = 0.0

    while (counter <= (1.96(sigma/.01))^2)  ### while our confidence in the mean waiting timem is below 95%
        counter = counter + 1
        u = rand(1)
        arrival = -(1/l)*log.(u[1]) ### generate our customer arrival
        dine = rand(Normal(m,s), 1)  ### generate the dinning time of our arrived customer
        if (arrival >= minimum(departure))
            wait = 0.0
            departure[indmin(departure)] = arrival + dine[1]
            push!(waiting_Time,wait)
        else
            wait = minimum(departure) - arrival
            departure[indmin(departure)] = arrival + wait + dine[1]
            push!(waiting_Time,wait)
        end
        
        if (length(waiting_Time) > tables)
            println(waiting_Time)
            for i in 1:length(waiting_Time)
                println(typeof(waiting_Time[i]))
            end
            sigma = std(waiting_Time)
        end    
    
    end

    results = (mean(waiting_Time))
    return results
end

#2

I suspect you’ve defined a global variable with the same name as a function (such as std = 1.0), as it runs fine for me (after replacing indmax with argmax).


#3

Thank you! I did indeed define a global variable and didn’t clear it.