\section{Exercises}
\begin{footnotesize} 
\subsection*{Targeted exercises} 

\subsubsection*{Exercises for Section \ref{Finding_local_maxima_using_scipy.signal.find_peaks}} 
\begin{enumerate}\setcounter{enumi}{-1}
	\item  Go to the the book's companion website (\website) and get the following files: `Raman UIO66.csv, `HDI IR.csv', and `AuNP Raman.csv'
	
	Using \lstinline{scipy.signal.find_peaks()} find the peaks in these files.  Experiment with the \lstinline{prominence}, \lstinline{height}, and \lstinline{width} keyword arguments to successfully only find one point per peak in each set of data.
	
\end{enumerate}

\subsubsection*{Exercises for Section \ref{Looping_until_some_conditions_are_met_with_while_loops}} 
\begin{enumerate}\setcounter{enumi}{0}
	\item  Modify the final code from Chapter 5 so that it will keep asking the user for the location of the feature of interest until the user provides a valid response (something that can be converted to an integer and that is present in the $x$-data).

	\item  Create a game that selects a random number between 0 and 10, asks the user guess the number, and tells them if they are correct. Make sure that the user can guess the number until the user is correct. Include functionality so that it runs until you type ``quit.'' Also, ensure that it keeps track of the number of valid guesses.

	
\item  Create a Wordle-like game that selects a random 5-letter word from a list, and then lets the user guess the word, reporting back how many letters were correct, and the position of these letters. 



\end{enumerate}
\subsection*{Comprehensive exercises} 
\begin{enumerate}\setcounter{enumi}{3}
	\item  Often, just finding the highest point in data is not an accurate determination of the center position of a peak in a spectrum or diffraction pattern.  This is especially true if your data has noise that is noticeable.  In this case, it is best to use the peak finding step not as the final step, but as a way to automatically generate a reasonable initial guess for a fitting process.  In the case of a CV, we don't have a great analytical function to fit the full data to, but we can fit just the area around the peak to a function like a Gaussian or parabola to get a better estimate of the true peak.  Try this for the positive going and negative going peaks in the CV data presented in this chapter (file `CVdata.csv' on the book's companion website \website) and see how different it is from the answer you get from \lstinline{find_peaks()}.  Another thing that happens when you fit data is that you get estimates of errors in the parameters, and so consider these as well, when comparing your results. 

	\item  Modify your code above to add more noise to the data by adding normally-distributed random numbers as we did in Section \ref{Generating_noisy_test_data_using_random_numbers_from_numpy.random} and see how the difference between the \lstinline{find_peaks()} result and the fitting result increases.  Keep making the noise larger and comment on how this continues to change.  

	\item  In the final code for Chapter 5, we had to ask the user which wavelength to use to extract the absorbances that we wanted to fit. Modify that code to automatically finds the peak for the initial parameter guess rather than ask the user.  Note that the peak you use for the absorbances is not the highest peak in the spectrum, so you will have to get the correct peak from the list returned by \lstinline{find_peaks()}.

	\item  Return to Exercise 6 from Chapter 8. This exercise dealt with simulating kinetics for an iodide clock. It turns out that the iodide clock only works for a narrow range of reactant concentrations, and the ones supplied there may not be the optimal ones. In this exercise, simulate the iodide clock reaction for different concentrations of $B$. Make the code automatically determine the amplitude of the first oscillation as a function of the concentration of $B$.  Find the concentration for which the amplitude of this oscillation is largest. Plot the concentration of $B$ versus amplitude and then find the peak in this data.

    \item Using the HCl FTIR spectrum from the book's companion website (\website) for this book (HCl-spectrum.csv), find all peaks greater than 15 standard deviation above the baseline.  Automatically determine the average and standard deviation for the baseline by selecting part of the data that clearly has no peaks in it.

	\item  In Exercise 5, you found the peaks in the spectrum, but these points are not necessarily the values we would report for the center of each peak.  We would like to get a more accurate estimate of the peak centers by fitting.  We can use the peaks we found as initial guesses for our fit:

    \begin{itemize}
        \item Create a model that is the sum of 47-ish Gaussians.  Do not hard code the number of peaks; if the number of peaks changes, you will have to change your code.  We want this to work for any number of peaks.  The easiest way to do this is with a for loop.
        
	\item Start with an empty model, and for each iteration, add a \lstinline{GaussianModel} with its own prefix.  At the same time, use \lstinline{make_params} to get initial parameters for the current \lstinline{GaussianModel}, with setting amplitude to be the $y$ value from your peak finder, center to be the $x$ value, and sigma to be something like 0.25.  Hint: use the \lstinline{update()} method for the Parameters class in LMFIT.  
    
	\item Plot your data initial guess to show that your initial guess is not crazy.  
    
	\item Now that you have the model and parameters, you should be ready to fit.  Do the fitting, plot the results of the fit using \lstinline{plotFit()}, and print the fit report.
    
    \end{itemize}


\end{enumerate}
\end{footnotesize} 
