Wednesday 15 July 2015

python - Integrating using scipy's trapz function -


I am currently trying to integrate a function that includes XY point pairs. Feel free to check once:

I am using Panda to read the file

  data_df = pd.read_csv ("example.csv", sep = " \ T If you look closely, the distance between constant x values ​​is the same, so I can write integral as the following:    P> 
 < Code> integral = integrate.trapz (data_df.values.transpose ()) * data_df.index [1]   

where is integrated is narrow and the data_ df .index is imported from [1] [1] refers to the interval low cost Is refunded: 189274.48501691

If I integrate in the following manner:

  integrate.trapz (data_df.values.transpose (), x = data_df.index)   

A completely different value has returned (5.846689e + 08). Any ideas why this is the case?

Note that the first result is correct It is also returned by MATLAB's trapz function.

You index Examples:

  Integrate options (data_df.values.transpose (), x = data_df.index.values) # [189274.48 501691408]   

This also works if you have your data_df.index to index to ndarray : Integrate

 . (Data_df.values.transpose (), x = data_df.index.view (pd.np.ndarray)) # [189274.48501691408]    

No comments:

Post a Comment