Reservoir Sampling, Or How To Sample Sets Of Unknown Size

Selecting a random sample from a set is simple. But what about selecting a fair random sample from a set of unknown or indeterminate size? That’s where reservoir sampling comes in, and [Sam Rose] has a beautifully-illustrated, interactive guide to how reservoir sampling works. As far as methods go, it’s as elegant as it is simple, and particularly suited to fairly sampling dynamic datasets like sipping from a firehose of log events.

While reservoir sampling is simple in principle it’s not entirely intuitive to everyone. That’s what makes [Sam]’s interactive essay so helpful; he first articulates the problem before presenting the solution in a way that makes it almost self-evident.

[Sam] uses an imaginary deck of cards to illustrate the problem. If one is being dealt cards one at a time from a deck of unknown size (there could be ten cards, or a million), how can one choose a single card in a way that gives each an equal chance of having been selected? Without collecting them all first?

In a nutshell, the solution is to make a decision every time a new card arrives: hold onto the current card, or replace it with the new one. Each new card is given a 1/n chance of becoming held, where n is the number of cards we’ve seen so far. That’s all it takes. No matter when the dealer stops dealing, each card that has been seen will have had an equal chance of ending up the one selected.

There are a few variations which [Sam] also covers, and practical ways of applying it to log collection, so check it out for yourself.

If [Sam]’s knack for illustrating concepts in an interactive way is your jam, we have one more to point out. Our own Al Williams wrote a piece on Turing machines; the original “universal machine” being a theoretical device with a read/write head and infinite paper tape. A wonderful companion to that article is [Sam]’s piece illustrating exactly how such a Turing machines would work in an interactive way.

Turbine Blower 3D Prints Every Part, Including Triple Planetary Gears

There was a time when print-in-place moving parts were a curiosity, but [Tomek] shows that things are now at a point where a hand-cranked turbine blower with integrated planetary gears can be entirely 3D printed. Some assembly is needed, but there is no added hardware beyond the printed parts. The blower is capable of decent airflow and can probably be optimized even further. Have a look at it work in the video below.

Every piece being 3D printed brings a few advantages. Prefer the hand crank on the other side? Simply mirror everything. Want a bigger version? Just scale everything up. Because all of the fasteners are printed as well as the parts, there’s no worry about external hardware no longer fitting oversized holes after scaling things up (scaling down might run into issues with tolerances, but if you manage an extra-small version, we’d love to hear about it).

There are a few good tips that are worth keeping in mind when it comes to print-in-place assemblies with moving parts. First, changing the seam location for each layer to ‘Random’ helps make moving parts smoother. This helps prevent the formation of a seam line, which can act as a little speed bump that gets in the way of smooth movement.

The other thing that helps is lubrication. A plastic-safe lubricant like PTFE-based Super Lube is a handy thing to have around the workshop and does wonders for smoothing out the action of 3D-printed moving parts. And we can attest that rubbing candle wax on mating surfaces works pretty well in a pinch.

One downside is that the blower is noisy in operation. 3D printed gears (and even printed bearings) can be effective, but do contribute to a distinct lack of silence compared to their purpose-built versions.

Still, a device like this is a sign of how far 3D printing has come, and how it enables projects that would otherwise remain an idea in a notebook. We do love 3D-printed gears.

Continue reading “Turbine Blower 3D Prints Every Part, Including Triple Planetary Gears”

Minecraft Clone Manages With Nothing But HTML + CSS

Can a 3D Minecraft implementation be done entirely in CSS and HTML, without a single line of JavaScript in sight? The answer is yes!

True, this small clone is limited to playing with blocks in a world that measures only 9x9x9, but the fact that [Benjamin Aster] managed it at all using only CSS and pure HTML is a fantastic achievement. As far as proofs of concept go, it’s a pretty clever one.

The project consists of roughly 40,000 lines of HTML radio buttons and labels, combined with fewer than 500 lines of CSS where the real work is done. In a short thread on X [Benjamin] explains that each block in the 9x9x9 world is defined with the help of tens of thousands of <label> and <input type="radio"> elements to track block types and faces, and CSS uses that as a type of display filter. Clicking a block is clicking a label, and changing a block type (“air” or no block is considered a type of block) switches which labels are visible to the user.

Viewing in 3D is implemented via CSS animations which apply transforms to what is displayed. Clicking a control starts and stops the animation, resulting in a view change. It’s a lot of atypical functionality for plain HTML and CSS, showing what is possible with a bit of out-of-the-box thinking.

[Simon Willison] has a more in-depth analysis of CSS-Minecraft and how it works, and the code is on GitHub if you want a closer look.

Once you’re done checking that out and hungry for more cleverness, don’t miss Minecraft in COBOL and Minecraft Running in… Minecraft.

Spiral Connector Makes Fastener-Free Assemblies

[Anton Gaia]’s SPIRAL sculpture resembles an organizer or modern shelving unit, but what’s really interesting is how it goes together. It’s made entirely from assembling copies of a single component (two, if you count the short ‘end pieces’ as separate) without a fastener in sight. [Anton] made the 3D model available, so check it out for yourself!

The self-similar design of the joint, based on the golden spiral, makes a self-supporting joint that requires neither glue nor fasteners.

The ends of each part form a tight, spiral-shaped joint when assembled with its neighbors. Parts connect solely to themselves without any need of fasteners or adhesives.

The end result is secure, scalable, and with a harmonious structure that is very pleasing to look at. Small wonder [Anton] used it as the basis for artistic work. You can see more pictures here.

The design of the joint is based on the golden spiral (which it turns out is also a pretty useful chicken coop architecture.)

The parts lend themselves quite well to 3D printing, and we’d like to take a moment to appreciate that [Anton] shared the .step file instead of just an STL. STEP (or STP) files can be imported meaningfully into CAD programs, making it much easier to incorporate the design into one’s own work. STEP is also supported natively in many 3D printer slicers, so there’s no need to convert formats just to print them.

A brief video describing SPIRAL is embedded just below, with a closer look at how the pieces fit together.

Continue reading “Spiral Connector Makes Fastener-Free Assemblies”

Dual RGB Cameras Get Depth Sensing Powerup

It’s sometimes useful for a system to not just have a flat 2D camera view of things, but to have an understanding of the depth of a scene. Dual RGB cameras can be used to sense depth by contrasting the two slightly different views, in much the same way that our own eyes work. It’s considered an economical but limited method of depth sensing, or at least it was before FoundationStereo came along and blew previous results out of the water. That link has a load of interactive comparisons to play with and see for yourself, so check it out.

A box of disordered tools at close range is understood very well, and these results are typical for the system.

The FoundationStereo paper explains how researchers leveraged machine learning to create a system that can not only outperform existing dual RGB camera setups, but even active depth-sensing cameras such as the Intel RealSense.

FoundationStereo is specifically designed for strong zero-shot performance, meaning it delivers useful general results with no additional training needed to handle any particular scene or environment. The framework and models are available from the project’s GitHub repository.

While products like Microsoft’s Kinect have struggled to keep the consumer’s attention, depth sensing remains an enabling technology that opens possibilities and gives rise to interesting projects, like a headset that allows one to see the world through the eyes of a depth sensor.

The ability to easily and quickly gain an understanding of the physical layout of a space is a powerful tool, and if a system like this one can deliver such fantastic results with nothing more than two RGB cameras, that’s a great sign. Watch it in action in the video below.

Continue reading “Dual RGB Cameras Get Depth Sensing Powerup”

Flopped Humane “AI Pin” Gets An Experimental SDK

The Humane AI Pin was ambitious, expensive, and failed to captivate people between its launch and shutdown shortly after. While the units do contain some interesting elements like the embedded projector, it’s all locked down tight, and the cloud services that tie it all together no longer exist. The devices technically still work, they just can’t do much of anything.

The Humane AI Pin had some bold ideas, like an embedded projector. (Image credit: Humane)

Since then, developers like [Adam Gastineau] have been hard at work turning the device into an experimental development platform: PenumbraOS, which provides a means to allow “untrusted” applications to perform privileged operations.

As announced earlier this month on social media, the experimental SDK lets developers treat the pin as a mostly normal Android device, with the addition of a modular, user-facing assistant app called MABL. [Adam] stresses that this is all highly experimental and has a way to go before it is useful in a user-facing sort of way, but there is absolutely a workable architecture.

When the Humane AI Pin launched, it aimed to compete with smartphones but failed to impress much of anyone. As a result, things folded in record time. Humane’s founders took jobs at HP and buyers were left with expensive paperweights due to the highly restrictive design.

Thankfully, a load of reverse engineering has laid the path to getting some new life out of these ambitious devices. The project could sure use help from anyone willing to pitch in, so if that’s up your alley be sure to join the project; you’ll be in good company.

Tune In To “Higher Lower”, The Minimal Handheld Electronic Game

[Tommy] has a great write-up about designing and building a minimalistic handheld electronic game called “Higher Lower”. It’s an audio-driven game in which the unit plays two tones and asks the player to choose whether the second tone was higher in pitch, or lower. The game relies on 3D printed components and minimal electronics, limiting player input to two buttons and output to whatever a speaker stuck to an output pin from an ATtiny85 can generate.

Fastener-free enclosure means fewer parts, and on the inside are pots for volume and difficulty. We love the thoughtful little tabs that hold the rocker switch in place during assembly.

Gameplay may be straightforward, but working with so little raises a number of design challenges. How does one best communicate game state (and things like scoring) with audio tones only? What’s the optimal way to generate a random seed when the best source of meaningful, zero-extra-components entropy (timing of player input) happens after the game has already started? What’s the most efficient way to turn a clear glue stick into a bunch of identical little light pipes? [Tommy] goes into great detail for each of these, and more.

In addition to the hardware and enclosure design, [Tommy] has tried new things on the software end of things. He found that using tools intended to develop for the Arduboy DIY handheld console along with a hardware emulator made for a very tight feedback loop during development. Being able to work on the software side without actually needing the hardware and chip programmer at hand was also flexible and convenient.

We’ve seen [Tommy]’s work before about his synth kits, and as usual his observations and shared insights about bringing an idea from concept to kit-worthy product are absolutely worth a read.

You can find all the design files on the GitHub repository, but Higher Lower is also available as a reasonably-priced kit with great documentation suitable for anyone with an interest. Watch it in action in the video below.

Continue reading “Tune In To “Higher Lower”, The Minimal Handheld Electronic Game”