AnyaO
AnyaO

Reputation: 21

how do I input number into a NetLogo plot?

I understand that this formula is super complicated to read, but I guess that the mistake that I'm making is super simple. This is a plot for dissimilarity index for segregation for two districts. The error is "missing value on the left"


plot (

mod (((count turtles with [ditrict-in = "high" color = blue])/ count turtles with [ color = blue ]) - 
    ((count turtles with [ditrict-in "high"  color orange])/ count turtles with [ color = orange ])) 
+ mod(((count turtles with [ditrict-in  = "0"  color = blue])/ count turtles with [ color = blue ]) - 
    ((count turtles with [ditrict-in = "0"  color = orange])/ count turtles with [ color = orange ]))

)

Upvotes: 0

Views: 35

Answers (1)

Jasper
Jasper

Reputation: 2780

You have a few errors in your code. The message you're seeing is from the mod operator. You're using mod as if it takes a single argument to the right like mod 10. But if we look at the docs for mod what we find is that mod works like a mathematical operator (+ or -) and takes one argument on the left and one on the right. 15 mod 4 gives 3. So at this point I'm not 100% sure what you want the mod operator to be doing, so I'll leave it to you to adjust how it's used (or maybe you want a different operator).

You also are missing some and operators and = checks in your code, too, though. Sometimes when I'm having trouble tracking down issues, I'll split out complex expressions into their pieces to make it easier to see what's going on. Here is how I split up your code, which still gives the error as you'll need to change the mod portion.

let blueCount (count turtles with [ color = blue ])
let orangeCount (count turtles with [ color = orange ])

let highBlueCount (count turtles with [ditrict-in = "high" and color = blue])
let highOrangeCount (count turtles with [ditrict-in = "high" and color = orange])

let zeroBlueCount (count turtles with [ditrict-in  = "0" and color = blue])
let zeroOrangeCOunt (count turtles with [ditrict-in = "0" and color = orange])

plot (
  mod ((highBlueCount / blueCount) - (highOrangeCount / orangeCount))
  + mod ((zeroBlueCount / blueCount) - (zeroOrangeCOunt / orangeCount))
)

Upvotes: 2

Related Questions