Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python numpy find local minima

import numpy as np
from scipy.signal import argrelextrema
import matplotlib.pyplot as plt

x = np.array([6, 3, 5, 2, 1, 4, 9, 7, 8])
y = np.array([2, 1, 3 ,5 ,3 ,9 ,8, 10, 7])

# sort the data in x and rearrange y accordingly
sortId = np.argsort(x)
x = x[sortId]
y = y[sortId]

# this way the x-axis corresponds to the index of x
plt.plot(x-1, y)
plt.show()
maxm = argrelextrema(y, np.greater)  # (array([1, 3, 6]),)
minm = argrelextrema(y, np.less)  # (array([2, 5, 7]),)
Comment

PREVIOUS NEXT
Code Example
Python :: scrapy itemloader example 
Python :: newspaper pypi 
Python :: You will be passed a file path P and string S on the command line. Output the number of times the string S appears in the file P. 
Python :: django BruteBuster error failed attempts 
Python :: Return a new RDD containing the distinct elements in this RDD. 
Python :: Reduces the elements of this RDD using the specified commutative and associative binary operator 
Python :: str = "This article is written in {}" print (str.format("Python")) 
Python :: Aggregate the elements of each partition, and then the results for all the partitions 
Python :: Applies the f function to all Row 
Python :: cdf empírica python 
Python :: tkinter e.delete(0,END) 
Python :: make large 3d plot in python 
Python :: torch print floating precision 
Python :: discord.py find channel by id 
Python :: cambiar barra de etitulo tkinter 
Python :: python hangman 
Python :: python run subprocess and get output 
Python :: how to add existiong database in dango 
Python :: pandas use map lambda to fillna python 
Python :: AI Challenge 
Python :: %Y-%m-%dT%H:%M:%SZ convert to date time object 
Python :: kloppy, public datasets, Standardized models, football tracking, data science 
Python :: finding the min an max values of grayscale image or frame 
Python :: ignore nil rows value in openpyxl 
Python :: Find python background process id 
Python :: wait_for_message definition 
Python :: what does - none do in python 
Python :: convert_hex_to_ASCII_3.py 
Python :: python map function using lambda function as one of the parameters 
Python :: face sentiment 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =