考虑以下想法:我想生成一系列函数f_k,k = 1,...,50并将它们存储在Python字典中.举一个具体的例子,让我们说
f_k(x) = f_{k-1}(x) * sqrt(x)
Run Code Online (Sandbox Code Playgroud)
这只是一个例子,我遇到的问题更复杂,但这对我的问题无关紧要.因为在我的实际问题f_{k-1}是非常嘈杂并且包含舍入误差,我不想f_k直接构建f_{k-1},而是我首先f_{k-1}通过样条近似近似,然后f_k从该样条逼近来确定.奇怪的是,这会导致错误消息表明超出了最大递归深度.以下是代码示例:
import numpy as np
from scipy.interpolate import interp1d
n = 50 # number of functions I want to create
args = np.linspace(1,4,20) # where to evaluate for spline approximation
fdict = dict() # dictionary that stores all the functions
fdict[0] = lambda x: x**2 # the first function
# generate function f_k as follows: First, take function …Run Code Online (Sandbox Code Playgroud) 我的任务很简单:我ts要绘制一个时间序列(2010 年至 2014 年间的欧元瑞士法郎每日汇率)。在该图中,我想通过放大来突出显示某个时间间隔。但是,缩放后的窗口只是空的(见下面的代码)。此外,我在选择放大窗口的 x 范围时遇到了问题,因为我不知道如何将日期正确转换为 matplotlib 的内部整数表示。
在此先感谢您的帮助!
这是我的代码:
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
# Load the time series
ts = pd.read_csv('./Data/EUR_CHF_Exchange_Rates/EUR_CHF_daily.csv',sep=';', parse_dates=['time'], index_col = 'time',decimal=',')
ts = ts['EUR/CHF']
ts = ts.sort_index(ascending=True)
# Plot
fig = plt.figure(figsize=(14,5))
ax = plt.axes()
ts.plot() # ts is my time series
# Label the axis
ax.set_xlabel('')
ax.set_ylabel('EUR/CHF')
#I want to select the x-range for …Run Code Online (Sandbox Code Playgroud)