Technology

What AI taught me

So i was browsing the web and came across this paper A high-order recombination algorithm for weak approximation of stochastic differential equations a way above my intelligence level, but I always wondered how people use these crazy alien looking equations.

So i copy and pasted it to ChatGPT and the first explanation was again way over my intelligence level so I had it explain to me as if i was a teenager

Sure — here’s a simple way to think about it:

Imagine you’re trying to learn the best way to do something, like win a game or solve a puzzle. You don’t know the perfect strategy yet, so at each step, you mix different ideas (strategies) and try them out to see what works best.

Now, think of each idea or strategy as a "player" in your team. At each round (call it step i), you have some confidence in each player — that's what the weights αj\alpha_j represent. The more confident you are, the bigger the weight.

The equation is basically saying:

"Hey, after I apply this smart learning rule (called Alg and Q), I take my current team mix and recalculate my new team (for the next step, i+1) by seeing how well each idea transfers over using a table of scores (that’s the weight matrix w(i))."

So you're updating your mix of strategies based on how much each old idea contributes to new ideas in the next round.

It’s like upgrading your strategy team over time, keeping track of who’s helping the most and adjusting your trust in them.

 

So stoked! Who wouldn't want to know an algorithm to help them find the best way to do something? I love when I randomly come across such useful information on the web its like "Internet Gold".

Now how can I apply this in real life? I ask chatGPT to show me in a language I can understand.

Here’s an interactive version of the strategy learning loop in PHP CLI — it asks you (the user) to give feedback manually for each strategy in each round (e.g., "Did the user like the content? Yes or No?").

This simulates you being the decision-maker or tester of each strategy.

 

<?php

$strategies = ['popular_videos', 'similar_likes', 'geo_trending'];
$alpha = [0.4, 0.4, 0.2];

$w = [
[0.6, 0.3, 0.1],
[0.2, 0.6, 0.2],
[0.1, 0.3, 0.6]
];

function normalize($vector) {
$sum = array_sum($vector);
return array_map(fn($v) => round($v / $sum, 3), $vector);
}

function ask($prompt) {
echo $prompt . " (y/n): ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
return strtolower(trim($line)) === 'y' ? 1 : 0;
}

function showBar($label, $value, $width = 30) {
$barLength = round($value * $width);
$bar = str_repeat("█", $barLength);
printf("%-18s [%-30s] %.2f\n", $label, $bar, $value);
}

for ($round = 1; $round <= 10; $round++) {
echo "\n=== Round $round ===\n";

// Collect feedback
$feedback = [];
foreach ($alpha as $i => $weight) {
$strategy = $strategies[$i];
$reward = ask("Did the user like content from '{$strategy}'?");
$feedback[$i] = $weight * $reward;
}

// Update using transition matrix
$newAlpha = array_fill(0, count($strategies), 0);
foreach ($feedback as $k => $scaled_weight) {
foreach ($strategies as $j => $_) {
$newAlpha[$j] += $scaled_weight * $w[$k][$j];
}
}

// Normalize
$alpha = normalize($newAlpha);

// Display new weights visually
echo "\nUpdated Strategy Weights:\n";
foreach ($strategies as $i => $s) {
showBar($s, $alpha[$i]);
}
}

 

Output example:

=== Round 3 ===
Did the user like content from 'popular_videos'? (y/n): y
Did the user like content from 'similar_likes'? (y/n): n
Did the user like content from 'geo_trending'? (y/n): y

Updated Strategy Weights:
popular_videos [███████████████████████ ] 0.65
similar_likes [██ ] 0.07
geo_trending [█████████ ] 0.28

Its pretty awesome how ChatGPT was able to take a random alien looking equations I found and break it down in a way that I can understand and even apply in my own projects.

I dive much deeper, but dont want to bore you, if your interested here is the conversation here

Tracking DMV wait times

PROJECT on-hold due to COVID-19

THIS PROJECT IS CURRENTLY NOT COLLECTING DATA BECAUSE THE DMV IS NOT OPERATING DUE TO THE COVID 19 PANDEMIC. CHECK OUT MY OC COVID TRACKER MEANWHILE.

So I was required to visit one of our favorite state agencies, the DMV. Its been a while, and when i showed up the line was wrapping around the building.  So i went home to spare my day, and figure out a better way to accomplish this civic duty.

With some general knowledge of the existing public data, I attempted to track the wait times for all my local DMV's. and figure out where and when a good time to go to the DMV would be.

Going to the DMV website I found some interesting stats

This data provides a  general overview but not the specifics im looking for. After a little more digging I wass able to find "some what" real time wait time on the DMW website:So i proceeded to scrape those wait times into a MYSQL database every 15 minutes for each location.  Making use of that much data can be difficult, so i need to make a way to visualize the data, so i employed google charts.   If your interested in seeing the ongoing results of this project click here

  I was able to figure out the best time and location, which i will publish online after I finish my dealings with the DMV. So be sure to check back or subscribe to my site for an update.

Why using Frameworks is a MUST

A coders example of why frameworks are a MUST in application development.

    • Frameworks reduce the amount of code required to complete a task.
    • It reduces the overhead cost and time (learning curve) of bringing onboard new developers to an existing project
    • Helps keep your code clean and organized as your project grows
    • The more displined you are in adhering to MVC pattern, means less time and less cost in future development

CodeIgniter is right for you if:

  • You want a framework with a small footprint.
  • You need exceptional performance.
  • You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.
  • You want a framework that requires nearly zero configuration.
  • You want a framework that does not require you to use the command line.
  • You want a framework that does not require you to adhere to restrictive coding rules.
  • You are not interested in large-scale monolithic libraries like PEAR.
  • You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).
  • You eschew complexity, favoring simple solutions.
  • You need clear, thorough documentation.

 

Now for the good stuff…

Querying Data from SQL

CodeIgniter (4 Lines of code)


$query = $this->db->get('table_name');
foreach ($query->result() as $row)
{
echo $row->title;
}

VS

PHP (LOTS OF LINES OF CODE) Using Codeigniter all the configuartion settings are automatically loaded and avaliable EVERYWHERE and ANYWHERE

$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();

This is just one example, to learn more about working with SQL via codeigniter

HELPERS

Toolbox of useful Code aka Collection of Functions that help simply coding such as
Dealing with Dates, Arrays, HTML, Forms, Cookies, Sessions, etc

Example Dates HELPER


//Makes all Date Helper Functions readily avaliable
$this->load->helper('name');

$bad_date = '199605';
// Should Produce: 1996-05-01
$better_date = nice_date($bad_date, 'Y-m-d');

For a complete list of CI helpers available

 

Libraries (Object Oriented Library of Common Tools)

Example of sending complex emails


//Load Library
$this->load->library('email');

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');

$this->email->send();

Without Framework you would have to add third party files SUCH as PHPMailer and add Includes on top of each page, coding alot more method calls

PAGINATION LIBRARY Codeigniter


$this->load->library('pagination');

$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = 200;
$config['per_page'] = 20;

$this->pagination->initialize($config);

echo $this->pagination->create_links();

Check out the list of libraries for almost everything you could possibly need 

Black Fly Aircraft coming in 2019

1-2



Possible game changer in personal aviation

This aircraft will be available for sale this year.  Here's why I think this aircraft stands out and could possible be a game changer for personal aviation

-Affordable (Cost of an SUV)

-No Pilots license required (Ultra Light Class)

-Vertical Take off and Landing

-Propiertary Engine, designed fail proof via redundancy (Parachute included)

-Small engine and propeller, so no large heavy parts falling from the sky.

-Developed in adherence to US regulatory laws (it'll be legal)

Currently the only thing holding this back from possibly being the next Tesla, is the current regulatory restrictions and civil ordinance, just like self driving cars, that will take a bit of time, but flight in our lifetime may now be possible.