<jupyter_start><jupyter_text>Lambdas to parametersHow many dimensions of lambdas do I need to span an $\mathbb{R}^n$ space of unkown parameters?+ One parameter needs only two lambdas, since they span a line+ Two parameters need more than two, but how many? Is three enough?Three lambdas will only span a triangle in $\mathbb{R}^2$ and the points associated with the lambdas will be the vertices, so you can get more convenient spans.If you really need a square, you can get a bigger triangle that covers the square.Four lambdas will give you a square though. Tentative conclusions+ For parameters living in $\mathbb{R}^n$, lambdas with $n+1$ dimensions will span a "triangle" (can I call this a simplex?) in $\mathbb{R}^n$. Appropriate choice of points might be enough to span all the points you're interested in (but maybe also span points that don't make sense for the model)+ For parameters living in $\mathbb{R}^n$, lambdas with an $n+2$ dimensions will span the hypercube you need.<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import sys
sys.path.append("../")
import src


simplex = src.generate_simplex_3dims(80)

d1simplex = simplex[:, 0]
d2simplex = simplex[:, 1]
fig, ax = plt.subplots(1, 1)
ax.plot(d1simplex, d2simplex)
ax.set_title("Span of lambdas", size=18)<jupyter_output><empty_output><jupyter_text>3 lambdas<jupyter_code>α1, α2, α3 = 0.0, 1.0, 0.7
β1, β2, β3 = 0.,   0., 1.

p1 = np.array([α1, β1])[:, np.newaxis]
p2 = np.array([α2, β2])[:, np.newaxis]
p3 = np.array([α3, β3])[:, np.newaxis]
possible_points = p1*simplex[:, 0] + p2*simplex[:, 1] + p3*simplex[:, 2]
xs = possible_points[0, :]
ys = possible_points[1, :]

fig, ax = plt.subplots(1, 1)
ax.plot(xs, ys)

ax.set_xlabel("Possible alphas", size=16)
ax.set_ylabel("Possible betas", size=16)
ax.set_title("Lambda span on alpha, beta space", size=18)<jupyter_output><empty_output><jupyter_text>4 lambdas<jupyter_code>def generate_simplex_4dims(n_per_dim=20):
    xlist = np.linspace(0.0, 1.0, n_per_dim)
    ylist = np.linspace(0.0, 1.0, n_per_dim)
    wlist = np.linspace(0.0, 1.0, n_per_dim)
    zlist = np.linspace(0.0, 1.0, n_per_dim)
    return np.array([[x, y, w, z] for x in xlist for y in ylist
                    for w in wlist for z in zlist
                    if np.allclose(x+y+z+w, 1.0)])

simplex = generate_simplex_4dims(20)


α1, α2, α3, α4 = 0.0, 1.0, 0., 1.
β1, β2, β3, β4 = 0.,   0., 1., 1.

p1 = np.array([α1, β1])[:, np.newaxis]
p2 = np.array([α2, β2])[:, np.newaxis]
p3 = np.array([α3, β3])[:, np.newaxis]
p4 = np.array([α4, β4])[:, np.newaxis]
possible_points = (p1*simplex[:, 0] + p2*simplex[:, 1]
                   + p3*simplex[:, 2] + p4*simplex[:, 3])
xs = possible_points[0, :]
ys = possible_points[1, :]

fig, ax = plt.subplots(1, 1)
ax.plot(xs, ys)

ax.set_xlabel("Possible alphas", size=16)
ax.set_ylabel("Possible betas", size=16)
ax.set_title("Lambda span on alpha, beta space", size=18)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14772344013490726, 'fraction_numerical': 0.04384485666104553, 'mean_word_length': 4.353790613718411, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '199265', 'license': 'Apache-2.0', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1164, 'n_words': 349, 'path': 'Notebooks/estimation/lambdas_to_parameters.ipynb', 'repo_name': 'cdagnino/LearningModels', 'size': '2965'}