Space elements, kappa function and p_Amemiya norm
To use numerical_function_spaces.orlicz_spaces in a project:
- link to interactive notebooks session.
import matplotlib.pyplot as plt
import numpy as np
import numerical_function_spaces.orlicz_spaces as osm
## Points/elements in spaces
Define \(x\) as simple function \(x(t)=\sum_{i=0}^{{len\_t} - 1} a_i \cdot \chi_{A_i}(t)\) as two rows numpy array, where first row is for \(a_i\) and second is for \(\mu(A_i)\)
Define \(x_1(t)=1 \cdot \chi_{[0,2)}(t)\)
len_t = 1
x_1 = np.zeros(shape=(2, len_t))
x_1[1, 0] = 2 # measure of support
x_1[0, 0] = 1 # value
for i in range(0, len_t):
plt.hlines(y=x_1[0, i], xmin=sum([j for j in x_1[1, 0:i]]), xmax=sum([j for j in x_1[1, 0:i + 1]]),
label='$x_1(t)$' if i == 0 else None, )
plt.legend()
plt.show()
plt.close()
Define \(x_2(t)=1 \cdot \chi_{[0,\infty)}(t)\)
# support with infinite measure support
len_t = 1
x_2 = np.zeros(shape=(2, len_t))
x_2[1, 0] = np.inf # measure of support
x_2[0, 0] = 1 # value
plt.plot([0, 5], [x_2[0, 0], x_2[0, 0]], label='$x_2(t)$')
plt.xticks(np.arange(0, 6, step=1), labels=[str(i) if i < 5 else r"$\infty$" for i in range(6)])
plt.legend()
plt.show()
plt.close()
Define \(x_3(t)=1 \cdot \chi_{[0,1)}(t) + \frac{1}{2} \cdot \chi_{[1,3)}(t) +
\frac{1}{3} \cdot \chi_{[3,6)}(t) + \frac{1}{4} \cdot \chi_{[6,10)}(t) + \frac{1}{5} \cdot \chi_{[10,15)}(t)\)
or \(x_3(t) = \sum_{i=0}^{4} \frac{1}{i+1}\cdot \chi_{A_{i}}(t)\) for disjoint \(A_i\) sets with \(\mu(A_i)=i+1\).
len_t = 5 #
x_3 = np.zeros(shape=(2, len_t))
for i in range(len_t):
x_3[1, i] = i + 1 # measure of supports
x_3[0, i] = 1 / (i + 1) # values
for i in range(0, len(x_3[1, :])):
plt.hlines(y=x_3[0, i], xmin=sum([j for j in x_3[1, 0:i]]), xmax=sum([j for j in x_3[1, 0:i + 1]]),
label='$x_3(t)$' if i == 0 else None)
plt.legend()
plt.show()
plt.close()
Define
for disjoint \(A_i\) sets with \(\mu(A_i)=\frac{2\cdot \pi}{1000}\).
t_max = 2 * np.pi
len_t = 1000
x_4 = np.zeros(shape=(2, len_t))
x_4[1, :] = t_max / len_t # measure of supports
for i in range(len_t):
arg = t_max / len_t * i
if arg <= 3:
x_4[0, i] = np.sin(arg) # values
for i in range(0, len_t):
plt.hlines(y=x_4[0, i], xmin=sum([j for j in x_4[1, 0:i]]), xmax=sum([j for j in x_4[1, 0:i + 1]]),
label='$x_4(t)$' if i == 0 else None, )
plt.legend()
plt.show()
plt.close()
plt.plot(np.linspace(0, t_max, len(x_4[1, :])), x_4[0], label='$x_4(t)$')
plt.legend()
plt.show()
plt.close()
Orlicz space
Given any Orlicz function \(\Phi \) we define on \(L_{0}\) the modular \(I_{\Phi } \) by
Then the set
for some \(c>0\) depending on \(x\) is called an Orlicz space. This space is usually equipped with the Luxemburg norm
or with the equivalent one
called the Orlicz norm in the Amemiya form.
Let’s define another class of norms given by the Amemiya formula - norms generated by the function
kappa() function
Let \(x\in L_{\Phi,p}.\) For any \(k \in (0,\infty) \) define function \(\kappa_{p,x}(k)\colon (0,\infty) \rightarrow (0,\infty]\) by formula
def Orlicz_function(u):
return np.where(u <= 1, u, np.inf)
osm.kappa(Orlicz_function, x=x_1, k=1, p_norm=1)
np.float64(3.0)
%%timeit
osm.kappa(Orlicz_function, x=x_1, k=1, p_norm=1)
38.9 μs ± 2.55 μs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
p_Amemiya_norm()
By the \(p-\)Amemiya norm of an element \(x\in L_0\) we mean the norm defined by the formula
It is well known that for \(p=1\) the \(p-\)Amemiya norm coincides with the Orlicz norm and for \(p=\infty\) with the Luxemburg norm [HM00].
osm.p_Amemiya_norm(Orlicz_function, x=x_1, p_norm=1)
np.float64(3.0)
%%timeit
osm.p_Amemiya_norm(Orlicz_function, x=x_1, p_norm=1)
14.1 ms ± 365 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
x = np.array([[1], [3]])
osm.plot_p_norms(Orlicz_function,
x=x,
p_min=1,
p_max=10,
dp=.2,
attach_inf=True,
figsize=(8, 5))
p_Amemiya_norm_with_stars()
Denote \(k^*_{p}(x) = \inf{K_{p}(x)}\) and \(k^{**}_{p}(x) = \sup{K_{p}(x)}\) (with convention \(\inf \emptyset = \infty\)). Then
and of any \(k \in K_{p}(x) \) holds
or (if \(K_{p}(x) = \emptyset\) )
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x_1, p_norm=1)
(np.float64(3.000110995691083),
np.float64(0.9998890166275929),
np.float64(0.9998890166275929))
where first result is \(||x||\), second is \(k_p^*(x)\) and third is \(k_p^{**}(x)\)
%%timeit
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x_1, p_norm=1)
226 ms ± 1.89 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
example of using p_Amemiya_norm_with_stars() function with additional parameters
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x_1, p_norm=1,
k_min=0.9,
k_max=1.1,
len_domain_k=1000, )
# show_progress=True)
(np.float64(3.000000000000011),
np.float64(0.999999999999989),
np.float64(0.999999999999989))
%%timeit
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x_1, p_norm=1, k_min=0.9, k_max=1.1, len_domain_k=1000)
47.9 ms ± 2.39 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
p_Amemiya_norm_with_stars_by_decimal()
Short examples how decimal module works
import decimal as dc # for function using decimal precision
print(dc.getcontext().prec)
print(dc.Decimal(0.2))
print(dc.Decimal('0.2'))
print(dc.Decimal(1) / 5)
print((dc.Decimal(np.sqrt(2))) ** 2)
print((dc.Decimal(2).sqrt()) ** 2)
dc.getcontext().prec = 50
print(dc.Decimal(0.2))
print(dc.Decimal('0.2'))
print(dc.Decimal(1) / 5)
print((dc.Decimal(np.sqrt(2))) ** 2)
print((dc.Decimal(2).sqrt()) ** 2)
28
0.200000000000000011102230246251565404236316680908203125
0.2
0.2
2.000000000000000273432346306
1.999999999999999999999999999
0.200000000000000011102230246251565404236316680908203125
0.2
0.2
2.0000000000000002734323463064769280688491650795723
1.9999999999999999999999999999999999999999999999999
Orlicz function and x must be prepared to decimal form
def Orlicz_function(u):
return np.where(u <= 1, u, dc.Decimal(np.inf))
len_t = 1
x_5 = np.zeros(shape=(2, len_t), dtype=np.dtype('object'))
x_5[1, 0] = dc.Decimal(2) # measure of support
x_5[0, 0] = dc.Decimal(1) # value
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x_5, p_norm=1)
(Decimal('3.1110988766779245797415719566910102134319832100514'),
Decimal('0.90000991'),
Decimal('0.90000991'))
%%timeit
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x_5, p_norm=1)
71.9 ms ± 20.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
example of using p_Amemiya_norm_with_stars_by_decimal() function with additional parameters
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x_5, p_norm=dc.Decimal(1),
k_min=dc.Decimal('0.9'),
k_max=dc.Decimal('1.1'),
len_domain_k=1000, )
# show_progress=True)
(Decimal('3.0000'), Decimal('1.0000'), Decimal('1.0000'))
%%timeit
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x_5, p_norm=dc.Decimal(1),
k_min=dc.Decimal('0.9'),
k_max=dc.Decimal('1.1'),
len_domain_k=1000
)
59.2 ms ± 3.34 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
In the next example there is false \(k_p^{*}(x)\) less than \(k_p^{**}(x)\)
def Orlicz_function(u):
return np.where(u <= 1, u, 2 * u - 1)
x = np.array([[1], [3]])
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x, p_norm=20)
(np.float64(3.0000000000430616),
np.float64(0.64823266269593),
np.float64(0.9999516967001615))
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x, p_norm=dc.Decimal(10))
(Decimal('3.0000145688845555222000227125563249652936039015189'),
Decimal('0.90000991'),
Decimal('0.90000991'))
For better accuracy we may reduce domain by
osm.p_Amemiya_norm_with_stars(Orlicz_function, x=x, p_norm=20,
k_min=0.45,
k_max=1.05)
(np.float64(3.0000000000433653),
np.float64(0.6671999999999962),
np.float64(0.9995999999999903))
osm.p_Amemiya_norm_with_stars_by_decimal(Orlicz_function, x=x, p_norm=dc.Decimal(10),
k_min=dc.Decimal(45) / 100,
k_max=dc.Decimal(105) / 100)
(Decimal('3.0000051008541999106151967575520682494068505040605'),
Decimal('0.9996'),
Decimal('0.9996'))