Home > Net >  How to get a set of numbers between 10^0 and 10^-3
How to get a set of numbers between 10^0 and 10^-3

Time:04-07

I have a list of numbers between 0 and -3 which I got using...

InfectProbs=np.arange(0, (-3-(3/11)), -(3/11)).tolist()

However, I need to get this list of numbers to become 10^(i) where i is a number in the InfectProbs list. I attempted to do..

InfectProbs=(10^(np.arange(0, (-3-(3/11)), -(3/11)))).tolist()

But got the error message of...

ufunc 'bitwise_xor' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

So, how do I get my desired output?

CodePudding user response:

use np.power

np.power(10, InfectProbs)

CodePudding user response:

As the comments say, in python you need to use ** for powers, not ^. So your code should be: InfectProbs=(10**(np.arange(0, (-3-(3/11)), -(3/11)))).tolist()

^ is the bitwise xor operator so this is where your error comes from (bitwise xor doesn't work for floats)

  • Related