'How to get a set of numbers between 10^0 and 10^-3

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?



Solution 1:[1]

use np.power

np.power(10, InfectProbs)

Solution 2:[2]

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)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Runinho
Solution 2 Ukulele