Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

calculate area under the curve in python

from __future__ import print_function

import numpy as np
from scipy.integrate import simps
from numpy import trapz


# The y values.  A numpy array is used here,
# but a python list could also be used.
y = np.array([5, 20, 4, 18, 19, 18, 7, 4])

# Compute the area using the composite trapezoidal rule.
area = trapz(y, dx=5)
print("area =", area)

# Compute the area using the composite Simpson's rule.
area = simps(y, dx=5)
print("area =", area)
Comment

PREVIOUS NEXT
Code Example
Python :: create frequency tables in pandas 
Python :: give cell format to condition pandas dataframe 
Python :: re module documentation 
Python :: python string: .lower() 
Python :: list comprehensions 
Python :: hex string to hex number 
Python :: list of dictionary values 
Python :: how to change padding of dbc.col 
Python :: k fold CV with xgboost 
Python :: isprime lambda python 
Python :: python parallelize for loop progressbar 
Python :: fibonacci numbers in reverse order 
Python :: python wheel 
Python :: gtts python 
Python :: Flatten List in Python Using NumPy concatenate 
Python :: Python Program to Find HCF or GCD 
Python :: format json data ipynb 
Python :: legend ax matplotlib 
Python :: unpersist cache pyspark 
Python :: python tkinter plot points 
Python :: # logging 
Python :: python get colorscale 
Python :: python cast number to between 0 and 1 
Python :: python trace code execution 
Python :: dict to list python 
Python :: #add,remove and clear all values on set in python 
Python :: run a shell script from python 
Python :: argparse for Command-Line Interface (CLI) 
Python :: impute data by using groupby and transform 
Python :: sns.savefig 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =