samedi 17 mars 2018

Using random.uniform gives "only size-1 arrays ... "error

I wrote the following code to use these random numbers in the calculation. Running the code gives an error.

import numpy as np
from math import *
from scipy.integrate import quad

sig=10
for i in range (1,10):
    R1=np.random.uniform(0,1,i)
    R2=np.random.uniform(0,1,i)
    def delta():
        d=sig*(sqrt(-2*log(R1))*cos(radians(R2)))
        return d
    print(delta())

it Gives this error:

d=sig*(sqrt(-2*log(R1))*cos(radians(R2))) TypeError: only size-1 arrays can be converted to Python scalars

I appreciate your help.




Aucun commentaire:

Enregistrer un commentaire