SnakeByte[17] The Metropolis Algorithm

Frame Grab From the movie Metropolis 1927

Who told you to attack the machines, you fools? Without them you’ll all die!!

~ Grot, the Guardian of the Heart Machine

First, as always, Oh Dear Reader, i hope you are safe. There are many unsafe places in and around the world in this current time. Second, this blog is a SnakeByte[] based on something that i knew about but had no idea it was called this by this name.

Third, relative to this, i must confess, Oh, Dear Reader, i have a disease of the bibliomaniac kind. i have an obsession with books and reading. “They” say that belief comes first, followed by admission. There is a Japanese word that translates to having so many books you cannot possibly read them all. This word is tsundoku. From the website (if you click on the word):

“Tsundoku dates from the Meiji era, and derives from a combination of tsunde-oku (to let things pile up) and dokusho (to read books). It can also refer to the stacks themselves. Crucially, it doesn’t carry a pejorative connotation, being more akin to bookworm than an irredeemable slob.”

Thus, while perusing a math-related book site, i came across a monograph entitled “The Metropolis Algorithm: Theory and Examples” by C Douglas Howard [1].

i was intrigued, and because it was 5 bucks (Side note: i always try to buy used and loved books), i decided to throw it into the virtual shopping buggy.

Upon receiving said monograph, i sat down to read it, and i was amazed to find it was closely related to something I was very familiar with from decades ago. This finally brings us to the current SnakeByte[].

The Metropolis Algorithm is a method in computational statistics used to sample from complex probability distributions. It is a type of Markov Chain Monte Carlo (MCMC) algorithm (i had no idea), which relies on Markov Chains to generate a sequence of samples that can approximate a desired distribution, even when direct sampling is complex. Yes, let me say that again – i had no idea. Go ahead LazyWebTM laugh!

So let us start with how the Metropolis Algorithm and how it relates to Markov Chains. (Caveat Emptor: You will need to dig out those statistics books and a little linear algebra.)

Markov Chains Basics

A Markov Chain is a mathematical system that transitions from one state to another in a state space. It has the property that the next state depends only on the current state, not the sequence of states preceding it. This is called the Markov property. The algorithm was introduced by Metropolis et al. (1953) in a Statistical Physics context and was generalized by Hastings (1970). It was considered in the context of image analysis (Geman and Geman, 1984) and data augmentation (Tanner (I’m not related that i know of…) and Wong, 1987). However, its routine use in statistics (especially for Bayesian inference) did not take place until Gelfand and Smith (1990) popularised it. For modern discussions of MCMC, see e.g. Tierney (1994), Smith and Roberts (1993), Gilks et al. (1996), and Roberts and Rosenthal (1998b).

Ergo, the name Metropolis-Hastings algorithm. Once again, i had no idea.

Anyhow,

A Markov Chain can be described by a set of states S and a transition matrix P , where each element P_{ij} represents the probability of transitioning from state i to state j .

Provide The Goal: Sampling from a Probability Distribution \pi(x)

In many applications (e.g., statistical mechanics, Bayesian inference, as mentioned), we are interested in sampling from a complex probability distribution \pi(x). This distribution might be difficult to sample from directly, but we can use a Markov Chain to create a sequence of samples that, after a certain period (called the burn-in period), will approximate \pi(x) .

Ok Now: The Metropolis Algorithm

The Metropolis Algorithm is one of the simplest MCMC algorithms to generate samples from \pi(x). It works by constructing a Markov Chain whose stationary distribution is the desired probability distribution \pi(x) . A stationary distribution is a probability distribution that remains the same over time in a Markov chain. Thus it can describe the long-term behavior of a chain, where the probabilities of being in each state do not change as time passes. (Whatever time is, i digress.)

The key steps of the algorithm are:

Initialization

Start with an initial guess x_0 , a point in the state space. This point can be chosen randomly or based on prior knowledge.

Proposal Step

From the current state x_t , propose a new state x^* using a proposal distribution q(x^*|x_t) , which suggests a candidate for the next state. This proposal distribution can be symmetric (e.g., a normal distribution centered at x_t ) or asymmetric.

Acceptance Probability

Calculate the acceptance probability \alpha for moving from the current state x_t to the proposed state x^* :

    \[\alpha = \min \left(1, \frac{\pi(x^) q(x_t | x^)}{\pi(x_t) q(x^* | x_t)} \right)\]

In the case where the proposal distribution is symmetric (i.e., q(x^|x_t) = q(x_t|x^)), the formula simplifies to:

    \[\alpha = \min \left(1, \frac{\pi(x^*)}{\pi(x_t)} \right)\]

Acceptance or Rejection

Generate a random number u from a uniform distribution U(0, 1)
If u \leq \alpha , accept the proposed state x^* , i.e., set x_{t+1} = x^* .
If u > \alpha , reject the proposed state and remain at the current state, i.e., set x_{t+1} = x_t .

Repeat

Repeat the proposal, acceptance, and rejection steps to generate a Markov Chain of samples.

Convergence and Stationary Distribution:

Over time, as more samples are generated, the Markov Chain converges to a stationary distribution. The stationary distribution is the target distribution \pi(x) , meaning the samples generated by the algorithm will approximate \pi(x) more closely as the number of iterations increases.

Applications:

The Metropolis Algorithm is widely used in various fields such as Bayesian statistics, physics (e.g., in the simulation of physical systems), machine learning, and finance. It is especially useful for high-dimensional problems where direct sampling is computationally expensive or impossible.

Key Features of the Metropolis Algorithm:

  • Simplicity: It’s easy to implement and doesn’t require knowledge of the normalization constant of \pi(x) , which can be difficult to compute.
  • Flexibility: It works with a wide range of proposal distributions, allowing the algorithm to be adapted to different problem contexts.
  • Efficiency: While it can be computationally demanding, the algorithm can provide high-quality approximations to complex distributions with well-chosen proposals and sufficient iterations.

The Metropolis-Hastings Algorithm is a more general version that allows for non-symmetric proposal distributions, expanding the range of problems the algorithm can handle.

Now let us code it up:

i am going to assume the underlying distribution is Gaussian with a time-dependent mean \mu_t, which changes slowly over time. We’ll use a simple time-series analytics setup to sample this distribution using the Metropolis Algorithm and plot the results. Note: When the target distribution is Gaussian (or close to Gaussian), the algorithm can converge more quickly to the true distribution because of the symmetric smooth nature of the normal distribution.

import numpy as np
import matplotlib.pyplot as plt

# Time-dependent mean function (example: sinusoidal pattern)
def mu_t(t):
    return 10 * np.sin(0.1 * t)

# Target distribution: Gaussian with time-varying mean mu_t and fixed variance
def target_distribution(x, t):
    mu = mu_t(t)
    sigma = 1.0  # Assume fixed variance for simplicity
    return np.exp(-0.5 * ((x - mu) / sigma) ** 2)

# Metropolis Algorithm for time-series sampling
def metropolis_sampling(num_samples, initial_x, proposal_std, time_steps):
    samples = np.zeros(num_samples)
    samples[0] = initial_x

    # Iterate over the time steps
    for t in range(1, num_samples):
        # Propose a new state based on the current state
        x_current = samples[t - 1]
        x_proposed = np.random.normal(x_current, proposal_std)

        # Acceptance probability (Metropolis-Hastings step)
        acceptance_ratio = target_distribution(x_proposed, time_steps[t]) / target_distribution(x_current, time_steps[t])
        acceptance_probability = min(1, acceptance_ratio)

        # Accept or reject the proposed sample
        if np.random.rand() < acceptance_probability:
            samples[t] = x_proposed
        else:
            samples[t] = x_current

    return samples

# Parameters
num_samples = 10000  # Total number of samples to generate
initial_x = 0.0      # Initial state
proposal_std = 0.5   # Standard deviation for proposal distribution
time_steps = np.linspace(0, 1000, num_samples)  # Time steps for temporal evolution

# Run the Metropolis Algorithm
samples = metropolis_sampling(num_samples, initial_x, proposal_std, time_steps)

# Plot the time series of samples and the underlying mean function
plt.figure(figsize=(12, 6))

# Plot the samples over time
plt.plot(time_steps, samples, label='Metropolis Samples', alpha=0.7)

# Plot the underlying time-varying mean (true function)
plt.plot(time_steps, mu_t(time_steps), label='True Mean \\mu_t', color='red', linewidth=2)

plt.title("Metropolis Algorithm Sampling with Time-Varying Gaussian Distribution")
plt.xlabel("Time")
plt.ylabel("Sample Value")
plt.legend()
plt.grid(True)
plt.show()

Output of Python Script Figure 1.0

Ok, What’s going on here?

For the Target Distribution:

The function mu_t(t) defines a time-varying mean for the distribution. In this example, it follows a sinusoidal pattern.
The function target_distribution(x, t) models a Gaussian distribution with mean \mu_t and a fixed variance (set to 1.0).


Metropolis Algorithm:

The metropolis_sampling function implements the Metropolis algorithm. It iterates over time, generating samples from the time-varying distribution. The acceptance probability is calculated using the target distribution at each time step.


Proposal Distribution:

A normal distribution centered around the current state with standard deviation proposal_std is used to propose new states.


Temporal Evolution:

The time steps are generated using np.linspace to simulate temporal evolution, which can be used in time-series analytics.


Plot The Results:

The results are plotted, showing the samples generated by the Metropolis algorithm as well as the true underlying mean function \mu_t (in red).

The plot shows the Metropolis samples over time, which should cluster around the time-varying mean \mu_t of the distribution. As time progresses, the samples follow the red curve (the true mean) as time moves on like and arrow in this case.

Now you are probably asking “Hey is there a more pythonic library way to to this?”. Oh Dear Reader i am glad you asked! Yes There Is A Python Library! AFAIC PyMC started it all. Most probably know it as PyMc3 (formerly known as…). There is a great writeup here: History of PyMc.

We are golden age of probabilistic programming.

~ Chris Fonnesbeck (creator of PyMC) 

Lets convert it using PyMC. Steps to Conversion:

  1. Define the probabilistic model using PyMC’s modeling syntax.
  2. Specify the Gaussian likelihood with the time-varying mean \mu_t .
  3. Use PyMC’s built-in Metropolis sampler.
  4. Visualize the results similarly to how we did earlier.
import pymc as pm
import numpy as np
import matplotlib.pyplot as plt

# Time-dependent mean function (example: sinusoidal pattern)
def mu_t(t):
    return 10 * np.sin(0.1 * t)

# Set random seed for reproducibility
np.random.seed(42)

# Number of time points and samples
num_samples = 10000
time_steps = np.linspace(0, 1000, num_samples)

# PyMC model definition
with pm.Model() as model:
    # Prior for the time-varying parameter (mean of Gaussian)
    mu_t_values = mu_t(time_steps)

    # Observational model: Normally distributed samples with time-varying mean and fixed variance
    sigma = 1.0  # Fixed variance
    x = pm.Normal('x', mu=mu_t_values, sigma=sigma, shape=num_samples)

    # Use the Metropolis sampler explicitly
    step = pm.Metropolis()

    # Run MCMC sampling with the Metropolis step
    samples_all = pm.sample(num_samples, tune=1000, step=step, chains=5, return_inferencedata=False)

# Extract one chain's worth of samples for plotting
samples = samples_all['x'][0]  # Taking only the first chain

# Plot the time series of samples and the underlying mean function
plt.figure(figsize=(12, 6))

# Plot the samples over time
plt.plot(time_steps, samples, label='PyMC Metropolis Samples', alpha=0.7)

# Plot the underlying time-varying mean (true function)
plt.plot(time_steps, mu_t(time_steps), label='True Mean \\mu_t', color='red', linewidth=2)

plt.title("PyMC Metropolis Sampling with Time-Varying Gaussian Distribution")
plt.xlabel("Time")
plt.ylabel("Sample Value")
plt.legend()
plt.grid(True)
plt.show()

When you execute this code you will see the following status bar:

It will be a while. Go grab your favorite beverage and take a walk…..

Output of Python Script Figure 1.1

Key Differences from the Previous Code:

PyMC Model Usage Definition:
In PyMC, the model is defined using the pm.Model() context. The x variable is defined as a Normal distribution with the time-varying mean \mu_t . Instead of manually implementing the acceptance probability, PyMC handles this automatically with the specified sampler.

Metropolis Sampler:
PyMC allows us to specify the sampling method. Here, we explicitly use the Metropolis algorithm with pm.Metropolis().

Samples Parameter:
We specify shape=num_samples in the pm.Normal() distribution to indicate that we want a series of samples for each time step.

Plotting:
The resulting plot will show the sampled values using the PyMC Metropolis algorithm compared with the true underlying mean, similar to the earlier approach. Now, samples has the same shape as time_steps (in this case, both with 10,000 elements), allowing you to plot the sample values correctly against the time points; otherwise, the x and y axes would not align.

NOTE: We used this library at one of our previous health startups with great success.

Optimizations herewith include several. There is a default setting in PyMC which is called NUTS.
No need to manually set the number of leapfrog steps. NUTS automatically determines the optimal number of steps for each iteration, preventing inefficient or divergent sampling. NUTS automatically stops the trajectory when it detects that the particle is about to turn back on itself (i.e., when the trajectory “U-turns”). A U-turn means that continuing to move in the same direction would result in redundant exploration of the space and inefficient sampling. When NUTS detects this, it terminates the trajectory early, preventing unnecessary steps. Also the acceptance rates on convergence are higher.

There are several references to this set of algorithms. It truly a case of both mathematical and computational elegance.

Of course you have to know what the name means. They say words have meanings. Then again one cannot know everything.

Until Then,

#iwishyouwater <- Of all places Alabama getting the memo From Helene 2024

𝕋𝕖𝕕 ℂ. 𝕋𝕒𝕟𝕟𝕖𝕣 𝕁𝕣. (@tctjr) / X

Music To Blog By: View From The Magicians Window, The Psychic Circle

References:

[1] The Metropolis Algorithm: Theory and Examples by C Douglas Howard

[2] The Metropolis-Hastings Algorithm: A note by Danielle Navarro

[3] Github code for Sample Based Inference by bashhwu

Entire Metropolis Movie For Your Viewing Pleasure. (AFAIC The most amazing Sci-Fi movie besides BladeRunner)

What Would Nash,Shannon,Turing, Wiener and von Neumann Think?

An image of the folks as mentioned above via the GAN de jour

First, as usual, i trust everyone is safe. Second, I’ve been “thoughting” a good deal about how the world is being eaten by software and, recently, machine learning. i personally have a tough time with using the words artificial intelligence.

What Would Nash, Shannon, Turing, Wiener, and von Neumann Think of Today’s World?

The modern world is a product of the mathematical and scientific brilliance of a handful of intellectual pioneers who happen to be whom i call the Horsemen of The Digital Future. i consider these humans to be my heroes and persons that i aspire to be whereas most have not accomplished one-quarter of the work product the humans have created for humanity. Among these giants are Dr. John Nash, Dr. Claude Shannon, Dr. Alan Turing, Dr. Norbert Wiener, and Dr. John von Neumann. Each of them, in their own way, laid the groundwork for concepts that now define our digital and technological age: game theory, information theory, artificial intelligence, cybernetics, and computing. But what would they think if they could see how their ideas, theories and creations have shaped the 21st century?

A little context.

John Nash: The Game Theorist

John Nash revolutionized economics, mathematics, and strategic decision-making through his groundbreaking work in game theory. His Nash Equilibrium describes how parties, whether they be countries, companies, or individuals, can find optimal strategies in competitive situations. Today, his work influences fields as diverse as economics, politics, and evolutionary biology. NOTE: Computational Consensus Not So Hard; Carbon (Human) Consensus Nigh Impossible.

The Nash equilibrium is the set of degradation strategies 

    \[(E_i^*,E_j^*)\]

 

such that, if both players adopt it, neither player can achieve a higher payoff by changing strategies. Therefore, two rational agents should be expected to pick the Nash equilibrium as their strategy.

If Nash were alive today, he would be amazed at how game theory has permeated decision-making in technology, particularly in algorithms used for machine learning, cryptocurrency trading, and even optimizing social networks. His equilibrium models are at the heart of competitive strategies used by businesses and governments alike. With the rise of AI systems, Nash might ponder the implications of intelligent agents learning to “outplay” human actors and question what ethical boundaries should be set when AI is used in geopolitical or financial arenas.

Claude Shannon: The Father of Information Theory

Claude Shannon’s work on information theory is perhaps the most essential building block of the digital age. His concept of representing and transmitting data efficiently set the stage for everything from telecommunications to the Internet as we know it. Shannon predicted the rise of digital communication and laid the foundations for the compression and encryption algorithms protecting our data. He also is the father of my favorite equation mapping the original entropy equation from thermodynamics to channel capacity:

    \[H=-1/N \sum_{i=1}^{N} P_i\,log_2\,P_i\]

The shear elegance and magnitude is unprecedented. If he were here, Shannon would witness the unprecedented explosion of data, quantities, and speeds far beyond what was conceivable in his era. The Internet of Things (IoT), big data analytics, 5G/6G networks, and quantum computing are evolutions directly related to his early ideas. He might also be interested in cybersecurity challenges, where information theory is critical in protecting global communications. Shannon would likely marvel at the sheer volume of information we produce yet be cautious of the potential misuse and the ethical quandaries regarding privacy, surveillance, and data ownership.

Alan Turing: The Architect of Artificial Intelligence

Alan Turing’s vision of machines capable of performing any conceivable task laid the foundation for modern computing and artificial intelligence. His Turing Machine is still a core concept in the theory of computation, and his famous Turing Test continues to be a benchmark in determining machine intelligence.

In today’s world, Turing would see his dream of intelligent machines realized—and then some. From self-driving cars to voice assistants like Siri and Alexa, AI systems are increasingly mimicking human cognition human capabilities in specific tasks like data analysis, pattern recognition, and simple problem-solving. While Turing would likely be excited by this progress, he might also wrestle with the ethical dilemmas arising from AI, such as autonomy, job displacement, and the dangers of creating highly autonomous AI systems as well as calling bluff on the fact that LLM systems do not reason in the same manner as human cognition on basing the results on probabilistic convex optimizations. His work on breaking the Enigma code might inspire him to delve into modern cryptography and cybersecurity challenges as well. His reaction-diffusion model called Turings Metapmorphsis equation, is foundational in explaining biological systems:

Turing’s reaction-diffusion system is typically written as a system of partial differential equations (PDEs):

    \[\frac{\partial u}{\partial t} &= D_u \nabla^2 u + f(u, v),\]


    \[\frac{\partial v}{\partial t} &= D_v \nabla^2 v + g(u, v),\]

where:

    \[\begin{itemize}\item $u$ and $v$ are concentrations of two chemical substances (morphogens),\item $D_u$ and $D_v$ are diffusion coefficients for $u$ and $v$,\item $\nabla^2$ is the Laplacian operator, representing spatial diffusion,\item $f(u, v)$ and $g(u, v)$ are reaction terms representing the interaction between $u$ and $v$.\end{itemize}\]

In addition to this, his contributions to cryptography and game theory alone are infathomable.
In his famous paper, Computing Machinery and Intelligence,” Turing posed the question, “Can machines think?” He proposed the Turing Test as a way to assess whether a machine can exhibit intelligent behavior indistinguishable from a human. This test has been a benchmark in AI for evaluating a machine’s ability to imitate human intelligence.

Given the recent advances made with large language models, I believe he would find it amusing, not that they think or reason.

Norbert Wiener: The Father of Cybernetics

Norbert Wiener’s theory of cybernetics explored the interplay between humans, machines, and systems, particularly how systems could regulate themselves through feedback loops. His ideas greatly influenced robotics, automation, and artificial intelligence. He wrote the books “Cybernetics” and “The Human Use of Humans”. During World War II, his work on the automatic aiming and firing of anti-aircraft guns caused Wiener to investigate information theory independently of Claude Shannon and to invent the Wiener filter. (The now-standard practice of modeling an information source as a random process—in other words, as a variety of noise—is due to Wiener.) Initially, his anti-aircraft work led him to write, with Arturo Rosenblueth and Julian Bigelow, the 1943 article ‘Behavior, Purpose and Teleology. He was also a complete pacifist. What was said about those who can hold two opposing views?

If Wiener were alive today, he would be fascinated by the rise of autonomous systems, from drones to self-regulated automated software, and the increasing role of cybernetic organisms (cyborgs) through advancements in bioengineering and robotic prosthetics. He, I would think, would also be amazed that we could do real-time frequency domain filtering based on his theories. However, Wiener’s warnings about unchecked automation and the need for human control over machines would likely be louder today. He might be deeply concerned about the potential for AI-driven systems to exacerbate inequalities or even spiral out of control without sufficient ethical oversight. The interaction between humans and machines in fields like healthcare, where cybernetics merges with biotechnology, would also be a keen point of interest for him.

John von Neumann: The Architect of Modern Computing

John von Neumann’s contributions span so many disciplines that it’s difficult to pinpoint just one. He’s perhaps most famous for his von Neumann architecture, the foundation of most modern computer systems, and his contributions to quantum mechanics and game theory. His visionary thinking on self-replicating machines even predated discussions of nanotechnology.

Von Neumann would likely be astounded by the ubiquity and power of modern computers. His architectural design is the backbone of nearly every device we use today, from smartphones to supercomputers. He would also find significant developments in quantum computing, aligning with his quantum mechanics work. As someone who worked on the Manhattan Project (also Opphenhiemer), von Neumann might also reflect on the dual-use nature of technology—the incredible potential of AI, nuclear power, and autonomous weapons to both benefit and harm humanity. His early concerns about the potential for mutual destruction could be echoed in today’s discussions on AI governance and existential risks.

What Would They Think Overall?

Together, these visionaries would undoubtedly marvel at how their individual contributions have woven into the very fabric of today’s society. The rapid advancements in AI, data transmission, computing power, and autonomous systems would be thrilling, but they might also feel a collective sense of responsibility to ask:

Where do we go from here?

Once again Oh Dear Reader You pre-empt me….

A colleague sent me this paper, which was the impetus for this blog:

My synopsis of said paper:


The Tensor as an Informational Resource” discusses the mathematical and computational importance of tensors as resources, particularly in quantum mechanics, AI, and computational complexity. The authors propose new preorders for comparing tensors and explore the notion of tensor rank and transformations, which generalize key problems in these fields. This paper is vital for understanding how the foundational work of Nash, Shannon, Turing, Wiener, and von Neumann has evolved into modern AI and quantum computing. Tensors offer a new frontier in scientific discovery, building on their theories and pushing the boundaries of computational efficiency, information processing, and artificial intelligence. It’s an extension of their legacy, providing a mathematical framework that could revolutionize our interaction with quantum information and complex systems. Fundamental to systems that appear to learn where the information-theoretic transforms are the very rosetta stone of how we perceive the world through perceptual filters of reality.

This shows the continuing relevance in ALL their ideas in today’s rapidly advancing AI and fluid computing technological landscape.

They might question whether today’s technology has outpaced ethical considerations and whether the systems they helped build are being used for the betterment of all humanity. Surveillance, privacy, inequality, and autonomous warfare would likely weigh heavily on their minds. Yet, their boundless curiosity and intellectual rigor would inspire them to continue pushing the boundaries of what’s possible, always seeking new answers to the timeless question of how to create the future we want and live better, more enlightened lives through science and technology.

Their legacy lives on, but so does their challenge to us: to use the tools they gave us wisely for the greater good of all.

Or would they be dismayed that we use all of this technology to make a powerpoint to save time so we can watch tik tok all day?

Until Then,

#iwishyouwater <- click and see folks who got the memo

𝕋𝕖𝕕 ℂ. 𝕋𝕒𝕟𝕟𝕖𝕣 𝕁𝕣. (@tctjr) / X

Music To blog by: Bach: Mass in B Minor, BWV 232. By far my favorite composer. The John Eliot Gardiner and Monterverdi Choir version circa 1985 is astounding.

SnakeByte[16]: Enhancing Your Code Analysis with pyastgrep

Dalle 3’s idea of an Abstract Syntax Tree in R^3 space

If you would know strength and patience, welcome the company of trees.

~ Hal Borland

First, I hope everyone is safe. Second, I am changing my usual SnakeByte [] stance process. I am pulling this from a website I ran across. I saw the library mentioned, so I decided to pull from the LazyWebTM instead of the usual snake-based tomes I have in my library.

As a Python developer, understanding and navigating your codebase efficiently is crucial, especially as it grows in size and complexity. Trust me, it will, as does Entropy. Traditional search tools like grep or IDE-based search functionalities can be helpful, but they cannot often “‘understand” the structure of Python code – sans some of the Co-Pilot developments. (I’m using understand here *very* loosely Oh Dear Reader).

This is where pyastgrep it comes into play, offering a powerful way to search and analyze your Python codebase using Abstract Syntax Trees (ASTs). While going into the theory of ASTs is tl;dr for a SnakeByte[] , and there appears to be some ambiguity on the history and definition of Who actually invented ASTs, i have placed some references at the end of the blog for your reading pleasure, Oh Dear Reader. In parlance, if you have ever worked on compilers or core embedded systems, Abstract Syntax Trees are data structures widely used in compilers and the like to represent the structure of program code. An AST is usually the result of the syntax analysis phase of a compiler. It often serves as an intermediate representation of the program through several stages that the compiler requires and has a strong impact on the final output of the compiler.

So what is the Python Library that you speak of? i’m Glad you asked.

What is pyastgrep?

pyastgrep is a command-line tool designed to search Python codebases with an understanding of Python’s syntax and structure. Unlike traditional text-based search tools, pyastgrep it leverages the AST, allowing you to search for specific syntactic constructs rather than just raw text. This makes it an invaluable tool for code refactoring, auditing, and general code analysis.

Why Use pyastgrep?

Here are a few scenarios where pyastgrep excels:

  1. Refactoring: Identify all instances of a particular pattern, such as function definitions, class instantiations, or specific argument names.
  2. Code Auditing: Find usages of deprecated functions, unsafe code patterns, or adherence to coding standards.
  3. Learning: Explore and understand unfamiliar codebases by searching for specific constructs.

I have a mantra: Reduce, Refactor, and Reuse. Please raise your hand of y’all need to refactor your code? (C’mon now no one is watching… tell the truth…). See if it is possible to reduce the code footprint, refactor the code into more optimized transforms, and then let others reuse it across the enterprise.

Getting Started with pyastgrep

Let’s explore some practical examples of using pyastgrep to enhance your code analysis workflow.

Installing pyastgrep

Before we dive into how to use pyastgrep, let’s get it installed. You can install pyastgrep via pip:

(base)tcjr% pip install pyastgrep #dont actually type the tctjr part that is my virtualenv

Example 1: Finding Function Definitions

Suppose you want to find all function definitions in your codebase. With pyastgrep, this is straightforward:

pyastgrep 'FunctionDef'

This command searches for all function definitions (FunctionDef) in your codebase, providing a list of files and line numbers where these definitions occur. Ok pretty basic string search.

Example 2: Searching for Specific Argument Names

Imagine you need to find all functions that take an argument named config. This is how you can do it:

pyastgrep 'arg(arg=config)'

This query searches for function arguments named config, helping you quickly locate where configuration arguments are being used.

Example 3: Finding Class Instantiations

To find all instances where a particular class, say MyClass, is instantiated, you can use:

pyastgrep 'Call(func=Name(id=MyClass))'

This command searches for instantiations of MyClass, making it easier to track how and where specific classes are utilized in your project.

Advanced Usage of pyastgrep

For more complex queries, you can combine multiple AST nodes. For instance, to find all print statements in your code, you might use:

pyastgrep 'Call(func=Name(id=print))'

This command finds all calls to the print function. You can also use more detailed queries to find nested structures or specific code patterns.

Integrating pyastgrep into Your Workflow

Integrating pyastgrep into your development workflow can greatly enhance your ability to analyze and maintain your code. Here are a few tips:

  1. Pre-commit Hooks: Use pyastgrep in pre-commit hooks to enforce coding standards or check for deprecated patterns.
  2. Code Reviews: Employ pyastgrep during code reviews to quickly identify and discuss specific code constructs.
  3. Documentation: Generate documentation or code summaries by extracting specific patterns or structures from your codebase.

Example Script

To get you started, here’s a simple Python script using pyastgrep to search for all function definitions in a directory:

import os
from subprocess import run

def search_function_definitions(directory):
result = run(['pyastgrep', 'FunctionDef', directory], capture_output=True, text=True)
print(result.stdout)

if __name__ == "__main__":
directory = "path/to/your/codebase" #yes this is not optimal folks just an example.
search_function_definitions(directory)

Replace "path/to/your/codebase" with the actual path to your Python codebase, and run the script to see pyastgrep in action.

Conclusion

pyastgrep is a powerful tool that brings the capabilities of AST-based searching to your fingertips. Understanding and leveraging the syntax and structure of your Python code, pyastgrep allows for more precise and meaningful code searches. Whether you’re refactoring, auditing, or simply exploring code, pyastgrep it can significantly enhance your productivity and code quality. This is a great direct addition to your arsenal. Hope it helps and i hope you found this interesting.

Until Then,

#iwishyouwater <- The best of the best at Day1 Tahiti Pro presented by Outerknown 2024

𝕋𝕖𝕕 ℂ. 𝕋𝕒𝕟𝕟𝕖𝕣 𝕁𝕣. (@tctjr) / X

MUZAK to Blog By: SweetLeaf: A Stoner Rock Salute to Black Sabbath. While i do not really like bands that do covers, this is very well done. For other references to the Best Band In Existence ( Black Sabbath) i also refer you to Nativity in Black Volumes 1&2.

References:

[1] Basics Of AST

[2] The person who made pyastgrep

[3] Wikipedia page on AST

SnakeByte [15]: Debugging With pdb In The Trenches

Dalle3 idea of debugging code from the view of the code itself.

If debugging is the process of removing software bugs, then programming must be the process of putting them in.

~ Edsger W. Dijkstra

Image Explanation: Above is the image showing the perspective of debugging code from the viewpoint of the code itself. The scene features lines of code on a large monitor, with sections highlighted to indicate errors. In the foreground, anthropomorphic code characters are working to fix these highlighted sections, set against a digital landscape of code lines forming a cityscape.

So meta and canonical.

In any event Dear Readers, it is Wednesday! That means as usual everyday is Wednesday in a startup, you actually work at a company where you enjoy the work or it is SnakeByte [ ] time!

i haven’t written a SnakeByte is quite some time. Also, recently, in a previous blog, I mentioned that I had a little oversite on my part, and my blog went down. i didn’t have alerting turned on ye ole AWS and those gosh darn binlogs where not deleting in ye ole WordPress as such we took the proverbial digger into downtime land. i re-provisioned with an additional sizing of the volume and changed the disc from magnetic to SSD, turned on alerts and we are back in business.

So per my usual routine i grab one of the python books from the book shelf randomly open then read about command or commands and attempt to write a blog as fast as possible.

Today’s random command from Python In A Nutshell is pdb, the Python Debugger. i’ll walk you through the basic of using pdb to debug your Python code, which, as it turns out is better than a bunch of print().

Getting Started with pdb

To leverage pdb, import it in your Python script. You can then set breakpoints manually with pdb.set_trace(). When the execution hits this line, the script pauses, allowing you to engage in an interactive debugging session.

Consider this straightforward example:

# example.py
import pdb

def add(a, b):
result = a + b
return result

def main():
x = 10
y = 20
pdb.set_trace() # Breakpoint set here
total = add(x, y)
print(f'Total: {total}')

if __name__ == '__main__':
main()

Here, we have a simple add function and a main function that invokes add. The pdb.set_trace() in the main function sets a breakpoint where the debugger will halt execution.

Running the Code with pdb

Execute the script from the command line to initiate the debugger:

python example.py

When the execution reaches pdb.set_trace(), you will see the debugger prompt ((Pdb)):

> /path/to/example.py(11)main()
-> total = add(x, y)
(Pdb)

Essential pdb Commands

Once at the debugger prompt, several commands can help you navigate and inspect your code. Key commands include:

  • l (list): Displays the surrounding source code.
  • n (next): Moves to the next line within the same function.
  • s (step): Steps into the next function call.
  • c (continue): Resumes execution until the next breakpoint.
  • p (print): Evaluates and prints an expression.
  • q (quit): Exits the debugger and terminates the program.

Let’s walk through using these commands in our example:

List the surrounding code:

Pdb) 1
  6         def main():
  7             x = 10
  8             y = 20
  9             pdb.set_trace()  # Breakpoint here
 10  ->         total = add(x, y)
 11             print(f'Total: {total}')
 12     
 13         if __name__ == '__main__':
 14             main()

Print variable values:

(Pdb) p x
10
(Pdb) p y
20

Step into the add function:

(Pdb) s
> /path/to/example.py(3)add()
-> result = a + b
(Pdb)

Inspect parameters a and b:

(Pdb) p a
10
(Pdb) p b
20

Continue execution:

(Pdb) c
Total: 30

Advanced pdb Features

For more nuanced debugging needs, pdb offers advanced capabilities:

Conditional Breakpoints: Trigger breakpoints based on specific conditions:

if x == 10:
    pdb.set_trace()

Post-Mortem Debugging: Analyze code after an exception occurs:

import pdb

def faulty_function():
    return 1 / 0

try:
    faulty_function()
except ZeroDivisionError:
    pdb.post_mortem() #they need to add a pre-mortem what can go wrong will...

Command Line Invocation: Run a script under pdb control directly from the command line like the first simple example:

python -m pdb example.py

Effective debugging is crucial for building robust and maintainable software. pdb provides a powerful, interactive way to understand and fix your Python code. By mastering pdb, you can streamline your debugging process, saving time and enhancing your productivity.

pdb, the Python Debugger, is an indispensable tool for any developer. It allows us to set breakpoints, step through code, inspect variables, and evaluate expressions on the fly. This level of control is crucial for diagnosing and resolving issues efficiently. While i used cli in the examples it also works with Jupyter Notebooks.

We’ve covered the basics and advanced features of pdb, equipping you with the knowledge to tackle even the most challenging bugs. As you integrate these techniques into your workflow, you’ll find that debugging becomes less of a chore and more of a strategic advantage unless you create a perfect design which is no code at all!

Until then,

#iwishyouwater <- La Vaca Gigante Wipeouts 2024

𝕋𝕖𝕕 ℂ. 𝕋𝕒𝕟𝕟𝕖𝕣 𝕁𝕣. (@tctjr)

Muzak to Blog By: Apostrophe (‘) by Frank Zappa. i was part of something called the Zappa Ensemble in graduate school as one of the engineers. The musicians where amazing. Apostrohe (‘)is an amazing album. The solo on Uncle Remus is just astounding well as is most of his solos.

Review: Flow Research Collective

Bonafide in The Art of The Flow

I will persist until I succeed.

I was not delivered unto this world in defeat, nor does failure course in my veins. I am not a sheep waiting to be prodded by my shepherd. I am a lion and I refuse to talk, to walk, to sleep with the sheep. I will hear not those who weep and complain, for their disease is contagious. Let them join the sheep. The slaughterhouse of failure is not my destiny.

I will persist until I succeed.

OG Mandino

First as always Dear Readers i trust everyone is safe. Second, whilst i have not written i in a while that does not mean i have not been “thoughting” of things to write about for You Oh Dear Reader. Third, software is hard and there was a glitch in the matrix and my site was down for a bit.

Starting last year on April 24th, 2023, with Matthew McConaughey’s “Art Of Living” worldwide class that was, in fact, a precursor to a class with him and Tony Robbins dedicated to looking into yourself and figuring out exactly what you want – sound familiar? However, this was not for me to use for others but for me – period. I knew that this was a stepping stone to the class that I was going to write about, a class given by the Flow Research Collective. After i took “The Art of Living” class i knew a Flow Research Collective Class was starting over “The Holidays” in December 2023. Knowing full well that i would be in the throes of work at my new gig and also “The Holidays”, i told myself just like i tell others: “The best time to plant a tree is yesterday. The best time to plant a tree is Now.” So i registered for the 9 week class. At the time, i was very familiar with Stephen Kotler, the founder of FRC given i had read many of his books:

  1. Abundance: The Future Is Better Than You Think” (2012) – Co-authored with Peter H. Diamandis
  2. Bold: How to Go Big, Create Wealth and Impact the World” (2015) – Co-authored with Peter H. Diamandis
  3. The Rise of Superman: Decoding the Science of Ultimate Human Performance” (2014)
  4. Tomorrowland: Our Journey from Science Fiction to Science Fact” (2015) – Co-authored with Peter H. Diamandis
  5. Stealing Fire: How Silicon Valley, the Navy SEALs, and Maverick Scientists Are Revolutionizing the Way We Live and Work” (2017) – Co-authored with Jamie Wheal
  6. The Future is Faster Than You Think: How Converging Technologies Are Transforming Business, Industries, and Our Lives” (2020) – Co-authored with Peter H. Diamandis
  7. The Art of The Impossible: A Peak Performance Primer” (2021)
  8. Gnar Country: Growing Old and Staying Rad” (2023)

I have read all of the ones concerning human performance.

Why did I push this off till now? Well, denial is an amazing psychological force.

In the realm of human performance, few concepts hold as much promise and intrigue as the state of flow. Coined by psychologist Mihaly Csikszentmihalyi, flow refers to a mental state of complete immersion and energized focus in an activity, where individuals experience profound enjoyment and peak performance. Flow is not just a fleeting moment of productivity; it’s a state where time seems to warp, self-vanishes, and optimal performance becomes effortless. Harnessing the power of flow can unlock human potential in remarkable ways.

The Flow Research Collective (FRC) is an organization that has made it its mission to understand, master, and utilize the principles of flow to help individuals and organizations achieve peak performance consistently. Founded by Steven Kotler, a prolific author and leading expert on the subject, and Rian Doris, the CEO, the FRC has journeyed from humble beginnings to becoming a powerhouse in the field of human performance enhancement.

Origins: The Spark of Inspiration

The story of the Flow Research Collective begins with Steven Kotler’s own personal journey. Struggling with Lyme disease, Kotler found himself facing physical and cognitive limitations that profoundly impacted his life and work. Determined to overcome these challenges, he delved deep into the science of human performance, stumbling upon the concept of flow.

Kotler’s fascination with flow led him to explore its intricacies, drawing from neuroscience, psychology, and various research fields. As he began understanding flow mechanics and its transformative potential, he realized the need to share this knowledge with the world. Thus, the seeds of the Flow Research Collective were planted.

Building Momentum: From Vision to Reality

Armed with a vision to unlock human potential through flow, Kotler embarked on a journey to build the Flow Research Collective from the ground up. Collaborating with like-minded individuals and experts in various domains, he set out to create a platform that would serve as a hub for research, education, and practical flow applications.

The early days were marked by relentless dedication and a commitment to excellence. Kotler and his team immersed themselves in the latest scientific literature, conducted experiments, and engaged with practitioners from diverse fields to gain insights into the nature of flow. Through trial and error, they refined their methodologies, developing frameworks and tools to help individuals cultivate flow and achieve peak performance.

Cultivating a Community: The Power of Connection

Central to the Flow Research Collective’s success is its ability to foster a vibrant and engaged community of flow enthusiasts. Through workshops, seminars, online courses, and collaborative projects, the FRC has brought together individuals from all walks of life who share a common passion for unlocking human potential.

The community’s collective nature has been instrumental in accelerating learning and innovation. By sharing experiences, exchanging ideas, and supporting one another, members of the FRC have been able to tap into the group’s collective wisdom, amplifying their individual efforts and achievements.

From Zero to Dangerous: Mastering the Art of Flow

The term “zero to dangerous” (ZTD) encapsulates the ultimate goal of the Flow Research Collective: to empower individuals to transition from a state of inexperience or mediocrity to one of mastery and excellence. Drawing inspiration from the language of fighter pilots who aim to go from zero to dangerous in their skill level, the FRC seeks to help individuals reach a level of proficiency where they can navigate life’s challenges with confidence and grace.

Achieving this level of mastery requires more than just theoretical knowledge; it demands practice, discipline, and a willingness to push beyond one’s comfort zone. Through a combination of cutting-edge research, immersive training experiences, and personalized coaching, the FRC equips individuals with the tools and techniques they need to harness the power of flow and unleash their full potential.

Looking Ahead: A Future of Possibilities

As the Flow Research Collective grows and evolves, the possibilities are endless. From helping athletes and artists achieve peak performance to revolutionizing the way businesses operate, the principles of flow have the potential to transform every aspect of human endeavor.

With advances in technology, neuroscience, and our understanding of human psychology, the FRC is poised to unlock new frontiers in human performance enhancement. By staying true to its mission of understanding, mastering, and leveraging the power of flow, the Flow Research Collective is paving the way for a future where individuals and organizations can thrive like never before.

What is FLOW?

Specifically, “Flow” occurs when individuals are fully immersed in a task, experiencing deep focus, high levels of enjoyment, and a sense of timelessness. In this state, individuals often report feeling in control, highly motivated, and completely absorbed in the activity at hand. Flow typically occurs when the challenge of a task matches an individual’s skill level, leading to a harmonious balance that encourages peak performance and creativity. Achieving flow can enhance productivity, increased well-being, and a sense of fulfillment. The class mentioned herewith trains you to optimize and balance the release of neurochemicals.

In the state of flow, several neurotransmitters and neurochemicals are released, contributing to the heightened sense of focus, motivation, and well-being experienced by individuals. Some of the key neurochemicals involved include:

  1. Dopamine: Often referred to as the “feel-good” neurotransmitter, dopamine is associated with motivation, reward, and pleasure. During flow, dopamine levels increase, reinforcing the behavior and enhancing the feeling of satisfaction associated with being in the zone.
  2. Endorphins: Endorphins are natural painkillers produced by the body and contribute to feelings of euphoria and well-being. In flow, endorphin levels rise, potentially reducing the perception of discomfort or fatigue and promoting a sense of exhilaration.
  3. Serotonin: Serotonin affects mood regulation, emotional balance, and overall well-being. Increased serotonin levels during flow can contribute to a sense of calmness, contentment, and happiness.
  4. Anandamide: Anandamide is a neurotransmitter associated with bliss, joy, and relaxation. Elevated levels of anandamide during flow may enhance individuals’ overall sense of well-being and pleasure.
  5. Norepinephrine: Norepinephrine plays a role in attention, focus, and arousal. In flow, norepinephrine levels increase, heightening alertness, enhancing concentration, and promoting a state of intense focus on the task at hand.

So this class was much more than just a recipe for flow. It was mapping what is called your Maximally Transformative Process.

The Maximally Transformative process (MTP) refers to a structured approach or methodology designed to help individuals achieve peak performance states such as flow more consistently and experience significant personal and professional growth.

This process typically involves a combination of research-based strategies, tools, and techniques derived from fields such as neuroscience, psychology, and peak performance coaching. It aims to help individuals identify and leverage their strengths, optimize their environment for flow, and cultivate the necessary mindset and skills to enter flow states more reliably.

The maximally transformative process often includes elements such as:

  1. Flow Triggers: Identifying specific triggers or conditions that reliably induce flow states for an individual, such as clear goals, immediate feedback, and a balance between challenge and skill.
  2. Flow Cycles: Understanding the stages of the flow cycle (struggle, release, flow, and recovery) and learning to navigate through them effectively to maximize performance and growth.
  3. Psychological Skills Training: Developing mental skills such as focus, resilience, and mindfulness to enhance the ability to enter and sustain flow states under varying conditions.
  4. Environmental Optimization: Structuring one’s physical and social environment to minimize distractions, maximize motivation, and promote optimal conditions for flow.
  5. Feedback and Reflection: Cultivating a practice of self-awareness, reflection, and continuous learning to refine performance and maintain momentum over time.

The actual class was related to achieving this process. As I mentioned earlier, there was a registration process. Upon registration, one is contacted by a representative from RFC. The person who contacted me for a qualifying interview was Maleke Fuentes. He was amazing during the qualification process. He discussed his background and how he became involved with FRC. He was very forthcoming, and I directly asked if FRC accepted all applicants. He flatly stated – NO.

Once you are accepted, you are dropped into both virtual and live classes. Relative to this, the class operationally consists of a pod that meets twice weekly, and then you have 1:1 time with the respective coach.

My coach was the amazing Marcus Lefton. He was very forthcoming and extremely insightful. He openly shared his amazing background and was very candid in pod and 1:1 classes. Given his background, he led by example and proverbially “at his own dog food,” as they say in the software space. He could go vertically deep and horizontally in recommending operationally, physically, and psychologically, as the FRC is extremely life-changing.

The class is broken into deeper steps into the rabbit hole. As one would expect, this can become extremely self-referential, which is the goal of the class.

For instance, there is a class where we are given 90 seconds to write down at least 15 things YOU do well. I, in full transparency, fully failed. I got to about two, maybe three. In one of Stephen Kotler’s books, he stated to write down 25 things you do well. It is difficult. Further, the suggestions and they are brutal in many cases are counter-intuitive, and they work.

Near the end of the class, we had a 1:1, during which we really drilled down into “my” Maximally Transformative Process. He was extremely candid and stated, “Ted, you are usually the shaman and or the genie that grants everyone else’s wishes. Now the genie is standing before you, asking you what you truly want?” i was very taken back as i don’t think in these terms. i just amplify folks at best.

i have not been the same since. Thank you Marcus.

In short, go look into the class. While it is not cheap, how much is your mental and physical health really worth?

As a wise man once said, “People who don’t need self-help books read them, and people who need them don’t read them.” This is usually the case here as all the folks in the pod i was included in were very performant.

The journey of the Flow Research Collective from Zero To Dangerous is a testament to the transformative power of flow. By unlocking the secrets of peak performance and sharing them with the world, the FRC is helping individuals tap into their innate potential and achieve extraordinary feats. One thing is clear as we look to the future: the flow revolution is just beginning, and the possibilities are limitless.

Personally, I can’t say enough about the class and people. Here is the link to the class -> Flow Research Class.

Go invest in yourself.

Until Then,

#iwishyouwater <- Cloudbreak from the surfing, waves and soundtrack.

Muzak To Blarg by : “Bach Synthesis: 15 Inventions”. Amazing.

Snake_Byte[15] Fourier, Discrete and Fast Transformers

The frequency domain of mind (a mind, it must be stressed, is an unextended, massless, immaterial singularity) can produce an extended, spacetime domain of matter via ontological Fourier mathematics, and the two domains interact via inverse and forward Fourier transforms.

~ Dr. Cody Newman, The Ontological Self: The Ontological Mathematics of Consciousness

I am Optimus Transformer Ruler Of The AutoCorrelation Bots

First i trust everyone is safe. i haven’t written technical blog in a while so figured i would write a Snake_Byte on one of my favorite equations The Fourier Transform:

    \[\hat{f} (\xi)=\int_{-\infty}^{\infty}f(x)e^{-2\pi ix\xi}dx\]

More specifically we will be dealing with the Fast Fourier Transform which is an implementation of The Discrete Fourier Transform. The Fourier Transform operates on continuous signals and while i do believe we will have analog computing devices (again) in the future we have to operate on 0’s and 1’s at this juncture thus we have a discrete version thereof. The discrete version:

    \[F(x) &= f\f[k] &= \sum_{j=0}^{N-1} x[j]\left(e^{-2\pi i k/N}\right)^j\0 &\leq k < N\]

where:

    \[f[k] &= f_e[k]+e^{-2\pi i k/N}f_o[k]\f[k+N/2] &= f_e[k]-e^{-2\pi i k/N}f_o[k]\]

The Discrete Fourier Transform (DFT) is a mathematical operation. The Fast Fourier Transform (FFT) is an efficient algorithm for the evaluation of that operation (actually, a family of such algorithms). However, it is easy to get these two confused. Often, one may see a phrase like “take the FFT of this sequence”, which really means to take the DFT of that sequence using the FFT algorithm to do it efficiently.

The Fourier sequence is a kernel operation for any number of transforms where the kernel is matched to the signal if possible. The Fourier Transform is a series of sin(\theta) and cos(\theta) which makes it really useful for audio and radar analysis.

For the FFT it only takes O(n\log{}n) for the sequence computation and as one would imagine this is a substantial gain. The most commonly used FFT algorithm is the Cooley-Tukey algorithm, which was named after J. W. Cooley and John Tukey. It’s a divide and conquer algorithm for the machine calculation of complex Fourier series. It breaks the DFT into smaller DFTs. Other FFT algorithms include the Rader’s algorithm, Winograd Fourier transform algorithm, Chirp Z-transform algorithm, etc. The only rub comes as a function of the delay throughput.

There have been amazing text books written on this subject and i will list them at the end of the blarg[1,2,3]

So lets get on with some code. First we do the usual houskeeping on import libraries as well as doing some majik for inline display if you are using JupyterNotebooks. Of note ffpack which is a package of Fortran subroutines for the fast Fourier transform. It includes complex, real, sine, cosine, and quarter-wave transforms. It was developed by Paul Swarztrauber of the National Center for Atmospheric Research, and is included in the general-purpose mathematical library SLATEC.

# House keeping libraries imports and inline plots:
import numpy as np
from scipy import fftpack
%matplotlib inline
import matplotlib.pyplot as pl

We now set up some signals where we create a sinusoid with a sample rate. We use linspace to set up the amplitude and signal length.

#frequency in cycles per second or Hertz
#this is equivalent to concert A

Frequency = 20 
# Sampling rate or the number of measurements per second
# This is the rate of digital audio

Sampling_Frequency = 100 

# set up the signal space:
time = np.linspace(0,2,2 * Sampling_Frequency, endpoint = False)
signal = np.sin(Frequency * 2 * np.pi * time)

Next we plot the sinusoid under consideration:

# plot the signal:
fif, ax = plt.subplots()
ax.plot(time, signal)
ax.set_xlabel('Time [seconds]')
ax.set_ylabel('Signal Amplitude')

Next we apply the Fast Fourier Transform and transform into the frequency domain:

X_Hat = fftpack.fft(signal)
Frequency_Component = fftpack.fftfreq(len(signal)) * Sampling_Frequency

We now plot the transformed sinusoid depicting the frequencies we generated:

# plot frequency components of the signal:
fig, ax = plt.subplots()
ax.stem(Frequency_Component, np.abs(X_Hat)) # absolute value of spectrum
ax.set_xlabel ('Frequency in Hertz [HZ] Of Transformed Signal')
ax.set_ylabel ('Frequency Domain (Spectrum) Magnitude')
ax.set_xlim(-Sampling_Frequency / 2, Sampling_Frequency / 2)
ax.set_ylim(-5,110)

To note you will see two frequency components, this is because there are positive and negative (real and imaginary) components to the transform which is what we see using the stem plots as expected. This is because the kernel as mentioned before is both sin(\theta) and cos(\theta).

So something really cool happens when using the FFT. It is called the convolution theorem as well as Dual Domain Theory. Convolution in the time domain yields multiplication in the frequency domain. Mathematically, the convolution theorem states that under suitable conditions the Fourier transform of a convolution of two functions (or signals) is the poin-twise (Hadamard multiplication) product of their Fourier transforms. More generally, convolution in one domain (e.g., time domain) equals point-wise multiplication in the other domain (e.g., frequency domain).

Where:

    \[x(t)*h(t) &= y(t)\]

    \[X(f) H(f) &= Y(f)\]

So there you have it. A little taster on the powerful Fourier Transform.

Until Then,

#iwishyouwater <- Cloudbreak this past year

Muzak To Blarg by: Voyager Essential Max Ricther. Phenomenal. November is truly staggering.

References:

[1] The Fourier Transform and Its Applications by Dr Ronald N Bracewell. i had the honor of taking the actual class at Stanford University from Professor Bracewell.

[2] The Fourier Transform and Its Applications by E. Roan Brigham. Graet book on butterfly and overlap-add derivations thereof.

[3] Adaptive Digital Signal Processing by Dr. Claude Lindquist. A phenomenal book on frequency domain signal processing and kernel analysis. A book ahead of its time. Professor Lindquist was a mentor and had a direct effect and affect on my career and the way i approach information theory.

¿Por qué haces apnea? (Why Do You Freedive?) and 9/11

Me Manifesting And Searching (photo by @clay.motus.liquidum)

I need the sea because it teaches me. I don’t know if I learn music or awareness, if it’s a single wave or its vast existence, or only its harsh voice or its shining suggestion of fishes and ships. The fact is that until I fall asleep, in some magnetic way I move in
the university of the waves.

~ Pablo Neruda

First i trust everyone is safe. Second today is a day that will live forever in most minds as a day that i call ‘When Belief Systems Run Amuck (WBSRA)”.

To those who lost loves ones on 9.11 my condolences. To those who are permanently scarred may peace eventually see its’ way unto and into you.

It is not random that one of my dear friends “JH” is relocating this very week to Charleston, SC. He was in the North tower on the 87th floor when the “WBSRA” occurred.

He is a great human. We are going to have a blast when he gets here.

Recently more than ever humans around me have been talking more and more about “stuff” they do besides “working” and inevitably as we are discussing these outside work endeavors someone mentions that i freedive.

Clay T. Talley Rappelling Underwater (photo Tanner Peterson @depthwishfreediving)

It goes something like this:

Human: Ted freedives.

Everyone: ( looking at me like i have obtained the classified UAP documents from the All-domain Anomaly Resolution Office (AARO)…)

Me: Yup.

Human: Wow really?

Me: (thinking… No i just lie about stuff like that…) Why Yes i do.

Me and @clay.motus.liquidum (photo courtesy of @depthwishfreediving)

Human: Have you seen “Deepest Breath” On Netflix?

Me: While i do not watch hardly any TV i did view it and yes it was amazing. The people in that video are the best of the best in the world and i have met one or two of them and have been coached and critiqued by some of them. i’m no where in their league.

Human: So really is it one breath? There must be some trick? How long can you hold your breath? How deep do you go?

Me: Yes, No, about 4:00+ minutes and i have broken 100ft . None of it really matters as the folks who are great, i pale in comparison, but it is a starting point. It is also not a contest with others. While there are competitions the only competitor is you and the water.

Me coming up from looking at the sand somewhere (photo courtesy of @depthwishfreediving)

Human: What is it like?

Me: It is truth. If there is a truth to life it is closer to living with the exception at least for me, what i find in surfing. Although the two are very different, the results, from to time, are the same. Complete un-adulterated FLOW STATE. The free fall is very close to getting a full tube ride. It is all enveloping it is not like meditating as some people think it is, although, there is a somnambulistic component to the free fall.

Clay Talley and Jacob Talley the day Jacob was certified (photo courtesy of @depthwishfreediving)

Human: What is freefall?

Me: That is after you get down to about 14 meters which is around 45 feet that is 3 atmospheres of pressure you start getting pulled down the elevator shaft as i call it. You can feel the water rushing by you and the sounds rushing, depending on if your hooked to a line or just letting your hand brush the dive line. Then as you go deeper it gets more enveloping.

Me: See your Mammalian Dive Reflect kicks in, your MDR, the master switch as it were. The sensors are still in our face. This is why it feels so nice to splash water on your face or take a shower. All those negative ions getting you balanced into BlueMind. There is much we have forgotten as a race. There is an excellent book called BlueMind i highly recommend.

Me, Thomas Tanner (@itstomfoolery) and My Nephew, Ty Tanner (@tytanner_) the day they got certified

(photo courtesy of @depthwishfreediving)

Human: Yea but how can you hold your breath that long?

Me: Practice. Actually it all happened in one weekend at Performance Freediving Institute (PFI). Me and my waterman commrade Clay Talley went down on a Friday and took a class after we read a book called “One Breath” and got turned onto a song called “Waves” by Bahamas. We have been training with weights in the pool for about 15 years for surfing then this freediving wonderland rabbit hole came along. We could easily get you to over a 2:30 breath hold in one day. Nothing prepared us for what was to come.

Human: I don’t see how that is possible.

Me: Well, i suppose with an attitude like that nothing is possible, but at least we gave it the benefit of the doubt and when we got certified. It was really intense due to several factors that i would have to explain later. However by far my certification was in one of the top experiences of my life and about as close to a religious experience as one could get.

My Son Thomas Tanner getting certified with Tanner Peterson Lower Left (photo courtesy of @tctjr)

Then then THE question:

Human: Why do you do it?

Me: Do what? Freedive?

Human: Yes.

This, Oh Dear Reader is where we start getting to the essence of the blog. Hope Y’all are still tuned-in to the channel.

To every sailor the gods have given a comrade
While one sleeps the other keeps watch on the bridge
When one doubts the other gives him his faith
When one falls the other discovers the oasis of ice for both of them
When my comrade loses faith I laugh confidently
When my comrade sleeps I keep watch for him
When my comrade falls I fight on for the both of us
Because to every sailor the gods have given a comrade

~ Blood Axis

Me: Well it is complicated. One of my best friends died freediving. He was one of the few people who really knew me and and happened to be the best coding computer scientist i have ever met, as well as an expert Waterman.

Me wondering what the Puppies are Thinking. (photo courtesy @clay.motus.luquidum)

Human: Oh i had no idea i am so sorry.

Me: Oh please no need for condolences. i’ll never get over it but that is a different issue. That said to answer your question i got into it because i wanted to understand how one of the smartest most fit watermen i have ever met came to his demise doing what he loved. i had to know or at least try to understand what Steven was searching for given i knew him so well.

It’s not tragic to die doing something you love.

~ Mark Foo

Me: See i kinda blew it off years ago when he kept talking about freediving and how incredible it was and in fact the last thing he said to me was he was really happy. That is really all i cared about to be honest. However it still nagged at me about there was a facet of “The Water” i hadn’t addressed.

So through a very seemingly random occurrence which to me wasn’t random at all i ran across the book “One Breath” which was a story of the death of one of the greatest freedivers of all time. So we (me and my commrade Clay Talley) finally got around to getting down so to speak and since then it has been a continual Alice in Wonderland – Down The Rabbit Hole. Besides the fact that you burn about 800-1000 calories an hour freediving it only teaches you more about yourself. It is indeed a fractal situation – the more complex – the more complex – the more simple – the more simple.

Me ascending and hanging out in Bonaire with Carlos Coste

(photo courtesy of @carloscoste1 of @blueclassroom and @freediveeexplorations)

Ted, Its all in Your Mind, Get me? Understand What I am saying?!

~ Cole Heitt

Me: Its really a super performant sport. All of the people that i have met have been physicists, composers, lawyers, bankers, technical folks and many have walked away from those careers in full pursuit of freediving. Everyone is very open, welcoming and focused. There is little to no overhead with some of the crap that you get with other sports endeavors, it is very binary. As an aside i personally want to dive with Sperm Whales.

Human: Yes but what about your friend?

Me: Well if i could have a discussion with him first i would punch him for being stupid then i would hug him, tell him i love him and say lets go for a freedive and this time i’ll be up and you be down.

Clay Talley Searching For Clay T. Talley

Me: Feel free to come down and get in the pool or we can take you down and get certified.

Human: Really?

Me: Of course and you can’t blame me for what will happen afterward.

To everyone that has ever asked me this is why i freedive. I needed to understand why and it has turned into a mirror for me.

On September 11, 2005, Steven Swenson took his last breath. However i know he was happy in fact the happiest i have ever heard him.

Recently his favorite musician past away, Jimmy Buffett. Steven’s favorite song was Son of A Son of A Sailor. He also liked “That is What Living Is to Me” and “One Particular Harbor”. I would like to think they are sharing sailing stories with each other with wind in their hair and water in their shoes.

Do me a favor if you knew him go listen to any of those songs and if you didn’t know him go listen and raise a glass to the ocean. i would also greatly appreciate it.

Mickey Talley @mich.888 Pushing Past Her Own Thoughts (photo courtesy @clay.motus.liquidum)

So there you have it folks.

Until Then,

#iwishyouwater <- Me and Present Crew Getting After it @iwishyouwater

@tctjr

Music To Blog By: The version of “Little Wing/ Third Stone: From The Sun off SRV archives and some Jimmy Buffett. The Tuck and Patti version of Castles Made of Sand / Little Wing is amazing as well.

Note: With Much Love to Roma, Lief and Gage.

Quality Over Quantity (Part D’eux)

Determination, energy, and courage appear spontaneously when we care deeply about something. We take risks that are unimaginable in any other context.

Margaret J. Wheatley

First i trust everyone is safe. Second sometimes the LazyWebTM can actually be a really cool place. Someone out there used an amazing thing called a LARGE LANGUAGE MODEL AKA ARTIFICIAL INTELLIGENCE to make a song out of a book passage that closely relates to my previous blog on Quality Over Quantity. The book is entitled The Greatest Salesman In The World. Here is that passage:

“I will persist until I succeed.

I was not delivered unto this world in defeat, nor does failure course in my veins. I am not a sheep waiting to be prodded by my shepherd. I am a lion and I refuse to talk, to walk, to sleep with the sheep. I will hear not those who weep and complain, for their disease is contagious. Let them join the sheep. The slaughterhouse of failure is not my destiny.

I will persist until I succeed.

The prizes of life are at the end of each journey, not near the beginning; and it is not given to me to know how many steps are necessary in order to reach my goal. Failure I may still encounter at the thousandth step, yet success hides behind the next bend in the road. Never will I know how close it lies unless I turn the corner.

Always will I take another step. If that is of no avail I will take another, and yet another. In truth, one step at a time is not too difficult.

I will persist until I succeed.”1

Then they “told” ChatGPT the person(s) behind the green curtain to write a metal song using the above passage:

(Verse 1)
Hear my mantra echo, “Persist until success,
Born not to the world in defeat, nor failure’s caress.
Not a sheep in the herd, prodded, guided by the rest,
I am the lion roaring, refusal in my chest.

(Chorus)
I won’t be moved by tears and whines, their sickness I’ll resist,
In the abattoir of failure, I’ll never coexist.
The end of every journey hides the precious prize,
One more step around the bend, where success quietly lies.

(Verse 2)
Step by step, relentless, no distance is too great,
Every challenge faced is just another weight.
My efforts like the blade, the mighty oak I strike,
Insignificant they seem, but will fell the tree in time.

(Chorus)
Like rain that washes mountains, the ant that feasts on tigers bold,
I am the star that lights the earth, the tale that’s yet untold.
Building castles, brick by brick, with each repeated trial,
Persist until I succeed, in my journey, every mile.

(Bridge)
Defeat is not a concept, its words I shall erase,
Quitting, failure, impossible, all fall from grace.
Obstacles may rise, despair may cloud the way,
Yet above it all, my gaze is fixed, where greener pastures lay.

(Chorus)
Persist until I succeed, let this anthem ring,
Born a lion, not a sheep, to my purpose, I will cling.
Journey’s end may hide the prize, step by step I’ll tread,
In the echoes of the night, let my mantra be heard and said.

(Outro)
I will persist until I succeed, etched in stars, this creed,
For I am the lion roaring, fulfilling every need.
The end of every journey hides the precious prize,
Persist until I succeed, echoes my eternal cry.

The book talks about The Art Of Living wherein there is the World’s Greatest Salesmen who was given some scrolls he must past to another person who he must identify with as being the keeper of the scrolls. The book goes into depth and each chapter is a scroll. A teaching if you will for being the world’s greatest salesmen so you as being the reader are immersed into this world.

Maybe someone will put some music to these words. i was thinking something like a Thin Lizzy feel if you will.

Until Then,

#iwishyouwater. <- WSL Live. Teahpoo Tahiti.

tctjr.

  1. OG Mandino: The Greatest Salesman In the World also referring to the #ArtOfLiving a class created by McConaughey and Tony Robbins ↩︎

Quality Over Quantity

Dalle’s Idea of Quality Over Quantity

Be a yardstick of quality.

Some people aren’t used to an environment where excellence is expected.

S. Jobs

First i hope this finds everyone safe. Second, your humble narrator has been incognito of late and re-emerged safe and sound as the CTO of a really cool company called BigBear.ai . Third, for some reason or another several folks have been talking to me about risks and reward in life as of late. i haven’t written a blarg in a while so i figured i would take the time to jot down some thoughts.

i dedicate this blarg to my parents. Here is why.

A long time ago in a land far away i lived in a modest ranch style house in Charleston,SC and in the den area there was a sign that said:

It is better to live one year as a lion than 20 years as a chicken.

Anonymous

This is a modified quote that can be tracked to several people in history. i am by no means referencing any political or religious views herewith so please check yourself. Someone somewhere could play the same music and someone would hate them for it on the internet.

i read this everyday coming in and out of the house and it had a profound effect on me later in life. Without me even knowing it i gravitated towards living on the creative side or maker side of life or let’s say risk taking side of life.

If you obey all the rules, you’ll miss all the fun.

Katheryn Hepburn

In the same fashion, for some unknown reason, people have been asking or talking to me about the creative process as well as having hobbies that appear to be risk taking.

For the record i don’t view anything that i do as a i hobby nearly as dangerous as driving. i’ll probably do a blarg on one activity everyone seems to be asking about is freediving but that isnt the subject of this blarg.

Life is to be lived folks. Social norms keep many from going and doing and living a life they DREAM. i hear you saing: “Well you know how it is life gets in the way.” Nope boys and girls your brain gets in the way and says “Oh you could never do that what would people think?”. “My <insert person here> would just disown me.”

What if you do it and you are truly happy?

The other thing people have been saying to me lately is “How’d you do that?” Well i just went and did it. Once again someone somewhere isn’t going to like whatever you do and you can’t please everyone so you might as well please yourself as the song says. (Rick Nelson – Garden Party).

Most people who really care about you just want you to be happy. They might not like or agree with you when letting your freak flag fly or even imagine how you could live in such a manner but i guarantee you show up to those you love truly happy then everything will be really OK. This is on YOU as it is on THEM. This is a two way street folks. You choose a difficult path not everyone is going to be “accepting”. The road will be strewn with stones to your path of righteousness. Trust me – Caveat Emptor.

The goal is living in a high quality life over a mundane mediocre life. The moments that take your breath away versus the number of breaths in a life. Where do you see a coffee table book entitled “Lives Of The Mediocre.”

Which is very closely related to the creation process. Putting yourself out there is scary. “Yes but i don’t have the courage or the skills.” You know what? Neither did anyone else who went and did The Thing.

Go do the thing that scares you the most then get the courage. That fine line is living. In fact it has been my experience it is a near life experience. Standing at the edge and looking down. Where you even surprise yourself.

“Yea but what if something goes wrong?”

Once again great question. It will. Yes Oh Dear Reader it will but guess what sitting in the recliner or couch every night for the rest of your life or looking out the window and thinking “I wish i would have done…” is way more painful than either pissing someone off for a little while or a broken leg, All will heal with love and happiness.

So put me on a highway
Show me a sign
Take it to the limit
One more time

The Eagles

Recently after a lengthy discussion about risk taking, mental gymnastics or physical hobbies someone asked me about my injuries. Here is a partial list:

Right shoulder replaced, Plates and 8 screws in my right forearm, Two left shoulder reconstructions, Two hip replacements, Broken right ankle and leg twice, Broke ribs, hernia operation, broken nose, cracked back, whiplashes, concussions, the list goes on…

Why would someone put themselves through this? I don’t know sounds like a startup co-founder huh? Because you MUST.

Because living at that level of passion is everything. There is nothing else. Because you know what? The crash is almost as amazing as making it! Quality Over Quantity Folks!

Taking this view In sports, companies and most importantly your relationships is crucial. Most will say they cannot live like that and they do not understand. Well just hand them a big cup of NOPE YA CAN’T. They will get very frustrated as well. Most people of that nature want their predictable life and the ability to dictate to others their lives.

So this morning i called my parents. Luckily both my parents are alive and very married. I told them thank you for having that sign in the den and it would be great if they could find the sign. They informed me it “wore out”. Get the symbology there? They said they had toted it from house to house.

After hanging up i went online to everyone’s favorite online retailer and bought this for my home gym:

Because i needed a reminder. Just like when i was a kid.

Enjoy it while you can
It’s just like the weather
So quit complaining brother
No one lives forever

Let’s have a party there’s a full moon in the sky
It’s the hour of the wolf and I don’t want to’ die

Oingo Boingo

So go create, make, live, and love like there is no tomorrow. You and the people around you will be better off and you will definitely find out who loves you when you are truly happy. Trust me in this area of life you will not have many if any followers just those who truly desire you to be happy.

Until Then,

#iwishyouwater <- near life at Mavericks in 2022.

@tctjr

Muzak To Blag By: Danny Elfman’s “Big Mess”. He is truly a genius. Yes the same person who created Oingo Boingo and all of the great soundtracks.

NOTE: i can also recommend several books on these views such as Tim Ferris’ “Tools For Titans” and Rolo May’s “The Courage To Create”, hit me up on the comments if you want more. Also please tell me a story where you put yourself out there. i’d love it hear about it.

What Is Love?

DALLE’s Idea Of Love

Love is a complex and multifaceted emotion that is often defined differently depending on cultural, social, and individual perspectives. At its core, love typically involves strong feelings of affection, caring, and attachment towards another person, often accompanied by a desire for intimacy, closeness, and mutual support.

Love can take many different forms, including romantic love, familial love, platonic love, and self-love. It can also involve a range of different experiences, such as joy, happiness, excitement, passion, and sometimes even pain and heartbreak.

Ultimately, love is a powerful and transformative force that can have a profound impact on our lives, shaping our relationships, beliefs, and sense of self.

~ ChatGPT

First Oh Dear Reader, i trust you are safe. Second, we are taking a slight detour into squishy, non-exact, messy, and truly complicated land: Emotions. This comes on the heels of Snake_Byte[14] Coding In Philosophical Frameworks. Also if you haven’t seen the news, the Cognitive Computing Arms Race with Large Language Models is in full swing. Boy Howdy Do We Love Us Some Anthropomorphism! ( i personally think its funny the parlor trick of auto-typing makes ChatGPT and all the other ones appear human to most. )

Turns out there is a class at Stanford on Computational Philosophy which is in the same realm as what i would love to discuss however slightly obtuse. It is a good read.

If we can compute Philosophical frameworks, could we or do we need to compute emotions in the future?

It was not random i started with the terseness of Stoicism. As this philosophy trends towards being objective in your emotions, akin to a more recent philosophy, “Objectivism.” We can quantify the aspects thereof. Or at least we think we can quantify them to some extent.

We know from a physiological standpoint that bodily metrics and chemicals can be measured for systematic responses to emotions. Dopamine, Vasopressin, Oxytocin, Serotonin, heart rate, sweat level, skin clamminess, and eye dilation are just a few measurable considerations.

However what does it mean?

Let’s take some bookend emotions: Love, Hate, Fear.

Some consider Fear to be the only true emotion. Flight or Fight. i’m also positive we can duplicate this in a machine or at least make it plausible to appear the machine is scared. (Also, it will make humans “feel” better one day but that is for a different discussion and different blog.)

Being that Spring Is In The Air let us choose LOVE.

There are so many types and kinds of Love.

  • Love of a Mother to a child
  • The Love you have for your pets
  • The Love of eating a doughnut.

i’m not referring to these types i am referencing:

  • You are the Love of My Life Companionship – Love

Books, signs, poetry, and yes, humans’ most deplorable creation War has been created over Love of Another. It is genuinely innate in the Human_Condition.

People acting a fool, if you will. You have seen it many times, and maybe (hopefully) you have done it.

As the famous song says, “What does love have to do with IT? What is love but some secondhand emotion?”. Great questioning Tina. We love you.

Have you ever been in The Love? How do you know that person Loves YOU?

i asked one of my progeny that question:

Me: “Do i Love you?”

Them: “Yes.”

Me” “How do you know?”

Them: “Dad i just know.”

This is not to be confused with infatuation, which is in and of itself an extremely intense feeling usually associated with a physically idealized version of the receiving person. Infatuation is initially overwhelming but then quickly fades. Love, on the other hand, appears to be a much deeper, almost seemingly “infinite forever-giving” emotion.

i was wondering how many times “Love” has been mentioned over the years. Below is a plot thereof:

Love Over The Years

i thought the drop in the 1980’s was interesting. If anyone was around in the United States in the 80’s that was the period of certain illegal chemicals, neon, 80’s metal and madonna. The Me Generation.

So what has happened in this area with using technology of Love? Well we scan our noggin:

From The Journal of Frontiers in Human Neuroscience

When I take you in my arms gathered forever. Sometimes it feels like a dream. Sometimes it feels like a dream; to be with you.

~ Feels Like A Dream Lyrics

Research has shown that certain brain regions are activated when a person is in love or experiencing strong feelings of affection, including the insula, anterior cingulate cortex, and striatum. These regions are associated with reward, motivation, and emotional processing. Brain scans have also revealed that the levels of certain neurotransmitters, like dopamine and oxytocin, can change in response to being in love. So while there is no one-size-fits-all image of someone in love, there are certain brain patterns and chemical changes that can be detected in those experiencing the emotion.

Furthermore on the chemical brain related activity research has shown that during the early stages of romantic love, there is a decrease and increase in serotonin levels in the brain[1]. Serotonin can have direct affects on anxiety, insomnia and depression. For men there is a decrease and for women and increase in serotonin. Strangely this is similar to what is observed in individuals with obsessive-compulsive disorder, suggesting that the intense focus and preoccupation with the loved one may be related to changes in serotonin levels. Additionally, it has been found that long-term couples who remain in love have higher levels of serotonin than those who have fallen out of love. This suggests that serotonin may play a role in maintaining long-term relationships.

Our study provides the first evidence of love-related alterations in the underlying architecture of the brain, and the results shed new light on the mechanisms of romantic love.

~ Professor Xiaochu Zhang

So if there are (and there are injectable adjuncts to all of these chemicals) that can be augmented and tailored with specific dosages, this led me to ask the questions:

  • can we compute a model of Love?
  • can we fool the brain into thinking it is in Love?
  • do we want to augment the brain so we feel like we are in Love?
  • Do we want to make Love a thing of the past with future tech?
  • The list could go on…..

 Did my heart love till now? Forswear it, sight / For I ne’er saw true beauty till this night.

~ That Romeo Guy

When people meet, go on a date, shack up, get hitched or get married, i have heard it said:

  • “You will grow to love them.”
  • “Well, the person doesn’t really have the attributes i am looking for in a mate, but i can adapt.”
  • “They share the same interest as you!”
  • “They can cook or fix stuff for you!”

Why would we want to change or have that person change? Are social norms so strong that there are unwritten rules that we as a so-called society must follow, With a hard rule of it must be two consenting adults in a relationship, what is it of anyone’s business? Do most want to do what they feel they should do? Do we want a best friend to watch the big game with or play golf? Why not a companion that you can dance with now and when your old and just look at each other? To idealized? Oh life gets in the way. i see it is hard and you have stuff to do – yep i get it. Then is Love that important? If not then what is?

Love in a relationship is it needed?

How do you know when you’re really in Love? Do violins play when you’re touching the one your Lovin?

~ The Tubes

Most often, love is due to their connection with their partner. This connection can be emotional, physical, spiritual, or intellectual (or hopefully all of them). People may also fall in love or grow into love because they appreciate their partner’s qualities or values, such as kindness, honesty, or intelligence. Sometimes, people are drawn to others who are different from themselves because they find them intriguing or exciting.

This room is bare
This night is cold
We’re far apart, and I’m growing old
But while we live
We’ll meet again
So then, my love
We may whisper once more
It’s you I adore

~ Palabras de Amor from Queen

Other factors that contribute to love include shared experiences, common interests, and mutual respect. When people feel like they’re a team with their partner and can rely on them, it can deepen their love. Additionally, physical attraction and chemistry can significantly influence romantic love.

However, what if it is all of these with the same partner? Isn’t that what you truly desire? ALL THE THINGS! To truly know that there is one – what would you do to have that person show up on your porch?

This is what i believe we need to understand as we trend toward a world of distributed disconnected artificial intelligence.

In one kiss, you’ll know all I haven’t said.

~ Pablo Neruda[3]

Even post the pandemic, we see people hug and kiss less. There is less physicality which as we all know for most, a hug feels good for both and releases several proof-positive chemicals. i would tend to think at some point you want to rub against your significant other instead of smooching in cyberspace or sleeping in separate beds.

Is Love now an algorithm? i know in the age of match.com and tinder this appears to be monday morning quarterbacking but at least i believe there is something more to it than a list of attributes. In fact one of the startups i worked at started with the premise, “What are the three main questions you ask someone on a blind date?” Here they are:

  • What is your favorite travel spot?
  • What is your favorite wine (assuming one drinks)
  • What type of music do you like?
DALLE Generated Endless Love

From a cognitive standpoint the most difficult one was music recommendations. This by the way Oh Dear Reader was circa 2001 before Pandora, Shazam or any other music recommendation system. We based it on a cognitive model of music perception and cognitive psychology of inter-relations[2].

If we already know the future and can match it aren’t we living in a world of no surprises? What happens to that special glance? That special smile or touch or a good morning hug? That true everlasting one that loves you for you and only you not because your father mother or your in-laws approved. (If course it has been said you marry the family not the person. )

i am sure by now you have heard of the term Twin Flame. This is different than a soul mate. A Twin Flame is a mirror of oneself, a yin-yang type entity. The biggest distinction between a twin flame and any other type of soul mate is that twin flames are two halves of the same whole. A soul mate, on the other hand, can be thought of as someone cut from the same cloth as you. There’s a deep familiarity, and you feel very close, but you aren’t the same soul.

i wonder if we can compute and create a Twin Flame Agent of oneself?

i’m not sure i want to work on those future algorithms folks. Some things i want to be a mystery[4].

i’d love to hear some stories, comments, and possibly even rants as this is some very esoteric area we have paddled into so to speak. i’d love to know if you have the love of your life, twin flame or a tinder swipe of the night, i hope you just know.

Until Then,

#iwshyouwater <- alexy molchanov sets a new world record in Bonaire. i was just in the same spot freediving.

Muzak To Blog By: All The Love Songs by Queen. i miss you Freddy and recently brian may was knighted.

References:

[1] Scans Say Its True Love Link

[2] For the record, i tried the system, and no one liked strict cathedral organ works.

[3] Pablo Neruda is the most prolific poet when it comes to love and beaches i have ever read. there is a connection there.

[4] In blade runner, harrison ford knows full well racheal is a replicant yet he Loves her. Question is – Is He? That would be a twin flame. robot love.