Re: [Tutor] Fitting data to error function

2015-03-16 Thread Oscar Benjamin
On 16 March 2015 at 22:22, Colin Ross wrote: > > Yes, thank you, they were suppose to both be E_out. Hi Colin, I'm not sure if that means that your problem is fixed or not but I thought I would point something out that helps in fixing this kind of problem. You're using ipython which has an exce

Re: [Tutor] Fitting data to error function

2015-03-16 Thread Danny Yoo
On Mon, Mar 16, 2015 at 3:22 PM, Colin Ross wrote: > Yes, thank you, they were suppose to both be E_out. > > And to answer your last question, I do not. Can you please explain? The article: http://en.wikipedia.org/wiki/Unit_testing may help. As a brief intro: we treat each interesting fun

Re: [Tutor] Fitting data to error function

2015-03-16 Thread Colin Ross
Yes, thank you, they were suppose to both be E_out. And to answer your last question, I do not. Can you please explain? On Mon, Mar 16, 2015 at 7:19 PM, Danny Yoo wrote: > On Mon, Mar 16, 2015 at 2:55 PM, Colin Ross > wrote: > > What I am trying to do is calculate the non-colinear autocorrel

Re: [Tutor] Fitting data to error function

2015-03-16 Thread Danny Yoo
On Mon, Mar 16, 2015 at 2:55 PM, Colin Ross wrote: > What I am trying to do is calculate the non-colinear autocorrelation: > > G(t_d) = \int_{-\infty}^{+\infty} |E(t)|^2 * |E(t - t_d)|^2 dt > > So I need to loop through an array of t_d values (len = 376) and calculate > G(t_d) for as many t values

Re: [Tutor] Fitting data to error function

2015-03-16 Thread Colin Ross
What I am trying to do is calculate the non-colinear autocorrelation: G(t_d) = \int_{-\infty}^{+\infty} |E(t)|^2 * |E(t - t_d)|^2 dt So I need to loop through an array of t_d values (len = 376) and calculate G(t_d) for as many t values as possible to eliminate sampling issues. Colin On Mon, Mar

Re: [Tutor] Fitting data to error function

2015-03-16 Thread Colin Ross
HI Danny, Here is a simplified version: import numpy as np import pylab from pylab import * import matplotlib.pyplot as plt import scipy from scipy.integrate import quad from scipy.fftpack import fft, ifft, fftfreq #

Re: [Tutor] Fitting data to error function

2015-03-15 Thread Danny Yoo
> What does fft expect to receive as an argument? We can read the following: > > > http://docs.scipy.org/doc/scipy/reference/generated/scipy.fftpack.fft.html#scipy.fftpack.fft > > Since fft is erroring out: there's only one possibility: E_(x) is not > providing a value that's appropriate to f

Re: [Tutor] Fitting data to error function

2015-03-15 Thread Danny Yoo
> Thanks for the help! As you mentioned, using scipy.special.erfc was a much > better idea. Below is a copy of my program and the stack trace, showing a > new error. It seems that the first auto correlation works, however the > second fails. At this point, the program is large enough that we nee

Re: [Tutor] Fitting data to error function

2015-03-15 Thread Colin Ross
Hi Danny, Thanks for the help! As you mentioned, using scipy.special.erfc was a much better idea. Below is a copy of my program and the stack trace, showing a new error. It seems that the first auto correlation works, however the second fails. ### # Autocorrelation p

Re: [Tutor] Fitting data to error function

2015-03-13 Thread Danny Yoo
On Fri, Mar 13, 2015 at 11:00 AM, Danny Yoo wrote: >> The error I am recieving is as follows: >> >> TypeError: only length-1 arrays can be converted to Python scalars > > > Hi Colin, > > Do you have a more informative "stack trace" of the entire error? > Providing this will help localize the probl

Re: [Tutor] Fitting data to error function

2015-03-13 Thread Danny Yoo
> The error I am recieving is as follows: > > TypeError: only length-1 arrays can be converted to Python scalars Hi Colin, Do you have a more informative "stack trace" of the entire error? Providing this will help localize the problem. As is, it's clear there's a type error... somewhere... :P

[Tutor] Fitting data to error function

2015-03-13 Thread Colin Ross
Hi all, I am attempting to optimize the parameters I_0 and w_0 in the function (func(x,I_0,w_0) shown below) to fit a set of data. However when I run this code I recieve the error shown below. Any suggestions would be greatly appreciated. Code: import numpy as np import math from math import *