Created
July 12, 2016 18:54
-
-
Save gabraganca/4e720a14b7ab44bdfc7694c13b196522 to your computer and use it in GitHub Desktop.
Exercício sobre série temporal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Exercício sobre série temporal" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Neste exercício, vamos testar o que vimos até agora em aula. Para isso usaremos os seguintes dados:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>t</th>\n", | |
" <th>y0</th>\n", | |
" <th>y1</th>\n", | |
" <th>y2</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>0.0</td>\n", | |
" <td>0.0</td>\n", | |
" <td>0.00</td>\n", | |
" <td>0.06</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>0.2</td>\n", | |
" <td>0.0</td>\n", | |
" <td>-0.01</td>\n", | |
" <td>-0.04</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>0.4</td>\n", | |
" <td>0.0</td>\n", | |
" <td>-0.01</td>\n", | |
" <td>0.09</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>0.6</td>\n", | |
" <td>0.0</td>\n", | |
" <td>-0.01</td>\n", | |
" <td>-0.03</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>0.8</td>\n", | |
" <td>0.0</td>\n", | |
" <td>0.01</td>\n", | |
" <td>-0.02</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" t y0 y1 y2\n", | |
"0 0.0 0.0 0.00 0.06\n", | |
"1 0.2 0.0 -0.01 -0.04\n", | |
"2 0.4 0.0 -0.01 0.09\n", | |
"3 0.6 0.0 -0.01 -0.03\n", | |
"4 0.8 0.0 0.01 -0.02" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import pandas as pd\n", | |
"\n", | |
"data = pd.read_csv('http://pastebin.com/raw/jmSftLRe')\n", | |
"data.columns = ['t', 'y0', 'y1', 'y2']\n", | |
"data.head()" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"A coluna `t` é o tempo em segundos que a media foi feita. A coluna `y0` é a \n", | |
"medida da intensidade do sinal e `y'`e `y2` é o sinal com ruído." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Exercício:\n", | |
"\n", | |
"1. Faça um gráfico para cada série temporal\n", | |
"2. Calcule a frequência máxima que é possível obter para este sinal. \n", | |
" A resposta deve ser em Hertz.\n", | |
"3. Calcule e plote a transformada de Fourier dos sinais.\n", | |
"4. Calcule a densidade espectral (PSD).\n", | |
"\n", | |
"Para os items 3 e 4 talvez seja necessário escrever uma função para calcular o espectro e outra para o PSD.\n", | |
"O pacote `numpy` fornece diversas ferramentas para Transformada de Fourier neste [link][1]. Também é\n", | |
"interessante olhar a biblioetca [`thinkdsp`][2] que utilizamos em aula.\n", | |
"\n", | |
"A equação da PSD é: \n", | |
"\n", | |
"$PSD = |H(f)|^2 + |H(-f)|^2$\n", | |
"\n", | |
"[1]: http://docs.scipy.org/doc/numpy/reference/routines.fft.html\n", | |
"[2]: https://github.com/AllenDowney/ThinkDSP/blob/master/code/thinkdsp.py" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment