-1

I'm trying make a code that gets the probability of getting numbers between 0.5 and 0.6 in the interval 0 to 1.

from numpy import *        
import sys        
N = int(sys.argv[1])        
r = random.uniform(0, 1, N)        
M = sum(0.5 <= r, r <= 0.6)        
p= float(M)/N         
print p        

    M = sum(0.5 <= r >= 0.6)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

When i try to run this, i get this valueerror. What is wrong, and what should i do to fix it?

Lujei
  • 1
  • 2

1 Answers1

-2
import system.*        
N = int(system.args[1])        
r = random.uniform(0, 1, N)        
M = sum(0.5 <= r, r <= 0.6)        
p= float(M)/N         
print p        

    M = sum(0.5 <= r >= 0.6)