Ask Your Question
0

'unable to simplify to float approximation'

asked 10 years ago

aguu gravatar image

updated 10 years ago

kcrisman gravatar image
#example a=0, b=10    
N=10000    
y = [random() for i in range(N)]    
A = []    
a=0    
b=10    
f = a*sin(x)+b*cos(2*x)    
for i in y:    
    f31 = f + normalvariate(0,1)    
    A.append(f31)    
v1 = finance.TimeSeries(A)    
p = v1.plot_histogram(bins=100,color='black', normalize=True)    
p.set_aspect_ratio('automatic')    
p

a it should be a * sin and b * cos
not displayed

What is wrong??

Thanks

Preview: (hide)

Comments

You should give your actual code as is, with proper indentation so that people can help: asin(x) is probably a*sin(x)....but where is a defined? How can your code run without a? Same for bcos(2x). Copy the code into your post and then indent each line by 4 space to get the properly formatted output. It's not clear what statements are in your loop.

dazedANDconfused gravatar imagedazedANDconfused ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

calc314 gravatar image

You are not passing a value into f within the loop. Try the following:

N=10000 
y = [random() for i in range(N)] 
A = [] 
a=0 
b=10 
f = a*sin(x)+b*cos(2*x) 
for i in y: 
    f31 = f(x=i) + normalvariate(0,1) 
    A.append(f31) 
print f31
v1 = finance.TimeSeries(A) 
p = v1.plot_histogram(bins=100,color='black', normalize=True) 
p.set_aspect_ratio('automatic') 
p
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 10 years ago

Seen: 1,476 times

Last updated: Sep 26 '14