Clever Algorithms: A Free Book of Nature-Inspired Ruby Recipes

cleveralgorithms.png

Clever Algorithms is a newly released book by Jason Brownlee PhD that describes 45 algorithms from the Artificial Intelligence (AI) field with Ruby-based examples. It's well produced and, notably, free in its PDF and online formats. A print copy is available at a small cost.

The book kicks off with a chapter of background regarding AI and its problem domains and moves on to an array of algorithms in the probabilistic, neural networking, stochastic, swarm, and evolutionary spaces.

Ruby purists will note that even though the demonstrations are in Ruby, they're not very Ruby like. Classes are rarely defined and using methods defined in the main context as functions is the order of the day. Nonetheless, the book remains well written and interesting and the Ruby code - as generic as it is - will nonetheless help Rubyists get the idea behind many of the processes demonstrated.

This book provides a handbook of algorithmic recipes from the fields of Metaheuristics, Biologically Inspired Computation and Computational Intelligence that have been described in a complete, consistent, and centralized manner. These standardized descriptions were carefully designed to be accessible, usable, and understandable.

Most of the algorithms described in this book were originally inspired by biological and natural systems, such as the adaptive capabilities of genetic evolution and the acquired immune system, and the foraging behaviors of birds, bees, ants and bacteria. An encyclopedic algorithm reference, this book is intended for research scientists, engineers, students, and interested amateurs.

Jason Brownlee

Check out Jason's book at cleveralgorithms.com and the content and code are in this GitHub repository.

[ad] Jaconda is a chat system designed for teams working on projects. It works from the browser, your IM app, or your phone, and lets you chat, share files, and keep up with tickets and project activity you can have sent automatically to your rooms.

#ruby

5 Reasons You Will Always Be Broke


Being broke sucks. I’ve had extended periods in my life where I have been living on the edge of financial ruin, so I know how stressful and overwhelming it can be. When you’re broke and hating your job, things are much worse. It's hard to leave ANY job, regardless of how insanely miserable it is. This is the reason I still need to work at my loathsome job as a financial planner.

Over the last 9 years working in financial planning (and struggling with my own budget), I have seen some commonalities when it comes to people living beyond their means.

Struggling with a job you hate job is hard enough, but when you never seem to have enough money to pay the bills, let alone get ahead, things can be damn depressing. Financial stress is extremely difficult on you, your marriage, and your children. I am speaking from personal experience here.

Getting ahead financially is not especially difficult, even in the absence of a high paying job. It all comes down to your spending habits. It seems so simple; spend less than you earn. In reality though is much more difficult than that.

Our society has taught us how to be greedy, needy, over spenders. In fact, it's empowered us to be downright irresponsible. We want what we want and then we go buy it! If we don't have the money, we buy it anyway.

With this in mind, here are the top 5 reasons that you will always be broke:

  1. Your Spouse Is Out Of Control.
    I've seen this time and time again. A non-working wife decides that she needs to fill her empty day with spending their money on anything and everything that looks remotely interesting. Ok, this is a little extreme, but having a spouse that is out of touch with the family finances (and reality), is very difficult to manage. If both partners are not on the same page with the money, things can, and usually do, get very ugly.

  • You're In Denial.
    Millions of people reside here. This is when you refuse to accept that you need to take a serious look at your financial picture. Doing so would mean you might actually have to stop spending and do without the things that your cool neighbor has. Who wants to do that?

  • You Are A Dreamer.
    I worked for a multi-level marketing (MLM) company about 15 years ago and I was taught that if I followed their "proven system", I would become wealthy. Guess what, thousands of us bought into it. We spent like we didn't have a care in the world, hell, we we're going to be RICH in 5 years. As it turns out, it was not what we all thought it was and the company, along with our hopes of becoming a millionaire, went down the toilet.

    Dreams are fine and long as long as the execution plan is injected with a sense of reality. Blindly following hype is a sure path to pain and agony.


  • You Have No Budget.
    Budgeting is a word that strikes fear into our hearts and sends us running for the hills. Why? Because it's absolutely boring, limiting, humbling, and at times depressing. At work, I have no problem building Excel spreadsheets and PowerPoint Presentations all day - still, I hate doing a budget. Now imagine the regular person who has no financial background and doesn't even know what Microsoft Office is. Are they going to budget? I think not. Calculators and graph paper don't have a ton of appeal.

  • You Waste Too Much Money.
    This is supremely obvious, but you would be surprised at how few people actually track their discretionary spending. In know, in your brain right now you're saying that the last point was 'budgeting'. I'm not talking about that here. I'm talking about tracking. People don't think about the coffee and bagel in the morning or the afternoon soda and candy bar they buy, but guess what? They will have spent around $1,700 in a year on this stuff. The $1,700 that could have taken your family on vacation.

    Start tracking every dime you spend and you will see the difference! Once you've tracked, you can budget. Without tracking, you have no idea what needs to me eliminated or limited in the first place!

  • There are a number of other reasons why you could be broke, but these are the 5 most common I've seen. So what do we do?

    How NOT To Be Broke
    It is certainly possible to turn our finances around and actually start showing in the black, but it takes work, often A LOT of work.

    Here are 5 ways to avoid being broke:

    • Talk With A Professional.
      This IS NOT a solicitation to get your business or to endorse any service! Remember, I hate my job and don't really want to help you manage your money. However, I do recommend finding a Certified Financial Planner (CFP) that can help you implement a comprehensive financial plan. Let's face it, most people are clueless when it comes to money.

      I have clients with $500k in cash that don't have any idea what a mutual fund is. It's not that they're stupid, they just never took the time to learn. On top of that, investing jargon is confusing and often intimidating.


  • Use Cash Only.
    Say what!!! Too many people fall victim to thinking they can just use their credit card this one time and they will pay it off when the bill comes. That one purchase turns into two and then into $40,000 in Visa and MasterCard debt. If you think you're smarter than that and are going to use your debit card instead, I've got news for you - it doesn't work either. You will end up over spending and getting slammed with $35 overdrawn account fees (and those annoying letters telling you about it). Budget out your needs for the month and use cash only. Use the Envelope Method to control spending. It's cheesy, but it works.

  • Cut Your Expenses.
    I'm not talking about canceling your power or living off of Ramen Noodles, I'm talking about things like limiting eating out, avoiding buying movie theater snacks (a $5 candy bar, really?), reducing your tv cable stations from 800 to 200, and generally avoiding buying anything on impulse. It can be done, it sucks big time, but it can be done.

  • Set Up Automatic Savings From Your Paycheck.
    This is one of my favorites because we totally forget that we are saving. I, unfortunately, have never been a good saver. I am fantastic at spending, but not so great at putting money away. Once you figure out exactly how much money you have going out each month, take a portion of the excess and have it taken out of your check and put into some form of savings vehicle. Also, put it into something that is not readily liquid. You will be much more likely to take it out and piss it away if it's sitting in cash at your bank. Buy a CD with a early withdrawal penalty or a Mutual Fund which charges a fee if you sell it before a certain period. Perhaps that will deter spending. (note: Don't use those account types for emergency funds. You can't get penalized for needing money when the furnace breaks!)

  • Educate Yourself.
    Many of the folks who struggle with their bills are not educated when it comes to finance. People tend to bury their heads in the sand when the topic comes up. You cannot afford to do that anymore. Go find a book on personal finance and spend some time reading and understanding it. You should at least know the basics. The more you understand about money, saving, investing, budgeting, etc., the more likely you are to take control of your finances. If you let it control you, you will always be broke.
  • The bottom line is that if you're living beyond your means, you MUST take control of the situation immediately. I have seen too many people lose everything because they just couldn't get it together.

    Don't let that be you too.

    Written on 1/22/2011 by Steve Roy. Steve is the owner of EndingTheGrind.com, a blog about escaping the daily grind of a 9 to 5 job, building an online business, and living your passions. You can also find him on Twitter at @EndGrind. Photo Credit: madmolecule

    The economic jungle: How ecologists could save banking - physics-math - 19 January 2011 - New Scientist

    THE world's financial system really is like a jungle - a realisation that may save it from disaster.

    An ecological theorist and the Bank of England's head of stability have teamed up to show that if you apply the mathematical models used in ecology to financial systems, they behave much like ecosystems - with similar risks of collapse. Worryingly, the models bankers now use maximise exactly those risks.

    Until the 1970s, ecologists believed that the more complex the ecosystem, the more stable: lose one species and the rest fill in. Then Robert May, now at the University of Oxford, and others showed that such complex systems have critical points at which a change in one species can have dramatic and non-linear effects on others. Losses can propagate, and even cause collapse. The stronger the connections and fewer differences there are among species, the greater the risk.

    By substituting various kinds of lending and assets for predation, cooperation and competition, May and banker Andy Haldane show that the global financial system might behave similarly (Nature, DOI: 10.1038/nature09659). Yet bankers still think like 1960s ecologists, they say.

    Banks maximise their connectivity and similarity in an effort to increase stability, when in fact this may do the opposite. Pricing models for financial products called derivatives, central to the 2008 crisis, also wrongly exclude non-linear effects. May and Haldane think more ecological financial models might stave off another crisis.

    Issue 2796 of New Scientist magazine

    • Like what you've just read?
    • Don't miss out on the latest content from New Scientist.
    • Get New Scientist magazine delivered to your door, plus unlimited access to the entire content of New Scientist online.
    • Subscribe now and save

    print

    send

    If you would like to reuse any content from New Scientist, either in print or online, please contact the syndication department first for permission. New Scientist does not own rights to photos, but there are a variety of licensing options available for use of articles and graphics we own the copyright to.

    Have your say

    Only subscribers may leave comments on this article. Please log in.

    Only personal subscribers may leave comments on this article

    Subscribe now to comment.

    All comments should respect the New Scientist House Rules. If you think a particular comment breaks these rules then please use the "Report" link in that comment to report it to us.

    If you are having a technical problem posting a comment, please contact technical support.

    What's the carbon footprint of war?

    Ferris Jabr, reporter

    In the past few years, some researchers have explored whether warfare and societal collapse might be explained in part by swings in climate.

    A 2007 study found that periods of cold weather preceded 12 of 15 major conflicts in China's ancient dynasties. The frost would have created food shortages, the study suggested, which would have inspired rebellions and made communities more vulnerable to invasion. More recently, a study in Science argued that dramatic shifts in climate would have affected agriculture, contributing to the fall of the Roman Empire.

    But what about the opposite effect? Can humanity's skirmishes change the climate?

    Yes, says a new study in The Holocene by Julia Pongratz of the Carnegie Institution for Science. It all comes down to a trade-off between people and trees: when a brutal war or devastating plague significantly reduces a human population, forests have the chance to re-grow and absorb carbon dioxide, mitigating the greenhouse effect.

    Pongratz reconstructed global land cover from 800 AD to the present and modelled the carbon cycle for the same time period in order to test how land usage influenced climate change. She found, for example, that during the Mongol invasions in Asia (1200 – 1380), which some historians estimate killed at least 15 million people, newly flourishing trees in once deforested areas inhaled nearly 700 million tons of carbon from the atmosphere – an amount equivalent to the world's total annual demand for gasoline today.

    There was also significant re-growth during the conquest of the Americas (1519 – 1700), in which native populations were decimated by up to 90 per cent – but not during shorter events like the Black Death (1347 – 1400) and the fall of the Ming Dynasty in China (1600 –1650).

    However, Pongratz points out, any sighs of relief forests drew from human war and death failed to overcome the climate damage caused by a long and continuing history of deforestation. As far as the Earth is concerned, there have been way too many people, and too few trees, for far too long.

    War is bad in every way possible.

    Wine family tree revealed

    FROM Riesling to Merlot, wine grapes from around the world are more closely related than expected, says the largest study so far to produce a family tree of grapes. The tree, above, also reveals that in 6000 years of domestication, breeders have left a vast swathe of possible varieties unexplored.

    Sean Myles of Stanford University in California and colleagues looked at 9000 genetic markers in each of the world's 583 cultivated grape varieties, or cultivars, to draw up the tree.

    They found that unlike other domesticated crops, most of the main cultivars are close cousins of one another. This was true regardless of where they are grown (Proceedings of the National Academy of Sciences, DOI: 10.1073/pnas.1009363108).

    Moreover, breeders have been unimaginative in the crosses they have made, reusing the same cultivars over and over. The Traminer cultivar, for example, has been bred for millennia and has 20 first-degree relatives. This is good news for breeders seeking to develop cultivars that are resistant to disease, says Myles, as so few of the potential crosses have actually been made.

    Issue 2796 of New Scientist magazine

    • Subscribe to New Scientist and you'll get:
    • New Scientist magazine delivered to your door
    • Unlimited access to all New Scientist online content -
      a benefit only available to subscribers
    • Great savings from the normal price
    • Subscribe now!

    print

    send

    If you would like to reuse any content from New Scientist, either in print or online, please contact the syndication department first for permission. New Scientist does not own rights to photos, but there are a variety of licensing options available for use of articles and graphics we own the copyright to.

    Have your say

    Only subscribers may leave comments on this article. Please log in.

    Only personal subscribers may leave comments on this article

    Subscribe now to comment.

    All comments should respect the New Scientist House Rules. If you think a particular comment breaks these rules then please use the "Report" link in that comment to report it to us.

    If you are having a technical problem posting a comment, please contact technical support.

    Ahh, wine...