<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Ibrahim Rayamah — writings</title><description>Ibrahim Rayamah is an engineer who writes about AI, economics and the long history behind how the world ended up this way. Essays, notes and open source projects.</description><link>https://www.ibz04.pro</link><language>en-us</language><item><title>Why Africa is poor</title><link>https://www.ibz04.pro/blog/why-africa-is-poor</link><guid isPermaLink="true">https://www.ibz04.pro/blog/why-africa-is-poor</guid><description>The continent sits on trillions in resources and still cannot pay its own bills, why is that?.</description><pubDate>Tue, 18 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;The question&lt;/h2&gt;
&lt;p&gt;Africa is the poorest continent on earth, and as the ::factories=factory:: of Asia finished developing, it kept falling further behind. Most of the world&apos;s extreme poverty now sits in &lt;a href=&quot;https://en.wikipedia.org/wiki/Sub-Saharan_Africa&quot;&gt;&lt;em&gt;&lt;strong&gt;Sub-Saharan Africa&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt;, and the income gap between a lot of African countries and rich ones has widened to a factor of 40 or 50. Of course Treating a continent as one economic case study is a silly thing to do. There are &lt;strong&gt;54 countries&lt;/strong&gt; in Africa with their own governments, currencies and problems, and asking one question about all of them is like assuming the US and Ecuador run on the same machinery. But poverty is the one thing that is close to universal here. There are outliers like Mauritius, the Seychelles and &lt;a href=&quot;https://en.wikipedia.org/wiki/Botswana&quot;&gt;Botswana&lt;/a&gt;, and even then the richest country on the continent by GDP per capita would sit in the lower middle of Europe.&lt;/p&gt;
&lt;h2&gt;The obvious answer is not enough&lt;/h2&gt;
&lt;p&gt;The symptoms are well known, i mean ... Political instability, corruption, capital that gets destroyed or seized, which makes ::industry=factory:: risky to build, which means fewer good jobs, which means poorer people, which feeds more instability. Add the modern version on top, where open trade makes it harder for young African industries to compete and easier for the best African workers to leave for a better salary somewhere else.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;Land&lt;/strong&gt; is a factor of production, and in the early game it is the important one, because good land feeds more people, and more people means some of them can stop farming and go discover new things.
Africa has plenty of land, what it did not have was &lt;strong&gt;easy&lt;/strong&gt; land. The ::desert:: splits the continent east to west, and for most of human history the Sahara worked like an ocean, which left everything south of it cut off from the trade and the ideas moving between Europe, the Middle East and Asia. That single feature is why economists usually split North Africa off from Sub-Saharan Africa and treat them as separate stories.&lt;/p&gt;
&lt;p&gt;The soil is even worse, green parts of the centre have fragile ::soil=crop:: that erodes fast unless you manage it with techniques nobody had a thousand years ago. There was not much reason to farm, foraging was simply cheaper and the lush parts came with tropical ::disease::, insects and predators. Anthropologists have a name for the thing that did not happen here, &lt;strong&gt;the trap of sedentism&lt;/strong&gt;. A group finds somewhere with fresh ::water::, wood and no predators, settles in for generations, eats the place clean, and now farming is the only option left because they already forgot how to move. Those gardens of eden barely existed in Africa, so groups stayed small and kept walking.&lt;/p&gt;
&lt;p&gt;Fast forward and you get a continent with hundreds of languages and thousands of ethnic groups, drawn over with borders somebody else invented. Many countries ended up landlocked with no ocean access, connected to their neighbours by dirt ::roads=road::, or by ::railways=rail:: left behind by empires that built them to haul ore to a ::port::, not to build an economy. Much of the west coast is raised and awkward to build shipping ::ports=port:: on. So before anyone was even here, this was not a great spawn point.&lt;/p&gt;
&lt;h2&gt;But geography is not the answer&lt;/h2&gt;
&lt;p&gt;The economists who dug into this hardest, &lt;a href=&quot;https://en.wikipedia.org/wiki/Daron_Acemoglu&quot;&gt;Daron Acemoglu&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/James_A._Robinson_(economist)&quot;&gt;James A. Robinson&lt;/a&gt;, asked whether geography explains the size of the gap, and their answer was a flat no. Geography matters, you cannot understand Saudi Arabia without ::oil:: or Ukraine without who it is standing next to, but institutions also matter more.&lt;/p&gt;
&lt;p&gt;Their favourite example is the ::wheel::. Even after wheels were common knowledge, a lot of groups kept moving heavy things on their heads, which is wildly less efficient than a hand cart. That looks irrational until you look at who was in charge. Rulers taxed by decree and took what they wanted by force, so groups that wanted to be left alone moved away from the few ::roads=road:: that existed, and nobody wanted to build a nice cart that could just be confiscated. The ruling institutions were quietly paying people to stay poor and self sufficient, and that habit outlived them.&lt;/p&gt;
&lt;h2&gt;Guns and extraction&lt;/h2&gt;
&lt;p&gt;Atlantic ::ships=ship:: needed labour because the plantations in the Americas were burning through people faster than they could be replaced. Some African rulers already used forced labour and were willing to trade captives for European ::guns::. That trade was self reinforcing in the ugliest way, because a gun is both property and the tool that enforces property, so it was the one piece of technology a strong man could hold onto. Powerful groups got more powerful by selling their rivals, and the money bought more guns.&lt;/p&gt;
&lt;p&gt;Europe did not colonise the interior at that point because African armies on home ground with malaria on their side were genuinely expensive to fight. Sailing across an ocean was easier, which tells you something. Then steam ::ships=ship::, industrial ::steel:: and basic malaria treatment changed the maths, and the continent went from trading partner to target.
When the empires left, they took the ::tools=tool::, the management and the industrial relations with them, and ::education=school:: was close to nonexistent and worse, they had spent decades hollowing out whatever legitimate local institutions existed and replacing them with a thin administrative shell that reached the capital and nothing else. That shell was useless for building an economy.&lt;/p&gt;
&lt;h2&gt;The piggy bank problem&lt;/h2&gt;
&lt;p&gt;The ::diamonds=diamond::, the ::oil::, the metals, the rare earths the whole world now needs for batteries, trillions of dollars sitting in the ground. In a lot of countries that wealth became the ruler&apos;s ::money:: for staying in power, not the country&apos;s budget for building ::schools=school:: and ::ports=port::, and it compounds into a reputation. Any project in Africa gets priced as riskier than the same project anywhere else, so obviously good infrastructure never gets funded. We saw this with the pipeline stalling in Niger, one of the easiest returns on investment you could draw up, and still not worth it once the politics turned. High global interest rates make it worse, because if you can park cash somewhere safe and still earn a solid return, why take the risk at all.&lt;/p&gt;
&lt;h2&gt;Botswana&lt;/h2&gt;
&lt;p&gt;Now let us move to the &lt;strong&gt;optimistic&lt;/strong&gt; part, because that paper is over a decade old. &lt;a href=&quot;https://en.wikipedia.org/wiki/Economy_of_Botswana&quot;&gt;&lt;em&gt;&lt;strong&gt;Botswana&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; has every excuse. Landlocked, hard to move around, dirt poor at independence with almost no ::roads=road:: and barely any educated elite, and it has diamonds, which for other countries has been a curse. It became one of the fastest growing economies in the world over 60 years, because it built the boring stuff. Stable property rights, ::courts=court:: that did not just serve one group, a ::democracy=vote:: that mostly worked, real spending on people and ::education=school::, and diamond revenue managed like it belonged to the country.&lt;/p&gt;
&lt;p&gt;It is worth remembering that 50 years ago most of Asia looked like much of Africa does today, and 300 years ago, which is nothing, the richest western countries produced about what the continent produces now. Economic success feeds on itself, and so does failure, which means most economies in history were stagnant right up until they were not. If Africa&apos;s turn comes, it will look sudden, and it will not have been.&lt;/p&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Acemoglu Robinson 2010 Why is Africa poor Economic History of Developing Regions&lt;/li&gt;
&lt;li&gt;Acemoglu Robinson 2012 Why Nations Fail Crown Business&lt;/li&gt;
&lt;li&gt;Acemoglu Johnson Robinson 2001 The colonial origins of comparative development American Economic Review&lt;/li&gt;
&lt;li&gt;Nunn 2008 The long term effects of Africas slave trades Quarterly Journal of Economics&lt;/li&gt;
&lt;li&gt;World Bank 2025 Poverty and Shared Prosperity data&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>History</category><category>Econs</category><category>Geography</category><author>Ibrahim Rayamah</author></item><item><title>Global path dependence</title><link>https://www.ibz04.pro/blog/global-path-dependence</link><guid isPermaLink="true">https://www.ibz04.pro/blog/global-path-dependence</guid><description>Why Europe lead today is less about IQ and more about geography, crops, animals, and germs.</description><pubDate>Tue, 04 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;The question&lt;/h2&gt;
&lt;p&gt;Why is the world the way it is today, with America and Europe leading, and the majority of the rest of the world behind, how did Europeans conquer the world?&lt;/p&gt;
&lt;p&gt;I hear a lot of talk and complaints about &lt;a href=&quot;https://en.wikipedia.org/wiki/Colonialism&quot;&gt;&lt;strong&gt;colonization&lt;/strong&gt;&lt;/a&gt;, but why didn&apos;t Africa or the Americas colonize Europe instead of the other way around? One side had ::steel::, ::swords::, ::guns::, ::horses::, oceangoing ::ships::, ::writing:: systems, and centralized ::kingdoms::, the other side had mostly ::stone:: and wooden weapons. To understand how some societies won the geographic lottery, we need to rewind the clock to about 11,000 BC.&lt;/p&gt;
&lt;h2&gt;Same starting line&lt;/h2&gt;
&lt;p&gt;At that point, humans everywhere were remarkably similar, they were &lt;a href=&quot;https://en.wikipedia.org/wiki/Homo_sapiens&quot;&gt;&lt;em&gt;&lt;strong&gt;Homo sapiens&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; with basically the same brains, the same cognitive abilities, and the same potential. There were minor differences like skin color, body type, or adaptations to local climates, but a baby born in Europe had no advantage over a baby born in Australia, the Americas, or Africa, everyone was a &lt;a href=&quot;https://en.wikipedia.org/wiki/Hunter-gatherer&quot;&gt;&lt;strong&gt;hunter-gatherer&lt;/strong&gt;&lt;/a&gt;. So if everyone started at roughly the same place, how did things diverge so dramatically?&lt;/p&gt;
&lt;h2&gt;The IQ myth&lt;/h2&gt;
&lt;p&gt;Most ignorant people say well, Native Americans and Africans had lower IQs and that&apos;s why they never caught up with Europe.&lt;/p&gt;
&lt;p&gt;But modern &lt;a href=&quot;https://en.wikipedia.org/wiki/Intelligence_quotient&quot;&gt;&lt;strong&gt;IQ tests&lt;/strong&gt;&lt;/a&gt; measure abstract reasoning, literacy, and mathematical concepts taught in schools, they were designed by academics to predict success in industrialized education systems. A researcher spent years working in &lt;a href=&quot;https://en.wikipedia.org/wiki/New_Guinea&quot;&gt;&lt;strong&gt;New Guinea&lt;/strong&gt;&lt;/a&gt;, and one thing that struck him immediately was that people there were exceptionally observant, inventive, and mentally sharp. To survive you had to know which plants were poisonous, how to read the weather, how to track animals, and mistakes would get you killed. If you gave a New Guinean farmer an IQ test designed for an American suburb, he&apos;d fail, obviously, he has never seen the references or types of problems the test assumes. But if you gave a Harvard graduate a New Guinea &quot;IQ test&quot; and made him track an animal through the forest or navigate without a GPS, he&apos;d fail with flying colours too.&lt;/p&gt;
&lt;p&gt;Geography determines which societies can develop &lt;a href=&quot;https://en.wikipedia.org/wiki/History_of_agriculture&quot;&gt;&lt;strong&gt;agriculture&lt;/strong&gt;&lt;/a&gt;, and agriculture determines everything that comes after. The societies that figured it out got a massive head start by thousands of years, and by the time Europeans crossed the Atlantic with guns and steel, they had a 5,000-year advantage.&lt;/p&gt;
&lt;h2&gt;Why hunter-gatherers couldn&apos;t just catch up&lt;/h2&gt;
&lt;p&gt;Why couldn&apos;t hunter-gatherers develop their own complex civilizations?Because they have to stay mobile, they follow herds and track seasonal plants. If food moves, they move, and that mobility creates constraints.&lt;/p&gt;
&lt;p&gt;Everyone is in food-gathering mode. Calories are tough to come by, and they take a tribe&apos;s time and effort. When you&apos;re constantly on the move, you can&apos;t accumulate possessions, you can&apos;t store food long term, everything you own has to be carried on your back, that means no heavy ::pottery::, ::tools::, or building materials. A nomadic mother can only carry one ::child=baby:: while she&apos;s also gathering food and hauling possessions, so hunter-gatherer women spaced births out about four years apart. Settled farmers spaced births about every two years, that&apos;s half the population growth rate right there, and over centuries that difference compounds into massive population gaps.
If you break your leg in a settled farming village, you heal, but break your leg as a nomad and you&apos;re a burden the group can&apos;t afford, either they leave you behind, or the whole group slows down and risks starvation. The same goes for the elderly or the sick. And forget about developing complex technology that requires time to tinker, experiment, and fail, it&apos;s time you don&apos;t have when you&apos;re spending every day searching for food. The first societies to stop moving were the first to start building. Agriculture allowed people to settle down, accumulate surplus food, and that surplus changed everything.&lt;/p&gt;
&lt;h2&gt;The plant jackpot&lt;/h2&gt;
&lt;p&gt;You might be thinking, okay, so why didn&apos;t everyone just figure out agriculture at the same time, how hard can it be to plant some seeds?&lt;/p&gt;
&lt;p&gt;As it turns out, it&apos;s really hard. Agriculture didn&apos;t happen everywhere at once, it happened in a handful of specific places, and those places shared something important, they hit the plant and animal jackpot. Most wild plants are inedible, poisonous, or so low in calories that they&apos;re not worth cultivating. Out of hundreds of thousands of plant species on Earth, only a few dozen ever made good crops. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Fertile_Crescent&quot;&gt;&lt;em&gt;&lt;strong&gt;Fertile Crescent&lt;/strong&gt;&lt;/em&gt;&lt;/a&gt; had a whole bunch of them. The region stretching from modern-day Egypt through Israel, Lebanon, Syria, and down into Iraq and Iran held wild ::wheat::, ::barley::, ::peas::, and ::lentils:: growing naturally, and those weren&apos;t finicky plants, they had large ::seeds::, predictable growth cycles, and they could be replanted easily. China got lucky too with &lt;a href=&quot;https://en.wikipedia.org/wiki/Rice&quot;&gt;&lt;strong&gt;rice&lt;/strong&gt;&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Millet&quot;&gt;&lt;strong&gt;millet&lt;/strong&gt;&lt;/a&gt;, both solid crops that could support dense populations.&lt;/p&gt;
&lt;p&gt;The Americas eventually developed ::corn::, but wild corn, called &lt;a href=&quot;https://en.wikipedia.org/wiki/Teosinte&quot;&gt;&lt;strong&gt;teosinte&lt;/strong&gt;&lt;/a&gt;, was basically useless. It took Native Americans about 3,000 years of selective breeding to turn it into something that resembled modern corn. Think about that, while one group spent thousands of years slowly improving a single crop, people in the Fertile Crescent were already building cities. &lt;a href=&quot;https://en.wikipedia.org/wiki/Sub-Saharan_Africa&quot;&gt;&lt;strong&gt;Sub-Saharan Africa&lt;/strong&gt;&lt;/a&gt; had &lt;a href=&quot;https://en.wikipedia.org/wiki/Sorghum&quot;&gt;&lt;strong&gt;sorghum&lt;/strong&gt;&lt;/a&gt;, a decent crop, but Africa had fewer plant species to choose from overall. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Sahara&quot;&gt;&lt;strong&gt;Sahara&lt;/strong&gt;&lt;/a&gt; also created a massive barrier that slowed the spread of agriculture and information from the Fertile Crescent. Australia essentially got nothing that could be farmed. About 33 of the world&apos;s 56 most valuable wild grasses grew in the Fertile Crescent, that&apos;s why agriculture started there first, they had the raw materials.&lt;/p&gt;
&lt;h2&gt;The animal jackpot&lt;/h2&gt;
&lt;p&gt;Plants are only half the story, animals matter just as much. There are lots of species, but only a few are easy to handle. Throughout human history, only about 14 large mammal species have ever been successfully &lt;a href=&quot;https://en.wikipedia.org/wiki/Domestication&quot;&gt;&lt;strong&gt;domesticated&lt;/strong&gt;&lt;/a&gt;. There are strict requirements, it has to grow fast and breed in captivity, and it needs a calm enough disposition so it won&apos;t kill you.&lt;/p&gt;
&lt;p&gt;Again, &lt;a href=&quot;https://en.wikipedia.org/wiki/Eurasia&quot;&gt;&lt;strong&gt;Eurasia&lt;/strong&gt;&lt;/a&gt; hit the jackpot with ::sheep::, ::goats::, ::pigs::, ::cows::, ::horses::, ::donkeys::, ::camels::. That&apos;s seven of the big 14 right there. South America had &lt;a href=&quot;https://en.wikipedia.org/wiki/Llama&quot;&gt;&lt;strong&gt;llamas&lt;/strong&gt;&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Alpaca&quot;&gt;&lt;strong&gt;alpacas&lt;/strong&gt;&lt;/a&gt;. North America, Africa, and Australia had zero.&lt;/p&gt;
&lt;p&gt;It&apos;s not like people didn&apos;t try. Native Americans desperately wanted to domesticate &lt;a href=&quot;https://en.wikipedia.org/wiki/American_bison&quot;&gt;&lt;strong&gt;bison&lt;/strong&gt;&lt;/a&gt;. Africans tried with &lt;a href=&quot;https://en.wikipedia.org/wiki/Zebra&quot;&gt;&lt;strong&gt;zebras&lt;/strong&gt;&lt;/a&gt; and antelope, but it didn&apos;t work. Zebras look like stripey ::horses::, but they&apos;re vicious, they bite and kick hard enough to kill a lion. Even today, with all our knowledge and tech, we still can&apos;t domesticate zebras on a broad scale. Horses are trainable, zebras just aren&apos;t wired that way. This wasn&apos;t a failure of effort or ingenuity, it was biology and luck.&lt;/p&gt;
&lt;h2&gt;East west vs north south&lt;/h2&gt;
&lt;p&gt;Geography shaped one more crucial advantage. Eurasia runs east west. You can travel about 5,000 miles from Portugal to China and stay at roughly the same latitude, same climate, same growing season, same day length. ::Wheat:: domesticated in the Fertile Crescent could spread to Europe, India, and China. ::Farmers:: didn&apos;t have to reinvent agriculture, they could take what worked in one place and plant it somewhere else.&lt;/p&gt;
&lt;p&gt;Africa and the Americas run north south. Try taking ::corn:: from Mexico and planting it in Canada, it doesn&apos;t work, different growing seasons, different climates. Crops hit climate-zone barriers and stop spreading. Africa has the same problem, especially with the Sahara cutting it in half, that means thousands of years of agricultural knowledge that never spread. While Eurasian farmers were swapping seeds and sharing innovations across an entire continent, American and African farmers were often stuck starting from scratch.&lt;/p&gt;
&lt;h2&gt;Surplus builds empires&lt;/h2&gt;
&lt;p&gt;Once agriculture takes hold, everything changes, because now there&apos;s a food surplus, and that surplus builds empires.
When 20 farmers can feed a hundred people, not everyone needs to spend the day hunting and gathering. Surplus gives you extra calories and extra time, it creates specialists. In a hunter-gatherer band, everyone hunts and gathers, there&apos;s no room for someone who sits around thinking about better tools. Once you have agriculture, you can afford people who don&apos;t produce food. One of the first things you need with surplus food is a way to store it permanently, then you need people to guard it from animals or other tribes, someone has to organize distribution, and the basics of government start to emerge. Later, professional ::armies:: conquer neighbors, and those conquests bring more land, more resources, more ::people=population::, civilization grows.&lt;/p&gt;
&lt;h2&gt;Competition and connectivity&lt;/h2&gt;
&lt;p&gt;Here&apos;s where political structure becomes crucial. Eurasia was fragmented in a way that actually helped ideas spread. It wasn&apos;t one giant unified empire, but competing kingdoms, city-states, and feudal territories connected by trade and migration. When one ::kingdom:: invented something useful like better ::plows::, bronze weapons, or &lt;a href=&quot;https://en.wikipedia.org/wiki/Gunpowder&quot;&gt;&lt;strong&gt;gunpowder&lt;/strong&gt;&lt;/a&gt;, that knowledge spread. Merchants carried innovations along routes, craftsmen moved between territories, and with important technology, you either adapted or someone took you over with it.&lt;/p&gt;
&lt;p&gt;The east west axis meant those innovations could travel thousands of miles without hitting climate barriers. Gunpowder invented in China reached Europe, steelmaking techniques developed in the Middle East spread to India and Europe. The Americas didn&apos;t have that same connectivity. The &lt;a href=&quot;https://en.wikipedia.org/wiki/Maya_civilization&quot;&gt;&lt;strong&gt;Maya&lt;/strong&gt;&lt;/a&gt; developed writing, but it never spread to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Inca_Empire&quot;&gt;&lt;strong&gt;Inca&lt;/strong&gt;&lt;/a&gt; or the &lt;a href=&quot;https://en.wikipedia.org/wiki/Aztec_Empire&quot;&gt;&lt;strong&gt;Aztecs&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;China had the opposite problem of too much unity. When China&apos;s emperor decided to halt oceanic exploration in the 1400s, that decision stuck for the entire empire. In Europe, when one kingdom stopped exploring, others continued. Spain&apos;s rivals couldn&apos;t afford to let Spain monopolize the New World. Technology builds on itself. Eurasia moved from stone ::tools:: to copper to bronze to ::iron=steel::. When &lt;a href=&quot;https://en.wikipedia.org/wiki/Hern%C3%A1n_Cort%C3%A9s&quot;&gt;&lt;strong&gt;Cortés&lt;/strong&gt;&lt;/a&gt; arrived in the Americas in the 1500s, the Aztecs were still using stone-age tools. They had &lt;a href=&quot;https://en.wikipedia.org/wiki/Obsidian&quot;&gt;&lt;strong&gt;obsidian&lt;/strong&gt;&lt;/a&gt; blades, which weren&apos;t terrible, but against steel swords it wasn&apos;t even close. That wasn&apos;t because the Aztecs were dumb or lazy, they started late, they didn&apos;t have Eurasia&apos;s 5,000-year head start. The Fertile Crescent got agriculture around 8500 BC, &lt;a href=&quot;https://en.wikipedia.org/wiki/Mesoamerica&quot;&gt;&lt;strong&gt;Mesoamerica&lt;/strong&gt;&lt;/a&gt; didn&apos;t get it until around 3500 BC.&lt;/p&gt;
&lt;p&gt;Put that in modern terms. Imagine the United States being attacked by a civilization just a hundred years younger, the 1926 US Army attacking modern America, it wouldn&apos;t be a fight. Now reverse it, imagine a society 5,000 years more advanced attacking us, I can&apos;t even fathom what that looks like. That&apos;s the situation the Incas, Native Americans, and many African societies faced when Europeans arrived, they were fighting enemies millennia ahead of them.&lt;/p&gt;
&lt;h2&gt;Germs, the deadliest weapon&lt;/h2&gt;
&lt;p&gt;But the most fearsome thing Europeans brought to the Americas wasn&apos;t guns, steel, or horses, it was ::germs::, Europe&apos;s invisible and unintentional weapon.&lt;/p&gt;
&lt;p&gt;Scholars generally agree that over 90% of the indigenous population of the Americas died from disease after European contact. If you lived in a village of a hundred people, within a generation only a handful would still be alive. &lt;a href=&quot;https://en.wikipedia.org/wiki/Smallpox&quot;&gt;&lt;strong&gt;Smallpox&lt;/strong&gt;&lt;/a&gt; killed more Native Americans than all European weapons combined.&lt;/p&gt;
&lt;p&gt;Some empires collapsed before Europeans even showed up. The Inca emperor &lt;a href=&quot;https://en.wikipedia.org/wiki/Huayna_Capac&quot;&gt;&lt;strong&gt;Huayna Capac&lt;/strong&gt;&lt;/a&gt; died of smallpox in 1527 without ever seeing a Spaniard. The disease traveled faster than the &lt;a href=&quot;https://en.wikipedia.org/wiki/Conquistador&quot;&gt;&lt;strong&gt;conquistadors&lt;/strong&gt;&lt;/a&gt;, spreading through trade routes and wiping out populations before Europeans arrived to conquer them.&lt;/p&gt;
&lt;p&gt;By the time &lt;a href=&quot;https://en.wikipedia.org/wiki/Francisco_Pizarro&quot;&gt;&lt;strong&gt;Pizarro&lt;/strong&gt;&lt;/a&gt; marched into Peru, the Inca Empire was already in chaos. A smallpox epidemic had killed the previous emperor and sparked a civil war over succession.&lt;/p&gt;
&lt;h3&gt;Why not the other way around?&lt;/h3&gt;
&lt;p&gt;Why didn&apos;t Native American diseases wipe out the Europeans, why was it a one-way street?
Europeans brought smallpox, &lt;a href=&quot;https://en.wikipedia.org/wiki/Measles&quot;&gt;&lt;strong&gt;measles&lt;/strong&gt;&lt;/a&gt;, flu, &lt;a href=&quot;https://en.wikipedia.org/wiki/Typhus&quot;&gt;&lt;strong&gt;typhus&lt;/strong&gt;&lt;/a&gt;, plague, &lt;a href=&quot;https://en.wikipedia.org/wiki/Tuberculosis&quot;&gt;&lt;strong&gt;tuberculosis&lt;/strong&gt;&lt;/a&gt;, and more. The main disease Europeans got from the Americas was likely &lt;a href=&quot;https://en.wikipedia.org/wiki/Syphilis&quot;&gt;&lt;strong&gt;syphilis&lt;/strong&gt;&lt;/a&gt;.
The answer goes back to domesticated animals. ::Sheep::, ::pigs::, ::cows::, and the rest weren&apos;t just ::food:: and labor, they were ::disease:: factories. Eurasians lived intimately with their animals for thousands of years, same structures, daily handling, shared air, and diseases leap from animals to humans. Smallpox jumped from ::cattle::, flu morphs from diseases in ::pigs:: and ::ducks::, measles came from ::cattle:: and ::sheep::.
Native Americans had fewer domesticated animals and never lived in close quarters with them the same way, so they never developed these diseases.&lt;/p&gt;
&lt;p&gt;But animals alone weren&apos;t enough, you also needed cities. Diseases like measles, smallpox, and tuberculosis are &lt;a href=&quot;https://en.wikipedia.org/wiki/Crowd_disease&quot;&gt;&lt;strong&gt;crowd diseases&lt;/strong&gt;&lt;/a&gt;, they need large, dense populations to keep circulating. Measles, for instance, needs on the order of hundreds of thousands of people. In a band of 50 hunter-gatherers moving through a forest, there aren&apos;t enough bodies for measles to survive.
Agriculture created that density. Thousands of people packed together were the perfect breeding ground. Over centuries, these diseases killed millions across Europe, Asia, and North Africa. But if you survive them once, you&apos;re often immune for life. Over thousands of years, Eurasians developed resistance, the Americas had no protection like that.&lt;/p&gt;
&lt;p&gt;When Europeans arrived with these invisible ::plagues::, Native Americans had zero defenses. The geographic lottery didn&apos;t just determine who had steel and guns, it determined germs as well, and that turned out to be the deadliest weapon of all.&lt;/p&gt;
&lt;h2&gt;Closing&lt;/h2&gt;
&lt;p&gt;I started by asking why Europeans took over the world that doesn&apos;t mean it will last forever.
I will go deeper into the American and African continents next. Stay tuned, Arigato!&lt;/p&gt;
</content:encoded><category>History</category><category>Geography</category><author>Ibrahim Rayamah</author></item><item><title>The Career Tree</title><link>https://www.ibz04.pro/blog/career-tree</link><guid isPermaLink="true">https://www.ibz04.pro/blog/career-tree</guid><description>How to find your career path, and how everything connects.</description><pubDate>Wed, 10 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;import CareerTreeBoard from &apos;../../components/CareerTreeBoard.tsx&apos;&lt;/p&gt;
&lt;h2&gt;Intro&lt;/h2&gt;
&lt;p&gt;Since the beginning of science, careers have popped up based on demand, earlier days required more research and discovery within the basic sciences.
Today there are many layers that sit on top of the basic sciences, and those layers create new paths, to find the perfect path its advised to be honest with yourself, consider your basic strengths, cognitive ability and geographic location.
For students and new grads, Its important to see your initial career as a &lt;strong&gt;portfolio&lt;/strong&gt;, and not necessarily what you will be doing in the next 10 years, It is of my personal opinion to have 3 fields in mind, two directly connected to your passion and one that is a safety net.&lt;/p&gt;
&lt;p&gt;A career is not linear, we are in times when everything moves fast, and the only constant is change, so be ready to adapt and pivot.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;The Career Tree&lt;/h2&gt;
&lt;p&gt;Read it like a family tree, the root is knowledge, each layer builds on the one above it, and you can follow a branch from a science you like down to the jobs it turns into.&lt;/p&gt;
&lt;p&gt;&amp;lt;CareerTreeBoard client:only=&quot;react&quot; /&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;How To Find Your Branch&lt;/h2&gt;
&lt;p&gt;Ignore titles and look at the content of the work, research on what they do all day, and how much control you have.
but before that consider how it connects to your university major.&lt;/p&gt;
&lt;h3&gt;The degree trap&lt;/h3&gt;
&lt;p&gt;People act like your degree is supposed to decide your whole life, and I think that screws a lot of people up.
That said, if you did not start with some advantages, the right degree can help a lot. If you went to a non-target school or do not already have a network, a good program or a highly ranked school can open doors for you.
Nowadays, you can move from physics into software, from biology into data, from mechanical engineering into materials science, or from philosophy into product management, as long as you can connect the dots and do the work.&lt;/p&gt;
&lt;p&gt;A degree does not decide what you can do. It mostly shapes your first instinct when you face a problem. lets take a problem: &lt;strong&gt;&quot;cooling buildings in hot cities without raising rent&quot;&lt;/strong&gt;. Physics starts by finding the mechanism causing the problem, then reduces it to forces, energy, and cause and effect. Biology &amp;amp; Chemistry starts from the natural properties of the existing material, then changes composition to get better performance at lower cost. Engineering starts from constraints, then designs a system that can work safely, repeatedly, and under failure. Math removes the story and turns the problem into variables, limits, and tradeoffs. Economics studies the incentives around the solution and asks whether people have a reason to adopt it.
Social sciences ask what habits or trust issues stop people from adopting a cheaper solution if it already exists.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Your personality&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Personality will not pick a career for you, but it tells you what will start annoying you.
If you hate uncertainty, try to avoid constant chaos like startups, and if you hate routine, avoid big tech or enterprise roles.&lt;/p&gt;
&lt;h3&gt;Where you work&lt;/h3&gt;
&lt;p&gt;Where you work changes the job way more than people admit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enterprise companies&lt;/strong&gt; (e.g., Salesforce, SAP, IBM)&lt;/p&gt;
&lt;p&gt;Stable, clear, and a little bit allergic to moving fast, good if you like predictability and structure.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Big Tech&lt;/strong&gt; (e.g., Apple, Google, Microsoft)&lt;/p&gt;
&lt;p&gt;Huge scale, strong systems, smart people, and enough process to make you question a few things, great if you like reliability and prestige.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Frontier labs&lt;/strong&gt; (e.g., OpenAI, DeepMind, Anthropic)&lt;/p&gt;
&lt;p&gt;High stakes, fast research, lots of ambiguity, and not much calm, great if you like deep work and uncertainty, and you don&apos;t mind the stress.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Corporate companies&lt;/strong&gt; (e.g., Procter &amp;amp; Gamble, JPMorgan Chase, Coca-Cola)&lt;/p&gt;
&lt;p&gt;Usually the best balance, you can have real ownership of projects, and a normal life, but get ready to smile to on monday mornings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Small companies&lt;/strong&gt; (e.g., boutique design studios, regional distributors, specialized law firms)&lt;/p&gt;
&lt;p&gt;More ownership, faster feedback, and usually less drama than a startup, you still have lots of responsibilities.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Startups&lt;/strong&gt; (e.g., YC companies, newly funded ventures)&lt;/p&gt;
&lt;p&gt;Everything changes fast and half the plan is fake by next month, great if you want responsibility early, sometimes you get an incredible return on investment.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Born to do&lt;/h3&gt;
&lt;p&gt;You build this over time, you get good at something, people trust you, you get more control, and the work starts to feel truly yours.
Dont wait around for passion to arrive fully formed, spoiler: it doesn&apos;t. You have to build it, then see if it holds up when times get hard.&lt;/p&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Oh Guay Kim Harold Lee Heo Shin 2014 fit happens globally meta analytic comparison Personnel Psychology&lt;/li&gt;
&lt;li&gt;Lewis Rivkin 1999 development of the ONET Interest Profiler National Center for ONET Development&lt;/li&gt;
&lt;li&gt;OKeefe Dweck Walton 2018 implicit theories of interest Psychological Science&lt;/li&gt;
&lt;li&gt;Hagger McAnally Star 2026 self determination theory and workplace outcomes meta analysis Stress and Health&lt;/li&gt;
&lt;li&gt;World Economic Forum 2025 Future of Jobs Report&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>Careers</category><category>Education</category><author>Ibrahim Rayamah</author></item><item><title>Building a tiny GPT in Rust</title><link>https://www.ibz04.pro/blog/gpt-from-scratch-rust</link><guid isPermaLink="true">https://www.ibz04.pro/blog/gpt-from-scratch-rust</guid><description>Implementing a character level Generative Pretrained Transformer model</description><pubDate>Sat, 02 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;If you only call an API, the model is a black box. This project is the opposite: one file of Rust, &lt;a href=&quot;https://github.com/huggingface/candle&quot;&gt;Candle&lt;/a&gt; for tensors, and the ideas from &lt;a href=&quot;https://arxiv.org/abs/1706.03762&quot;&gt;&lt;em&gt;Attention Is All You Need&lt;/em&gt;&lt;/a&gt; boiled down to a &lt;strong&gt;decoder only&lt;/strong&gt; stack (masked self attention, no encoder). That is the same family as GPT: predict the next character given everything so far.&lt;/p&gt;
&lt;p&gt;Everything lives in &lt;a href=&quot;https://github.com/iBz-04/RustGPT&quot;&gt;RustGPT on GitHub&lt;/a&gt;. This post sticks to simple language and shows the parts that matter in code.&lt;/p&gt;
&lt;h2&gt;What you need at the top of the file&lt;/h2&gt;
&lt;p&gt;Errors use &lt;code&gt;anyhow&lt;/code&gt;. Training uses &lt;code&gt;candle_core&lt;/code&gt;, &lt;code&gt;candle_nn&lt;/code&gt;, and &lt;code&gt;rand&lt;/code&gt; for batch sampling and generation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;use anyhow::{bail, Context, Result};
use candle_core::{DType, Device, Tensor, D};
use candle_nn as nn;
use candle_nn::{Module, Optimizer};
use rand::distributions::{Distribution, WeightedIndex};
use rand::{Rng, SeedableRng};
use std::collections::HashMap;
use std::fs;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Knobs in one place&lt;/h2&gt;
&lt;p&gt;All sizes and training settings sit in &lt;code&gt;Config&lt;/code&gt;. &lt;code&gt;vocab_size&lt;/code&gt; is filled in after you read the text because it depends on how many unique characters you have.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#[derive(Clone)]
struct Config {
    batch_size: usize,
    block_size: usize,
    max_iters: usize,
    eval_interval: usize,
    eval_iters: usize,
    learning_rate: f64,
    n_embd: usize,
    n_head: usize,
    n_layer: usize,
    dropout: f64,
    seed: u64,
    max_new_tokens: usize,
    vocab_size: usize,
    temperature: f32,
    top_k: usize,
}

impl Default for Config {
    fn default() -&amp;gt; Self {
        Self {
            batch_size: 32,
            block_size: 256,
            max_iters: 8000,
            eval_interval: 1000,
            eval_iters: 100,
            learning_rate: 3e-4,
            n_embd: 192,
            n_head: 6,
            n_layer: 4,
            dropout: 0.1,
            seed: 1337,
            max_new_tokens: 500,
            vocab_size: 0,
            temperature: 0.9,
            top_k: 40,
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Turn &lt;code&gt;input.txt&lt;/code&gt; into numbers&lt;/h2&gt;
&lt;p&gt;We keep it simple: &lt;strong&gt;character level&lt;/strong&gt;. Build the alphabet from the file, sort and dedupe, map each character to a &lt;code&gt;u32&lt;/code&gt;. The first 90% of tokens are train, the rest are validation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;struct Dataset {
    train: Vec&amp;lt;u32&amp;gt;,
    val: Vec&amp;lt;u32&amp;gt;,
    itos: Vec&amp;lt;char&amp;gt;,
}

fn build_dataset(path: &amp;amp;str) -&amp;gt; Result&amp;lt;Dataset&amp;gt; {
    let text = fs::read_to_string(path).with_context(|| format!(&quot;read {path}&quot;))?;
    let mut vocab: Vec&amp;lt;char&amp;gt; = text.chars().collect();
    vocab.sort_unstable();
    vocab.dedup();

    let stoi: HashMap&amp;lt;char, u32&amp;gt; = vocab
        .iter()
        .enumerate()
        .map(|(i, ch)| (*ch, i as u32))
        .collect();
    let itos = vocab;

    let data = encode(&amp;amp;text, &amp;amp;stoi);
    let split = data.len() * 9 / 10;
    Ok(Dataset {
        train: data[..split].to_vec(),
        val: data[split..].to_vec(),
        itos,
    })
}

fn encode(text: &amp;amp;str, stoi: &amp;amp;HashMap&amp;lt;char, u32&amp;gt;) -&amp;gt; Vec&amp;lt;u32&amp;gt; {
    text.chars().map(|ch| stoi[&amp;amp;ch]).collect()
}

fn decode(tokens: &amp;amp;[u32], itos: &amp;amp;[char]) -&amp;gt; String {
    tokens.iter().map(|&amp;amp;i| itos[i as usize]).collect()
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Batches: predict the next character&lt;/h2&gt;
&lt;p&gt;For each random start index we take &lt;code&gt;block_size&lt;/code&gt; tokens as &lt;code&gt;x&lt;/code&gt;, and the same length shifted by one as &lt;code&gt;y&lt;/code&gt;. So at every position the model should guess the &lt;strong&gt;next&lt;/strong&gt; token. That is the whole training target.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#[derive(Clone, Copy)]
enum Split {
    Train,
    Val,
}

fn get_batch(
    split: Split,
    data: &amp;amp;Dataset,
    cfg: &amp;amp;Config,
    device: &amp;amp;Device,
    rng: &amp;amp;mut impl Rng,
) -&amp;gt; Result&amp;lt;(Tensor, Tensor)&amp;gt; {
    let source = match split {
        Split::Train =&amp;gt; &amp;amp;data.train,
        Split::Val =&amp;gt; &amp;amp;data.val,
    };
    if source.len() &amp;lt;= cfg.block_size + 1 {
        bail!(&quot;dataset too small for block_size&quot;)
    }

    let max_start = source.len() - cfg.block_size - 1;
    let mut x_buf = Vec::with_capacity(cfg.batch_size * cfg.block_size);
    let mut y_buf = Vec::with_capacity(cfg.batch_size * cfg.block_size);

    for _ in 0..cfg.batch_size {
        let start = rng.gen_range(0..max_start);
        x_buf.extend_from_slice(&amp;amp;source[start..start + cfg.block_size]);
        y_buf.extend_from_slice(&amp;amp;source[start + 1..start + 1 + cfg.block_size]);
    }

    let x = Tensor::from_vec(x_buf, (cfg.batch_size, cfg.block_size), device)?;
    let y = Tensor::from_vec(y_buf, (cfg.batch_size, cfg.block_size), device)?;
    Ok((x, y))
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Loss is plain cross entropy on the flattened logits and integer labels.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fn compute_loss(logits: &amp;amp;Tensor, targets: &amp;amp;Tensor) -&amp;gt; Result&amp;lt;Tensor&amp;gt; {
    let (b, t, c) = logits.dims3()?;
    let logits = logits.reshape((b * t, c))?;
    let targets = targets.reshape((b * t,))?.to_dtype(DType::U32)?;
    Ok(nn::loss::cross_entropy(&amp;amp;logits, &amp;amp;targets)?)
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;The causal mask (no peeking ahead)&lt;/h2&gt;
&lt;p&gt;Attention would let every position see the whole sentence. For language modeling we &lt;strong&gt;must&lt;/strong&gt; hide the future. The mask is 1 where &lt;code&gt;i &amp;gt;= j&lt;/code&gt; and 0 otherwise, so we keep lower triangular attention.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fn causal_mask(t: usize, device: &amp;amp;Device) -&amp;gt; Result&amp;lt;Tensor&amp;gt; {
    let idx = Tensor::arange(0u32, t as u32, device)?;
    let i = idx.reshape((t, 1))?.broadcast_as((t, t))?;
    let j = idx.reshape((1, t))?.broadcast_as((t, t))?;
    Ok(i.ge(&amp;amp;j)?.to_dtype(DType::U8)?)
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;One attention layer (the heart of the paper)&lt;/h2&gt;
&lt;p&gt;Project input to &lt;code&gt;Q&lt;/code&gt;, &lt;code&gt;K&lt;/code&gt;, and &lt;code&gt;V&lt;/code&gt;, split heads, scale the product of &lt;code&gt;Q&lt;/code&gt; and &lt;code&gt;K&lt;/code&gt; transposed, apply the mask and softmax, multiply by &lt;code&gt;V&lt;/code&gt;, merge heads, project again. Dropout is on during training.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;let k_t = k.transpose(2, 3)?;
let wei = (q.matmul(&amp;amp;k_t)? * self.scale)?;

let mask = causal_mask(t, x.device())?
    .unsqueeze(0)?
    .unsqueeze(0)?
    .broadcast_as((b, self.n_head, t, t))?;
let neg = Tensor::full(-1e4f32, (b, self.n_head, t, t), x.device())?;
let wei = mask.where_cond(&amp;amp;wei, &amp;amp;neg)?;

let wei = nn::ops::softmax(&amp;amp;wei, D::Minus1)?;
let wei = self.attn_dropout.forward(&amp;amp;wei, train)?;

let out = wei.matmul(&amp;amp;v)?;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Block and full GPT forward&lt;/h2&gt;
&lt;p&gt;Each block is pre norm: layer norm, then attention, add residual. Then layer norm, feedforward (expand by 4x, GELU, project back), add residual. The GELU matches the usual GPT 2 style approximation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fn forward_t(&amp;amp;self, x: &amp;amp;Tensor, train: bool) -&amp;gt; Result&amp;lt;Tensor&amp;gt; {
    let x = x.broadcast_add(&amp;amp;self.sa.forward_t(&amp;amp;self.ln1.forward(x)?, train)?)?;
    let x = x.broadcast_add(&amp;amp;self.ffwd.forward_t(&amp;amp;self.ln2.forward(&amp;amp;x)?, train)?)?;
    Ok(x)
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The top level adds &lt;strong&gt;token embeddings&lt;/strong&gt; plus &lt;strong&gt;position embeddings&lt;/strong&gt;, runs &lt;code&gt;n_layer&lt;/code&gt; blocks, final norm, then &lt;code&gt;lm_head&lt;/code&gt; to logits over the vocabulary.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fn forward_t(&amp;amp;self, idx: &amp;amp;Tensor, train: bool) -&amp;gt; Result&amp;lt;Tensor&amp;gt; {
    let (_b, t) = idx.dims2()?;
    let tok_emb = self.token_embedding.forward(idx)?;
    let pos = Tensor::arange(0u32, t as u32, idx.device())?;
    let pos_emb = self.position_embedding.forward(&amp;amp;pos)?;
    let mut x = tok_emb.broadcast_add(&amp;amp;pos_emb)?;
    for block in &amp;amp;self.blocks {
        x = block.forward_t(&amp;amp;x, train)?;
    }
    let x = self.ln_f.forward(&amp;amp;x)?;
    Ok(self.lm_head.forward(&amp;amp;x)?)
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Training loop&lt;/h2&gt;
&lt;p&gt;Pick Metal on Apple Silicon if it works, else CPU. Build the &lt;code&gt;VarMap&lt;/code&gt;, &lt;code&gt;AdamW&lt;/code&gt;, loop &lt;code&gt;max_iters&lt;/code&gt;, print train and val loss on a schedule, backward step each time.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;let device = Device::new_metal(0).unwrap_or(Device::Cpu);
if matches!(device, Device::Metal(_)) {
    device.set_seed(cfg.seed)?;
}

let varmap = nn::VarMap::new();
let vb = nn::VarBuilder::from_varmap(&amp;amp;varmap, DType::F32, &amp;amp;device);
let model = GPT::new(&amp;amp;cfg, vb)?;

let mut opt = nn::AdamW::new(
    varmap.all_vars(),
    nn::ParamsAdamW {
        lr: cfg.learning_rate,
        ..Default::default()
    },
)?;

let mut rng = rand::rngs::StdRng::seed_from_u64(cfg.seed);

for iter in 0..cfg.max_iters {
    if iter % cfg.eval_interval == 0 || iter == cfg.max_iters - 1 {
        let (train, val) = estimate_loss(&amp;amp;model, &amp;amp;data, &amp;amp;cfg, &amp;amp;device, &amp;amp;mut rng)?;
        println!(&quot;step {iter}: train loss {train:.4}, val loss {val:.4}&quot;);
    }

    let (xb, yb) = get_batch(Split::Train, &amp;amp;data, &amp;amp;cfg, &amp;amp;device, &amp;amp;mut rng)?;
    let logits = model.forward_t(&amp;amp;xb, true)?;
    let loss = compute_loss(&amp;amp;logits, &amp;amp;yb)?;
    opt.backward_step(&amp;amp;loss)?;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Generating text&lt;/h2&gt;
&lt;p&gt;We seed from a short slice of training data, then repeatedly take the last logits, divide by &lt;strong&gt;temperature&lt;/strong&gt;, keep only &lt;strong&gt;top k&lt;/strong&gt; candidates, softmax on CPU, sample one id, append, and feed the sliding window back in.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;let mut logits = last.to_device(&amp;amp;Device::Cpu)?.to_vec1::&amp;lt;f32&amp;gt;()?;
let temp = cfg.temperature.max(1e-4);
for v in &amp;amp;mut logits {
    *v /= temp;
}
apply_top_k(&amp;amp;mut logits, cfg.top_k);
let probs = softmax_cpu(&amp;amp;logits);
let dist = WeightedIndex::new(&amp;amp;probs)?;
let next_id = dist.sample(rng) as u32;
idx.push(next_id);
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Saving weights&lt;/h2&gt;
&lt;p&gt;Weights are dumped as raw &lt;code&gt;f32&lt;/code&gt; bytes plus a small JSON file listing shapes. Good enough to prove you can serialize what you trained. The loop that fills &lt;code&gt;tensors&lt;/code&gt; walks &lt;code&gt;varmap.all_vars()&lt;/code&gt;, copies each tensor to CPU, reshapes to a flat &lt;code&gt;f32&lt;/code&gt; vector, and packs bytes (see the repo for the full &lt;code&gt;save_model&lt;/code&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;let metadata: Vec&amp;lt;(String, Vec&amp;lt;usize&amp;gt;)&amp;gt; = tensors
    .iter()
    .map(|(name, shape, _)| (name.clone(), shape.clone()))
    .collect();

let metadata_json = serde_json::to_string(&amp;amp;metadata)?;
fs::write(&amp;amp;format!(&quot;{}.meta.json&quot;, path), metadata_json)?;

let mut all_data = Vec::new();
for (_, _, bytes) in &amp;amp;tensors {
    all_data.extend_from_slice(bytes);
}
fs::write(path, &amp;amp;all_data)?;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.meta.json&lt;/code&gt; file keeps the names and shapes so you could load the blob back if you write a loader.&lt;/p&gt;
&lt;h2&gt;Closing&lt;/h2&gt;
&lt;p&gt;If you like learning by typing, this setup is small enough to read in an evening and real enough to watch loss go down. Clone &lt;a href=&quot;https://github.com/iBz-04/RustGPT&quot;&gt;RustGPT&lt;/a&gt;, drop &lt;a href=&quot;https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt&quot;&gt;TinyShakespeare&lt;/a&gt; or any text into &lt;code&gt;input.txt&lt;/code&gt;, and run &lt;code&gt;cargo run --release&lt;/code&gt;. The architecture is the decoder side of the transformer from &lt;em&gt;Attention Is All You Need&lt;/em&gt;. The rest is training and sampling.&lt;/p&gt;
</content:encoded><category>rust</category><category>ml</category><category>gpt</category><category>transformers</category><author>Ibrahim Rayamah</author></item><item><title>Early History of AI</title><link>https://www.ibz04.pro/blog/early-history-of-ai</link><guid isPermaLink="true">https://www.ibz04.pro/blog/early-history-of-ai</guid><description>looking into the inital efforts towards the creation of Artificial Intelligence</description><pubDate>Sun, 01 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Intro&lt;/h2&gt;
&lt;p&gt;Computers are now doing  some of the things that humans do when we say &lt;strong&gt;&quot;we are thinking&quot;&lt;/strong&gt;. I am convinced that machines will think in our lifetime and they already are .. sort of &quot;thinking&quot;. Below the algorithmic level, I know there is something we are overlooking as humans, something we are denying, &quot;but they are just computers, they can never think like us&quot;. Maybe computers will never think like us, bu instead we will outsource our thinking to the extent that there will be no distinction between man and machine in terms of output.&lt;/p&gt;
&lt;p&gt;The history of thinking machines dates back to the year &lt;strong&gt;1939&lt;/strong&gt;, Nazi Germany deploys the Enigma, an encryption machine believed to be unbreakable. The Allied forces face a new challenge and  turn to Alan Turing, a visionary mathematician who then envisioned a new kind of machine, which kickstarted the era of computing.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1770417501/ASST._HEAD-ADMIN._ST._MARY_S_SENIOR_HIGH_SCHOOL_4_qkqb9f.png&quot; alt=&quot;alan turing&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;1947&lt;/h2&gt;
&lt;p&gt;By 1946, every military in the world understands the power of computers and wants one of their own. The problem is efficiency, computers rely on vacuum tubes, which work like giant light bulbs. They require constant maintenance and manual labor, and some military computers grow to the size of entire warehouses. So scientists begin searching for a better way.&lt;/p&gt;
&lt;p&gt;A brilliant physicist enters the picture. His name is &lt;strong&gt;William Shockley&lt;/strong&gt;. He imagines powering computers using the element germanium to create semiconductors. A semiconductor sits between conductors like metal and insulators like rubber. It can do both, allowing it to act as an electrical switch &lt;strong&gt;[0, 1]&lt;/strong&gt;.
This invention becomes known as the transistor and changes technology forever.
Though its applications are still theoretical, the smartest minds in the world immediately see the future. A transistor, no bigger than a kernel of corn, sparks visions of super computers.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1770415956/ASST._HEAD-ADMIN._ST._MARY_S_SENIOR_HIGH_SCHOOL_2_ml0ihi.png&quot; alt=&quot;vacuum tubes&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;1950&lt;/h2&gt;
&lt;p&gt;In 1950, Alan Turing introduces the Imitation Game, later called the &lt;strong&gt;Turing Test&lt;/strong&gt;. It is designed to determine whether a machine can exhibit intelligent behavior indistinguishable from a human. The test fundamentally questions the limits of artificial and human intelligence.&lt;/p&gt;
&lt;p&gt;Universities such as Harvard, MIT, and Princeton begin offering computer science degrees. Computer engineers become some of the highest paid skilled workers in the world and the smartest people flock to these programs.&lt;/p&gt;
&lt;p&gt;One of them is &lt;strong&gt;Marvin Minsky&lt;/strong&gt;, a 23 year old PhD candidate at Princeton University.
Inspired by Turing’s work, Minsky builds the world’s first working neural network using wires and six vacuum tubes as synapses. Despite frequent failures, the machine works and lays the foundation for artificial intelligence and neural networks.
Shockley’s transistor leads to the transistor radio, which becomes the highest selling consumer electronic device of all time. The world gets its first taste of compact electronics.
Shockley leaves Bell Labs and starts Shockley Semiconductor in Palo Alto, making it one of the earliest tech startups in Silicon Valley. He recruits bright minds such as &lt;strong&gt;Gordon Moore&lt;/strong&gt; and &lt;strong&gt;Robert Noyce&lt;/strong&gt;, along with twelve other geniuses.&lt;/p&gt;
&lt;h2&gt;1956&lt;/h2&gt;
&lt;p&gt;Just months after Shockley received the Nobel Prize, eight of the men he recruited left and founded &lt;strong&gt;Fairchild Semiconductor&lt;/strong&gt;.
Fairchild quickly became profitable, selling silicon-based transistors to IBM for military navigation systems. This proved that silicon was far superior to germanium, with profit margins nearly 30 times higher.&lt;/p&gt;
&lt;h3&gt;Manufacturing Crisis&lt;/h3&gt;
&lt;p&gt;The military now needs thousands of transistors, but manufacturing is unreliable. A simple knock could destroy a transistor.
&lt;strong&gt;Jean Hoerni&lt;/strong&gt;, a physicist at Fairchild, invents the planar process, adding a protective layer to transistors. This dramatically increases durability and scalability. Fairchild holds the patent, forcing anyone making transistors to pay them, and so their profits soar even higher.&lt;/p&gt;
&lt;h3&gt;Integrated Circuits&lt;/h3&gt;
&lt;p&gt;Despite success, transistors are limited because each one performs a single task and scaling becomes impossible.
&lt;strong&gt;Robert Noyce&lt;/strong&gt; creates the integrated circuit, allowing transistors to operate together on a single chip. Though &lt;strong&gt;Jack Kilby&lt;/strong&gt; proposed a similar idea earlier, Noyce’s version proves practical.
This invention creates an entirely new industry. Former Fairchild employees leave to form new companies, later called the “Fairchildren,” including Intel, AMD, and LSI Logic. Over 90 percent of today’s computing power can be traced back to Fairchild.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1770417220/ASST._HEAD-ADMIN._ST._MARY_S_SENIOR_HIGH_SCHOOL_3_arcol7.png&quot; alt=&quot;vacuum tubes&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;conclusion&lt;/h2&gt;
&lt;p&gt;To be continued ..&lt;/p&gt;
</content:encoded><category>history</category><category>ai</category><author>Ibrahim Rayamah</author></item><item><title>Where are we going</title><link>https://www.ibz04.pro/blog/where-are-we-going</link><guid isPermaLink="true">https://www.ibz04.pro/blog/where-are-we-going</guid><description>Modernity gave us comfort, speed and endless choice, and quietly took something back. Where the direction of today&apos;s people actually points.</description><pubDate>Sun, 28 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tim Cook:&lt;/strong&gt; &quot;I&apos;m not worried about computers thinking like humans, I am more concerned about humans thinking like computers&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The people of today are goal-driven; they move without personal values or compassion. The average 18-25 year old is hopeless, lacks purpose, has no direction. We outsource our thinking and wait for the next influencer, the next reel, the next TikTok to tell us what to do, to give us opinions, because we don&apos;t think for ourselves. We are scared to make mistakes, we are scared to go wrong, and even more scared to be criticized.&lt;/p&gt;
&lt;h2&gt;The Cause&lt;/h2&gt;
&lt;h3&gt;Online perfectionism&lt;/h3&gt;
&lt;p&gt;Every single video or picture online is of a perfect life, a perfect marriage, perfect scores on exams, perfect makeup. People spend hours perfecting that one post for social media, but when you see it you compare it to your normal life. Don&apos;t.&lt;/p&gt;
&lt;p&gt;Social media was originally created to be a personal space you can share together with friends even when they&apos;re far from you. But it is now a perfection competition: who has the best pictures, the best life, lives in a better country. We make each other feel like we lack something. It makes people insecure to post an imperfect picture, an imperfect life, an imperfect result; but all some people will ever have is an average life, &lt;strong&gt;what will become of these people?&lt;/strong&gt; The guy who has a rusted car will never post it because he fears his imperfection, the girl who can&apos;t afford makeup or a good camera will fear to show herself because she&apos;s imperfect according to &lt;em&gt;modern&lt;/em&gt; standards. They will forever hate their lives because they will never be enough.&lt;/p&gt;
&lt;p&gt;Who is to blame? We must blame ourselves.&lt;/p&gt;
&lt;h3&gt;Individualism&lt;/h3&gt;
&lt;p&gt;We were promised a better life if we shifted from communities to individualism. Everything became personalized: personalized video recommendations, personalized job recommendations, even people recommendations. But now that every person has the power to become/do whatever they want... &lt;em&gt;we suddenly cannot choose&lt;/em&gt;. An endless number of choices: millions of clothes to buy online but you don&apos;t know what to buy, millions of men and women you can see on social platforms but you cannot choose who to be with, hundreds of apps, thousands of websites on your phone, but you are bored. Millions of job openings but you&apos;re unemployed, millions of careers but you don&apos;t know what to be... The human brain did not evolve to evaluate millions of options. It evolved to choose between a few concrete paths inside a tribe.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1766952188/Untitled_design_1_ztb960.png&quot; alt=&quot;illustration of humans on social media&quot; /&gt;&lt;/p&gt;
&lt;h3&gt;Fear and hatred&lt;/h3&gt;
&lt;p&gt;Go to any social media, there are groups of men who are dedicated to blaming women, and groups of women who swear that men are trash. There are groups who are dedicated to hating on other races, other beliefs. Hatred is now a way people can feel part of communities; it is now a brand. When human beings feel inferior they cling to a collective hate campaign, and they blame the opposite group for all their problems: blame men, blame women, blame the government, blame the older generation, blame immigrants. They never seem to look at the root of the problem (themselves). They are scared of being at fault so they always blame others.&lt;/p&gt;
&lt;h2&gt;Remarks&lt;/h2&gt;
&lt;h3&gt;Stop treating purpose as something you find&lt;/h3&gt;
&lt;p&gt;Purpose is not discovered by scrolling, thinking, or waiting to feel ready. That mindset is part of the damage.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pick one direction that is “good enough,” not perfect.&lt;/li&gt;
&lt;li&gt;Stay long enough to suffer, learn, and matter.&lt;/li&gt;
&lt;li&gt;Accept that boredom and doubt are not signs of failure; they are entry fees.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Chosen constraints&lt;/h3&gt;
&lt;p&gt;Freedom without limits creates anxiety.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Give yourself fewer apps.&lt;/li&gt;
&lt;li&gt;Give yourself fewer platforms.&lt;/li&gt;
&lt;li&gt;Give yourself fewer “backup plans.”&lt;/li&gt;
&lt;li&gt;Give yourself fewer options.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Be comfortable with your choices; it&apos;s okay to be wrong.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;We are not lost because the world is broken. We are lost because we refuse limits.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We want freedom without commitment, choice without consequence, identity without responsibility. We want meaning, but we avoid the very things that create it: discipline, sacrifice, and long-term effort. So we scroll, compare, blame, and wait for clarity that never arrives.&lt;/p&gt;
&lt;p&gt;The solution is not going backward, and it is not destroying technology. It is learning how to live as humans again inside a world that moves too fast. That means choosing fewer things and taking them seriously. It means building small communities instead of performing for large audiences. It means accepting that an ordinary life lived with responsibility is not a failure.
&lt;strong&gt;So where are we going? Nowhere, until we act like humans.&lt;/strong&gt;&lt;/p&gt;
</content:encoded><category>Sociology</category><category>Modernity</category><author>Ibrahim Rayamah</author></item><item><title>Rotation Matrices in Quadcopter dynamics</title><link>https://www.ibz04.pro/blog/rotation-matrices</link><guid isPermaLink="true">https://www.ibz04.pro/blog/rotation-matrices</guid><description>Understanding Rotation Matrices and 3D transformations</description><pubDate>Thu, 03 Oct 2024 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In robotics and aerospace engineering, rotation matrices are vital tools for translating vector coordinates from one frame of reference to another. When applied to systems like quadcopters, they enable easy transformation of vectors from the quadcopter’s body frame to an external, fixed inertial frame[^1].&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731859567/quad_m5jlu9.png&quot; alt=&quot;screenshot of a quadcopter&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Definition&lt;/h2&gt;
&lt;p&gt;A rotation matrix is a mathematical construct used to rotate vectors in three-dimensional space. By applying a rotation matrix,
we can convert the representation of a vector from one coordinate system to another.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For instance, a vector expressed in a quadcopter&apos;s body frame can be translated to the inertial frame of the ground.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;To better understand its significance, consider a quadcopter in flight&lt;/em&gt; :&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731859582/quad_body_m2jdlp.png&quot; alt=&quot;screenshot of a quadcopter in flight&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Body Frame: This coordinate system moves and rotates with the quadcopter, with its own x, y, and z axes aligned to the craft’s orientation.&lt;/li&gt;
&lt;li&gt;Inertial Frame: This is a fixed coordinate system, usually defined relative to the ground, representing Earth’s x, y, and z axes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Movement&lt;/h2&gt;
&lt;p&gt;When the quadcopter performs movements such as yaw, pitch, or roll, vectors in its body frame must be converted to the inertial frame for accurate computation of movement, orientation, and external interactions. This transformation is essential for navigation systems, trajectory planning, and understanding how the quadcopter behaves relative to the Earth.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Constructing the Rotation Matrix&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;The rotation matrix 𝑅 is built using Euler angles that represent three successive rotations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Yaw ( 𝜓 ): Rotation around the z-axis, adjusting the direction in the horizontal plane (e.g., turning left or right).&lt;/li&gt;
&lt;li&gt;Pitch ( 𝜃 ): Rotation around the new y-axis, tilting the quadcopter&apos;s nose up or down.&lt;/li&gt;
&lt;li&gt;Roll ( 𝜙): Rotation around the new x-axis, causing side-to-side tilting.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These rotations give us the full rotation matrix 𝑅:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731859609/matrix_amyrmf.png&quot; alt=&quot;rotation matrix&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thus&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;For a given vector x in the body frame, the corresponding vector is given by Rx in the inertial frame&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Example Scenario&lt;/strong&gt;
Suppose the quadcopter tilts and rotates mid-flight. You need to know where &quot;forward&quot; points now from the ground&apos;s perspective (in the inertial frame). By applying 𝑅 to a vector pointing forward in the body frame, you get a new vector showing where that direction is pointing from the ground&apos;s view.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;This is crucial for controlling the quadcopter’s motion relative to the ground and understanding how it interacts with the environment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The quadcopter&apos;s motion involves complex kinematics where the body’s position and orientation need to be managed using the speeds of its four rotors. The relationship between body movements and world movements is defined through a rotation matrix
𝑅, which captures how the body frame&apos;s orientation maps to the fixed inertial frame. This matrix is crucial for designing controllers that can direct the quadcopter&apos;s movement and stabilize it in flight.&lt;/p&gt;
&lt;p&gt;[^1]: Rotation matrices transform vectors between a quadcopter&apos;s body and external frame.&lt;/p&gt;
</content:encoded><category>Linear Algebra</category><category>UAVs</category><author>Ibrahim Rayamah</author></item><item><title>Embedded Systems &amp; Pulse Oximetry</title><link>https://www.ibz04.pro/blog/oximetry</link><guid isPermaLink="true">https://www.ibz04.pro/blog/oximetry</guid><description>How Embedded Systems Process Oxygen Saturation Data in Real-Time</description><pubDate>Tue, 20 Aug 2024 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Pulse oximetry&lt;/strong&gt; is an efficient way to monitor oxygen saturation (&lt;em&gt;SpO2&lt;/em&gt;) in the blood. The role of embedded technology here is to process signals in real time to provide accurate &lt;strong&gt;SpO2&lt;/strong&gt; readings. The pulse oximeter uses principles of light absorption to determine oxygen levels, and the system is responsible for managing sensors, processing data, and calculating the oxygen saturation.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731875887/pulse_m_oylpdu.jpg&quot; alt=&quot;screenshot of pulse oximeter&quot; /&gt;&lt;/p&gt;
&lt;h2&gt;Components&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Light Source (LEDs):&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These LEDs shine light through the tissue, and the amount of light absorbed depends on the oxygenation levels of the hemoglobin in the blood.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Photodetector:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A photodetector measures the amount of light that is absorbed by the blood.
The amount of light absorbed by the blood is inversely proportional to the amount of oxygenated hemoglobin. The photodetector sends this data to the microcontroller.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Microcontroller:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The microcontroller processes the signals from the photodetector to calculate the absorption ratios of red and infrared light. This ratio is crucial in determining the &lt;em&gt;SpO2&lt;/em&gt; level.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The core of the microcontroller&apos;s task is to apply &lt;strong&gt;Beer-Lambert&apos;s&lt;/strong&gt; Law and convert the measured absorption into a meaningful oxygen saturation value. The absorption of red and infrared light is calculated and compared as:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731875912/lamb_law_ygsan0.png&quot; alt=&quot;screenshot of lambert law&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This ratio is processed by the microcontroller, which then calculates the SpO2 and displays it to the user.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Application&lt;/h2&gt;
&lt;p&gt;Let’s assume the measured absorbance at red light (660 nm) is &lt;em&gt;A red&lt;/em&gt; = 0.4 &amp;amp;  at infrared light (940 nm) &lt;em&gt;A infrared&lt;/em&gt; = 0.2
​The system will calculate it as :&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://res.cloudinary.com/diekemzs9/image/upload/v1731875923/infra_bl0lhw.png&quot; alt=&quot;screenshot of solution&quot; /&gt;&lt;/p&gt;
&lt;p&gt;This result means 50% of the hemoglobin in the blood is oxygenated&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Oxygen saturation of &lt;strong&gt;50%&lt;/strong&gt; is significantly lower than the normal range (&lt;strong&gt;95-100%&lt;/strong&gt;).
This suggests that the body is not receiving enough oxygen, which could indicate a serious condition such as respiratory failure or severe hypoxemia.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Error Sources&lt;/h2&gt;
&lt;p&gt;These are some factors can lead to errors in the system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Carboxyhemoglobin/methemoglobin&lt;/strong&gt; absorb light similarly to oxyhemoglobin, leading to overestimation of oxygen saturation.
The embedded system needs to be calibrated to account for this.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Motion&lt;/strong&gt; can cause signal distortion. The embedded system filters these out using motion-detection algorithms, ensuring accurate readings even during patient movement.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;citation&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;*Upadhyay, A., &amp;amp; Dhapola, A. S. (2015). Embedded systems and its application in medical field. [https://doi.org/10.13140/2.1.1299.1528] *&lt;/p&gt;
</content:encoded><category>Embedded systems</category><category>Medtech</category><author>Ibrahim Rayamah</author></item></channel></rss>