More from pcloadletter
I saw a cool version of the Monty Hall game here recently: https://monty.donk.systems. This is really cool! But I had an itch I wanted to scratch: rather than manually test out the probabilities, I wanted to run two games side-by-side: one where a switch happened and one where a switch didn't happen. Then, running those over and over, we should see the overall win percentages converge to 66.7% for switching and 33.3% for not switching. So I coded up a simulation here to scratch my itch! Controls # To control the simulation, you can start or stop here. You can also adjust the speed. Speed (between 1-30): Score # Cumulative stats as the games go on. Scenario Plays Wins Win Percent Switch 0 0 - No switch 0 0 - Switch simulation # If we switch cards after the first goat reveal. +---+ +---+ +---+ | | | | | | +---+ +---+ +---+ No switch simulation # If we don't switch. +---+ +---+ +---+ | | | | | | +---+ +---+ +---+ { playBtn.setAttribute('disabled', 'true'); setTimeout(() => { playBtn.removeAttribute('disabled'); }, 3000); started = !started; playBtn.innerHTML = started ? "Stop simulation" : "Start simulation"; play(true); play(false); }) let playCount = 0; let switchWinCount = 0; let nsPlayCount = 0; let noSwitchWinCount = 0; const playCountDisplay = document.querySelector('#plays'); const winCountDisplay = document.querySelector('#wins'); const winPctDisplay = document.querySelector('#win-pct'); const nsPlayCountDisplay = document.querySelector('#ns-plays'); const nsWinCountDisplay = document.querySelector('#ns-wins'); const nsWinPctDisplay = document.querySelector('#ns-win-pct'); const getRandomIndex = () => { return Math.floor(Math.random() * 3); } const boardDoors = (isSwitch) => document.querySelectorAll(`#${isSwitch ? '' : 'no-'}switch-board span.card`); const boardGuesses = (isSwitch) => document.querySelectorAll(`#${isSwitch ? '' : 'no-'}switch-board span.guess`); const clearBoard = (isSwitch) => { for (let i = 0; i { speed = parseInt(e.target.value); }) const delay = (seconds) => { return new Promise(res => { setTimeout(res, seconds * 1000 / speed) }); } const doorIndices = [0, 1, 2]; const setStatus = (isSwitch, text) => { const statusArea = document.querySelector(`#${isSwitch ? '' : 'no-'}switch-board section`); statusArea.innerHTML = text; } async function play(isSwitch) { if (!started) return; setStatus(isSwitch, " "); clearBoard(isSwitch); // Start with all goats const doors = new Array(3).fill("G"); // Add prize randomly const winIndex = getRandomIndex(); doors[winIndex] = "C"; await delay(0.5); setStatus(isSwitch, "Initial guess") await delay(0.5); // Select random spot for guess let guessIndex = getRandomIndex(); boardGuesses(isSwitch)[guessIndex].innerHTML = "✔" await delay(0.5); setStatus(isSwitch, "Revealing a goat") await delay(0.5); // Reveal a goat const doorsThatCanBeRevealed = doorIndices.filter(el => { return el !== guessIndex && el !== winIndex }) const revealIndex = Math.floor(Math.random() * doorsThatCanBeRevealed.length); const doorToReveal = doorsThatCanBeRevealed[revealIndex]; boardDoors(isSwitch)[doorToReveal].innerHTML = "G" await delay(0.5); setStatus(isSwitch, isSwitch ? "Switching choice" : "Not switching choice"); await delay(0.5); if (isSwitch) { boardGuesses(isSwitch)[guessIndex].innerHTML = " "; guessIndex = doorIndices.filter(el => { return el !== guessIndex && el !== doorToReveal })[0]; boardGuesses(isSwitch)[guessIndex].innerHTML = "✔" } await delay(0.5); setStatus(isSwitch, "Reveal") await delay(0.5); // Reveal for (let i = 0; i
One concern I have heard from AI naysayers is that AI slop will make code reviews nearly impossible. AI churns out so much code, documentation, etc. that it's just impossible for any reviewer to keep up with it... right? Wrong! If you have good PR review processes, then reviewing AI-assisted code shouldn't be any more onerous than reviewing any other code. Here are some concerns I have heard and my response. AI generates tons of code # It's true that AI can sometimes generate tons of code—but your PR process shouldn't allow for massive PRs in the first place! If I get a 100 file PR today, I wouldn't review that. I'd respectfully ask the author to break the PR down into smaller, atomic pieces of work that can be reviewed more carefully. I'd ask this whether or not AI helped generate the code. As an aside, AI can actually generate small, digestible diffs! You just need to prompt in a way to do so. I have found being more methodical in walking AI through the problem step-by-step not only results in more digestible diffs, but also results in higher-quality code. AI generates low quality code # I don't quite know what to say to this one! If you're not reviewing PRs for quality in the first place, then that's a problem. Just apply your regular level of vetting to AI-assisted code as you would regular code. If you don't currently review PRs closely, then the problem isn't the quality of the code—it's that you're phoning it in during PR reviews. People just accept whatever AI outputs without understanding it # I tend to review PRs pretty closely and ask questions about anything I don't understand or think may be wrong. If you author a PR and are unable to answer the questions I have about your code, then it's not making it into the codebase. Again, this is as true today as it was 10 years ago. AI or not, I am going to make sure your code makes sense! AI can use outdated/vulnerable dependencies # If you add third-party dependencies in a PR, that should be considered a "bigger deal" than some folks treat it today (I'm looking at you, node ecosystem). Your PR review process should include evaluating what new dependencies are being added and a review of the installed version. Ideally, there should also be some consideration of whether an external dependency is even needed. Outside of the PR review process, you should ideally have automated dependency scanning (sonarqube, dependabot, etc.) that will detect vulnerable dependencies. Conclusion # If you're worried about AI "slop" making its way into your codebase, consider how your prevent human "slop" from making its way into your codebase. PR reviews are a critical tool for this—and should remain one as we explore this new AI-assisted world.
I'm kind of writing this to "past" me, who I assume is "current" you for a number of folks out there. For the rest of you, this might just sound like ramblings of an old fogey super late to the party. Yes, AI is over-hyped. LLMs will not solve every problem under the sun but, like with any hot new tech, companies are going to say it will solve every problem out there, especially problems in the domain space of the company. Startups who used to be "uber for farmers" are now "AI-powered uber for farmers." You can't get away from it. It's exhausting. I let the hype exhaustion get the best of me for a while and eschewed the tech entirely. Well, I was wrong to do so. This became clear when my company bought Cursor licenses for all software developers in the company and strongly encouraged us to use it. I reluctantly started experimenting. The first thing I noticed is that LLM-powered autocomplete was wildly accurate. It seemed like it "knew" what I wanted to do next at every turn. Due to my discomfort with AI, I just stuck with autocomplete for a while. And, honestly, if I stuck with just using autocomplete it would still have been a massive level up. I remember having a few false starts with the agent panel in Cursor. I felt totally out of control when it was making changes to all sorts of files when I asked it a simple question. I have since figured out how to ask more directed questions, provide constraints, and supply markdown files in the codebase with general instructions. I now find the agent panel really helpful. I use it to help understand parts of a codebase, scaffold entirely new services or unit tests, and track down bugs. As a former skeptic, I am a wildly more productive developer with AI tooling. I let my aversion to the hype train cause me to miss out on those productivity gains for too long. I hope you don't make the same mistake.
Generative AI will probably make blogs better. Have you ever searched for something on Google and found the first one, two, or three blog posts to be utter nonsense? That's because these blog posts have been optimized not for human consumption, but rather to entertain the search engine ranking algorithms. People have figured out the right buzzwords to include in headings, how to game backlinks, and research keywords to write up blog posts about things they know nothing about. Pleasing these bots means raking in the views—and ad revenue (or product referrals, sales leads, etc.). Search Engine Optimization (SEO) may have been the single worst thing that happened to the web. Every year it seems like search results get worse than the previous. The streets of the internet are littered with SEO junk. But now, we may have an escape from this SEO hellscape: generative AI! Think about it: if AI-generated search results (or even direct use of AI chat interfaces) subsumes web search as a primary way to look up information, there will be no more motivation to crank out SEO-driven content. These kinds of articles will fade into obscurity as the only purpose for their existence (monetization) is gone. Perhaps we will be left with the blogosphere of old with webrings and RSS (not that these things went away but they're certainly not mainstream anymore). This, anyways, is my hope. No more blogging to entertain the robots. Just writing stuff you want to write and share with other like-minded folks online.
Here we go again: I'm so tired of crypto web3 LLMs. I'm positive there are wonderful applications for LLMs. The ChatGPT web UI seems great for summarizing information from various online sources (as long as you're willing to verify the things that you learn). But a lot fo the "AI businesses" coming out right now are just lightweight wrappers around ChatGPT. It's lazy and unhelpful. Probably the worst offenders are in the content marketing space. We didn't know how lucky we were back in the "This one weird trick for saving money" days. Now, rather than a human writing that junk, we have every article sounding like the writing voice equivalent of the dad from Cocomelon. Here's an approximate technical diagram of how these businesses work: Part 1 is what I like to call the "bilking process." Basically, you put up a flashy landing page promising content generation in exchange for a monthly subscription fee (or discounted annual fee, of course!). No more paying pesky writers! Once the husk of a company has secured the bag, part 2, the "bullshit process," kicks in. Customers provide their niches and the service happily passes queries over to the ChatGPT (or similar) API. Customers are rewarded with stinky garbage articles that sound like they're being narrated by HAL on Prozac in return. Success! I suppose we should have expected as much. With every new tech trend comes a deluge of tech investors trying to find the next great thing. And when this happens, it's a gold rush every time. I will say I'm more optimistic about "AI" (aka machine learning, aka statistics). There are going to be some pretty cool applications of this tech eventually—but your ChatGPT wrapper ain't it.
More in science
In a remote corner of the driest state in the country, Anne Heggli's team has been keeping watch over some of Earth’s oldest beings. Since 02012, Heggli’s NevCAN network has recorded conditions at the Nevada Bristlecone Preserve every eight minutes. The result is more than 120 million data points and a high-resolution portrait of how a bristlecone pine thrives. Paleoclimatologist Adam Csank showed how bristlecone microcores reveal the droughts and floods these trees survived long before us, a history that fine-tunes models of what's ahead. Artist and philosopher Jonathon Keats went further. “The most accurate clock,” he said, “is a tree.” His monumental artwork Centuries of the Bristlecone keeps bristlecone time, a clock calibrated to the trees' own growth over millennia. Together, Heggli, Keats and Csank made the case for long science: patient, continuous observation that will help us answer future urgent questions. “Data at this resolution,” Csank said, “is like a Rosetta Stone” for understanding nature’s resilience. At fourteen years young, the bristlecone record is just beginning, Heggli said, but it already holds the key to questions like these: How will bristlecones adapt? What happens when the droughts and floods they've weathered for millennia arrive faster and more frequently? “We can't answer the questions if we're not watching,” said Csank. “We are the stewards of this data,” Heggli concluded. “This is why we need long science.”
Prende y se apaga sola, sale después de hora. CHARLY GARCÍA La máquina de ser feliz I’ve learned to tolerate them, and sometimes even like them, but Zoom meetings are weird. Even in familiar contexts: I have weekly check-ins with … Continue reading →
the economics are especially interesting
[Note that this article is a transcript of the video embedded above.] If you have a fluid-filled system of pipes in your life, whether liquid or gas, (and who among us doesn’t?) there’s a very good chance that it passes through a simple device at some point on its journey to you. This device is almost unbelievably reliable for a purely mechanical system, and it has changed very little since the mid 1800s. So reliable that there’s a good chance you’ve probably never serviced or replaced one and maybe never even noticed one, despite them controlling so many aspects of our everyday lives. Of course, I’m talking about pressure regulators. But don’t let the jargon bore you, because these things are fascinating. They’re basically Victorian-era mechanical computers, and I cut one in half so we can see how it works. I’m Grady and this is Practical Engineering. “Control theory” is the branch of engineering that we use to describe managing dynamic systems, including the flow of fluids in pipes. I have a bunch of videos and demonstrations of just how dynamic those systems can get. A fundamental idea in this field is that, to garner any amount of control, you need some kind of feedback. And this is not a complicated idea. Say I want to control the pressure in my garden hose. I can put a pressure gauge on it, look at that gauge, and adjust the valve until I hit my setpoint. If something changes, like someone flushing all the toilets in the house simultaneously, I’m the feedback loop. I look at the gauge and make the change to get the pressure back to where it’s supposed to be. In fact, this exact situation (more or less) contributed to the pressure regulation equipment that we know and love today. The legend goes that in 1876, a massive fire broke out in Marshalltown, Iowa. William Fisher, a city engineer, spent all day and all night adjusting the throttle on steam-driven pumps by hand to manage the water pressure in the system to help the firefighters. Exhausted by the effort, he went on to develop the constant pressure pump governor, a precursor to the modern pressure regulators that are absolutely ubiquitous today. And I really mean that. Let’s take a little tour. One of the easiest regulators to find is on an air compressor. You generally want the reservoir as full as possible, which means pressurizing it to a level higher than what you would actually want out of the hose. Every air tool has its own maximum pressure, so you have a knob like this so that, no matter how much higher the pressure in the tank is, you get a consistent and controllable pressure out. If you use pressurized tanks of gas like oxygen, argon, or propane - exact same thing. You’re almost always going to see a regulator on top to control the pressure leaving the tank. Maybe you have a natural gas connection to your house. In most cases, residential plumbing and appliances are designed for very low pressures, like a half a psi or about 30 millibar. That’s great for getting gas from your basement up to your kitchen, but it’s hard to get gas to flow long distances at those pressures, so the lines feeding houses are usually at pressures quite a bit higher. You don’t want high pressure explosive gas in the walls of your house, so it has to be regulated down at the meter. That’s the pancake shaped device you often see outside. Even a standard pressure cooker has a regulator on top. A weight on top of a small pipe balances the steam pressure inside, providing only enough release to maintain a constant pressure inside. It’s not just gases either. The pressure in your water main can be too high for residential plumbing, so you might have a pressure reducing valve on your water service line. Most internal combustion vehicles have regulators that manage fuel pressure between the pump and injectors. And, of course, there are countless industrial applications of pressure regulators used in factories, power plants, and more. If you can find a pipe anywhere in the world, there’s a good chance that, no matter what’s in it, somewhere along it is a pressure regulating device. By the way, the stakes associated with pressure regulation are extremely high, particularly when it comes to natural gas. In 2018, the Merrimack Valley in Massachusetts saw over a hundred structures damaged by fire and explosions, 22 people injured, and 1 dead all as part of a single incident. It all came down to a mistake made during a pipe replacement project that kept the regulators from working correctly. This was a system where pressure was regulated down at a district level instead of each individual meter. The mistake sent natural gas into homes and businesses at pressures way above what the plumbing was designed to handle, ultimately resulting in one of the worst natural gas disasters in American history. I covered the whole story in a video a while back if you want to learn more after this. Here’s the thing: it’s not that complicated to reduce the pressure in a stream of fluid. Basically any kind of obstruction to the flow will do it. A simple way to do it is to put a flat plate with a hole inside the pipe. But a graph will show you why it’s not quite that easy. Let’s assume you have a constant pressure on the inlet side. If you graph the outlet pressure as a function of flow rate through the pipe, you don’t get a flat line, but a curve. And, critically, when there’s no flow, the pressure on the outlet side is the same as the inlet. There’s no reduction at all. If you let the pressure on the inlet vary, things get even more complicated. It’s easy to see why a static device, like an orifice plate, is not a very good regulator. There’s no feedback and no control. You definitely get a lower pressure in some situations, but if you need a consistent pressure that doesn’t exceed some maximum level, this is not going to work. Early gas regulators were bulky contraptions, but actually pretty simple. You could suspend an iron bell in a tank of water. A cast iron cone was attached to the top of the bell, sliding inside the inlet pipe. If the pressure inside the bell rose, it would float upward, pulling the cone too. The higher the cone is, the more restriction you get on the inlet pipe, decreasing the flow to maintain a consistent pressure leaving the device. It’s a pretty clever invention, but not entirely practical. The water level had to be maintained; it could freeze or get gross; the metal corrodes. And importantly, when it failed, it didn’t fail safely. If the bell sprung a leak or the counterweight cable broke, the cone would fall downward, fully opening the inlet. Modern regulators have a few features that improve on the original idea, and I happen to have a natural gas regulator so we can take a look inside. This is a used regulator that probably came from a large commercial building or a light industrial setting. And it’s actually built by Fisher Controls, the company William Fisher started after his firefighting pump throttling experience. Not a sponsor, but I like to think he would appreciate us cutting it up to learn more about it. I tried to be strategic about this to allow a look inside without it completely falling apart. From the outside, it kind of looks like gas would make a straight shot through, but when you cut it open, you can see that there's a separation here where the regulator connects to the line. I have it set where the discharge is pointed down. Gas has to pass through this valve to make it to the discharge side, and you can see that, past the valve, the discharge side is connected to this chamber in the main body of the regulator. Inside the chamber is this flexible membrane called the diaphragm sandwiched between the two sides of the housing. It’s a little floppier than usual, since I cut the whole thing in half, but hopefully you can still see how this works. This regulator has a stiffening plate attached to the diaphragm that acts against a spring at the top. The spring is a little too stiff for me to show you the full range of motion, so I’m going to take the seat off just to demonstrate. Let’s say there’s no demand for gas downstream. In that case, the pressure in the discharge line will build up, pushing the diaphragm upward. The diaphragm is connected to this lever, which is connected to a poppet, which pushes up against an orifice to close the valve, preventing gas from flowing. Let’s say someone opens a valve downstream, like a stove or a heater. As the gas flows out of the system, the pressure in the discharge line will fall, reducing the pressure on the diaphragm. The spring at the top will push the diaphragm down, lowering the lever, and opening the poppet so that gas can start flowing. If the demand increases, the pressure will drop further, lowering the diaphragm and opening the valve even more. And this system will constantly adjust to the downstream pressure, throttling the valve to keep it consistent - a completely mechanical control loop maintaining equilibrium. Any difference in the setpoint and actual downstream pressure creates a proportional movement of the diaphragm and poppet valve. And it’s adjustable too: The compression of the spring at the top can be increased or decreased, which allows you to dial in the exact pressure the regulator will supply. This is just so impressive to me. It’s a dead simple idea, but it does such an important job. But one of the difficulties, especially with natural gas, is that, like all mechanical devices, there’s some friction in the system. I mentioned that the downstream pressure of natural gas is pretty low. This regulator has an outlet range of about 1.5 to 3 psi above ambient air pressure, or about 100 to 200 millibar. Force is pressure times area. If the area of the diaphragm was small, the total force from the gas pressure acting against the spring would be practically indistinguishable within that range, especially when you consider the friction of the lever and valve. That’s why the diaphragm in natural gas regulators is so big. Even small changes in pressure create large difference in force, so you get more sensitivity, and the valve positions are more closely tied to the actual changes in pressure. You might see an issue with this design though: For the valve to open wider to allow more flow, the diaphragm must move down. For the diaphragm to move down, the pressure holding it up (the downstream pressure) must drop. Engineers call this droop, which I love. But there is still some variability in the downstream pressure. Pressure is tied to the valve position, so it’s necessary that it be allowed to fluctuate some. It will never be rock solid in this model. If you need that, the solution is usually a pilot-operated regulator. In this design, the downstream pressure is connected to a tiny, ultra-sensitive pilot regulator, and that regulator basically uses the higher-pressure inlet gas to move the main valve. In this way, you can go from 0 percent to 100 percent flow with almost no change in downstream pressure. Regulators can also be sensitive to inlet pressure. You can see on my model that the inlet pressure acts against the spring to open the valve. Of course the valve is a lot smaller than the diaphragm, so the effect isn’t as big, but there’s still a relationship between inlet pressure and outlet pressure, which isn’t always ideal. A lot of regulators work the opposite way, where the inlet pressure acts to close the valve. If you use a regulator on a tank, this can cause the counterintuitive issue of discharge pressure spiking as the tank empties, since the inlet to the regulator isn’t pushing as hard to close the valve. If you want to reduce this sensitivity, you can use a two stage regulator where you drop the pressure in steps. Let the first stage handle the coarse reduction, providing a more consistent inlet pressure to the second stage which can then keep the discharge pressure rock steady. One thing this regulator doesn’t do is fail closed. If this diaphragm rips, the outlet pressure won’t be able to push it upward to close the valve. So we have to account for that potential in other ways. Lots of gas systems will use a secondary, redundant regulator set to a slightly higher pressure that will take over if the primary fails. There is also a circuit breaker equivalent for gas systems called an overpressure shut-off or slam-shut. This model uses another option: an internal relief valve. Say the pressure on the discharge end somehow got too high. Maybe something got stuck in the valve, keeping it from fully closing. Or maybe the discharge line was exposed to sunlight, expanding the gas inside. In this case, the diaphragm can bottom out and act against this secondary spring, lifting off this plate. Gas is allowed to escape through a hole in the center of the diaphragm into the top half of the casing and out of this vent hole. And here we have another valve called a flapper. It can open inward to balance the pressure inside the regulator. And it can open outward if the relief valve activates, letting the excess pressure escape. The regulator would normally be mounted like this so the vent points downward, keeping rain out. And it has a screen so bugs don’t make a home inside. Obviously, this has some tradeoffs. This regulator has to be mounted outside or be attached to a ventilation pipe running outdoors to make sure it’s not releasing gas into a closed space. Even so, you don’t necessarily want to vent a bunch of natural gas outside. But because of the odorant that’s added to it, the idea is that someone would notice pretty quickly that some part of the system is malfunctioning and shut the line down for repairs. Like every part of engineering, it’s a game of tradeoffs: pressure versus flow, capacity versus cost, accuracy versus redundancy, and safety here versus safety there. I just love that there’s stuff like this out there, pretty much anywhere you’re willing to look, doing an essential job that few people even consider, and that their basic function really hasn’t changed in centuries. Samuel Clegg, one of the early engineers in natural gas systems had this to say about the pressure regulator: “Its use is nowhere sufficiently appreciated. Had it been a complicated piece of machinery, or expensive in its first cost and after application, objections to its adoption would not have been surprising; but it is perfectly simple: its action is certain and unvarying, and its first cost inconsiderable.” Nearly 200 years later, I couldn’t have put it any better myself.
TLDR: yes, models are getting funnier over time I love laughing. Well, who doesn’t? Good jokes have a certain notion of cleverness to them and I do believe that great comedians display high intelligence. Cracking a good joke requires astute observations about odd situations, and linking them to something we find familiar. Jokes are hard!… Read More The post How funny are the frontier AI models? appeared first on Inverted Passion.