<jupyter_start><jupyter_text>Phase portraitsRelationships between variables may be delayed in time.This makes studying the impact of X on Y challenging.<jupyter_code>import numpy as np
import scipy
import matplotlib.pyplot as plt
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import scipy.stats as stats
def phase_eg(phi=0.0,a_x=1,a_y=1,f_x=1,f_y=1,noise_lvl=0.0):
    t = np.linspace(-10,10,100)
    x = a_x * np.sin(2 * np.pi * f_x * t) + np.random.normal(0,noise_lvl,size=t.shape)
    y = a_y * np.sin(2 * np.pi * f_y * t + phi) + np.random.normal(0,noise_lvl,size=t.shape)
    
    plt.figure()
    plt.subplot(1,2,1)
    plt.plot(t,x)
    plt.plot(t,y)
    plt.subplot(1,2,2)
    plt.scatter(x,y)
    plt.xlim((-2,2))
    plt.ylim((-2,2))
    plt.text(x=0,y=0,s=stats.pearsonr(x,y)[0])
    plt.show()
    
    
interactive(phase_eg,phi=(-np.pi,np.pi,0.01),a_x=(0.0,5.0,1.0),a_y=(0.0,5.0,1.0),f_x=(0.01,10,0.05),f_y=(0.01,10,0.05),noise_lvl=(0.0,1.0,0.01))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18042226487523993, 'fraction_numerical': 0.0671785028790787, 'mean_word_length': 4.189054726368159, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '87891', 'license': 'MIT', 'n_tokens_mistral': 510, 'n_tokens_neox': 488, 'n_words': 72, 'path': 'Notebooks/Phase_portraits.ipynb', 'repo_name': 'virati/ECGTensor', 'size': '1042'}