gandalfthegreat
gandalfthegreat

Reputation: 21

Where is the syntax error in this Julia function

I have the following code:

using Winston

function testConjecGeneral(n,numTrials)
    rangeVec = 2.0
    uppBound = zeros(length(rangeVec), 1)
    count = 1
    for alpha = rangeVec
        uppBound(count) = n*renyi([0.25, 0.5, 0.25], alpha)
        println("Upper bound: $(uppBound(count))")
       count = count+1
    end
end

When I try to load the code, using include("testConjecGeneral.jl") at the command prompt, I get ERROR: syntax: missing comma or ) in argument list while loading /home/ganesh/UROP/YuryJulia/testConjecGeneral.jl, in expression starting on line 3

Can someone help me figure this out?

Upvotes: 1

Views: 1492

Answers (2)

Sig TM
Sig TM

Reputation: 123

I don't think this is a syntax error, but rangeVec is not what you seem to think it is. You assign to rangeVec the Float64 value 2.0 and then you treat rangeVec like an Array, calling length(rangeVec) and looping over alpha = rangeVec. Do you mean for rangeVec to be an Array or a Float64?

Upvotes: 0

Jeremy Wall
Jeremy Wall

Reputation: 25275

uppBound(count) = n*renyi([0.25, 0.5, 0.25], alpha)

doesn't look right to me. zeros returns an array and the right way to reference an array item is with square brackets. As written now it looks like it's trying call a function. Does changing that line to:

uppBound[count] = n*renyi([0.25, 0.5, 0.25], alpha)

fix the problem?

Upvotes: 2

Related Questions