Download PDF Art of randomness 1 / converted edition ronald t. kneusel full chapter pdf

Page 1


Art Of Randomness 1 / converted Edition Ronald T. Kneusel

Visit to download the full and correct content document: https://textbookfull.com/product/art-of-randomness-1-converted-edition-ronald-t-kneus el/

More products digital (pdf, epub, mobi) instant download maybe you interests ...

How AI Works - From Sorcery to Science 1st Edition

Kneusel Ronald T.

https://textbookfull.com/product/how-ai-works-from-sorcery-toscience-1st-edition-kneusel-ronald-t/

Learning OpenTelemetry 1 / converted Edition Ted Young

https://textbookfull.com/product/learningopentelemetry-1-converted-edition-ted-young/

PowerShell 7 Workshop 1 / converted Edition Nick Parlow

https://textbookfull.com/product/powershell-7-workshop-1converted-edition-nick-parlow/

Windows Security Internals 1 / converted Edition James Forshaw

https://textbookfull.com/product/windows-securityinternals-1-converted-edition-james-forshaw/

Deep Learning from Scratch 1 / converted Edition Seth Weidman

https://textbookfull.com/product/deep-learning-fromscratch-1-converted-edition-seth-weidman/

The Software Architect Elevator 1 / converted Edition

Gregor Hohpe

https://textbookfull.com/product/the-software-architectelevator-1-converted-edition-gregor-hohpe/

Network Architect's Handbook 1 / converted Edition Alim H. Ali

https://textbookfull.com/product/network-architectshandbook-1-converted-edition-alim-h-ali/

Implementing DevSecOps Practices 1 / converted Edition Vandana Verma Sehgal

https://textbookfull.com/product/implementing-devsecopspractices-1-converted-edition-vandana-verma-sehgal/

Effective Machine Learning Teams 1 / converted Edition

David Tan

https://textbookfull.com/product/effective-machine-learningteams-1-converted-edition-david-tan/

THE ART OF RANDOMNESS

Randomized Algorithms in the Real World

San Francisco

THE ART OF RANDOMNESS. Copyright © 2024 by Ronald T. Kneusel.

All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.

First printing

28 27 26 25 24 1 2 3 4 5

ISBN-13: 978-1-7185-0324-3 (print)

ISBN-13: 978-1-7185-0325-0 (ebook)

Published by No Starch Press , Inc

245 8th Street, San Francisco, CA 94103

phone: +1 415 863 9900 www.nostarch.com; info@nostarch.com

Publisher: William Pollock

Managing Editor: Jill Franklin

Production Manager: Sabrina Plomitallo-González

Production Editor: Sydney Cromwell

Developmental Editors: Alex Freed and Eva Morrow

Cover Illustrator: Gina Redman

Interior Design: Octopod Studios

Technical Reviewer: Doug Couwenhoven

Copyeditor: George Hale

Proofreader: Audrey Doyle

Library of Congress Cataloging-in-Publication Data

Name: Kneusel, Ronald T., author. ®

Title: The art of randomness : using randomized algorithms in the real world / Ron Kneusel

Includes bibliographical references and index.

Identifiers: LCCN 2023029979 (print) | LCCN 2023029980 (ebook) | ISBN 9781718503243 (paperback) | ISBN 9781718503250 (ebook)

Subjects: LCSH: Algorithms. | Numbers, Random. | Python (Computer program language)

Classification: LCC QA9.58 .K635 2024 (print) | LCC QA9.58 (ebook) | DDC 519.2/3--dc23/eng/20231018

LC record available at https://lccn loc gov/2023029979

LC ebook record available at https://lccn.loc.gov/2023029980

For customer service inquiries, please contact info@nostarch.com. For information on distribution, bulk sales, corporate sales, or translations: sales@nostarch.com. For permission to translate this work: rights@nostarch.com. To report counterfeit copies or piracy: counterfeit@nostarch.com.

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc

Other product and company names mentioned herein may be the trademarks of their respective owners Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.

In memory of George Marsaglia (1924–2011), PRNG designer extraordinaire

u32 x32(){static u32 =9; ^= <<13; ^= >>17; ^= <<5;return ;}

About the Author

Ronald T. Kneusel has been working with machine learning in industry since 2003 and completed a PhD in machine learning at the University of Colorado, Boulder, in 2016 Ron has six other books: How AI Works: From Sorcery to Science (No Starch Press, 2023), Strange Code: Esoteric Languages That Make Programming Fun Again (No Starch Press, 2022), Practical Deep Learning: A Python-Based Introduction (No Starch Press, 2021), Math for Deep Learning: What You Need to Know to Understand Neural Networks (No Starch Press, 2021), Numbers and Computers (Springer, 2017), and Random Numbers and Computers (Springer, 2018)

About the Technical Reviewer

Doug Couwenhoven is a research scientist with more than 30 years of experience developing algorithms for digital imaging applications He has a BS in physics and an MS in electrical engineering and signal processing. He spent the first 24 years of his career working at a large imaging company developing software algorithms for digital photography, printing, and imaging systems, and holds 50 US patents in the field. In 2013, he joined an aerospace technology company, and is currently part of a research group there that focuses on developing deep learning and machine learning algorithms for remotely sensed data.

BRIEF CONTENTS

Foreword

Acknowledgments

Introduction

Chapter 1: The Nature of Randomness

Chapter 2: Hiding Information

Chapter 3: Simulate the Real World

Chapter 4: Optimize the World

Chapter 5: Swarm Optimization

Chapter 6: Machine Learning

Chapter 7: Art

Chapter 8: Music

Chapter 9: Audio Signals

Chapter 10: Experimental Design

Chapter 11: Computer Science Algorithms

Chapter 12: Sampling

Resources

Index

CONTENTS IN DETAIL

FOREWORD

ACKNOWLEDGMENTS

INTRODUCTION

1

THE NATURE OF RANDOMNESS

Probability and Randomness

Discrete Distributions

Continuous Distributions

Testing for Randomness

Truly Random Processes

Flipping Coins

Rolling Dice

Using Voltage

Random Physical Processes

Atmospheric Radio Frequency Noise

Voyager Plasma and Charged Particle Data

Radioactive Decay

Deterministic Processes

Pseudorandom Numbers

Quasirandom Sequences

Combining Deterministic and Truly Random Processes

The Book’s Randomness Engine

The RE Class

RE Class Examples

Summary

2

HIDING INFORMATION

In Strings

Fixed Offset

Random Offset In Random Data

How Much Can You Hide?

The steg random.py Code

In an Audio File

A Quiet Live Performance

The steg audio.py Code

In an Image File

Defining Image Formats

Using NumPy and PIL

Hiding Bits in Pixels

Hiding One Image in Another

The steg image.py Code

Exercises

Summary

3

SIMULATE THE REAL WORLD

Introduction to Models

Estimate Pi

Using a Dartboard

Simulating Random Darts

Understanding the RE Class Output

Implementing the Darts Model

Birthday Paradox

Simulating 100,000 Parties

Testing the Birthday Model

Implementing the Birthday Model

Simulating Evolution

Natural Selection

Static World

Gradually Changing World

Catastrophic World

Genetic Drift

Testing the Simulations

Exercises

Summary

4 OPTIMIZE THE WORLD

Optimization with Randomness

Fitting with Swarms

Curves

The curves.py Code

The Optimization Algorithms

Fitting Data

Introducing Stacks and Postfix Notation

Mapping Code to Points

Creating gp py

Evolving Fit Functions

Exercises

Summary

5 SWARM OPTIMIZATION

Packing Circles in a Square

The Swarm Search

The Code

Placing Cell Towers

The Swarm Search

The Code

Enhancing Images

The Enhancement Function

The Code

Arranging a Grocery Store

The Environment

The Shoppers

The Objective Function

The Shopping Simulation

Exercises

Summary

6

MACHINE LEARNING

Datasets

Histology Slide Data

Handwritten Digits

Neural Networks

Anatomy Analysis

Randomness

Initialization

Extreme Learning Machines

Implementation

Testing

Reckless Swarm Optimizations

Random Forests

Decision Trees

Models Combined with Voting

Exercises

Summary

Creating Random Art

Moiré Patterns

Random Walks A Grid

Fun with Fractals

The Chaos Game

Iterated Function Systems

Fractals Plotted with Points

IFS Maps

Exercises

Summary

Creating Random Sounds

Sine Waves

C Major Scale

Generating Melodies

Swarm Search

The melody maker.py code

Implementation

Exercises

Summary

9

AUDIO SIGNALS

Compressed Sensing

Signal Generation

Unraveled Images

Compressed Sensing Applications

Exercises

Summary

10

EXPERIMENTAL DESIGN

Randomization in Experiments

Simple Block

Stratified

Defining the Simulation

Implementing the Simulation

Functions and Classes

Schemes

Exploring the Simulation

Simple Block

Stratified

Exercises

Summary

11

COMPUTER SCIENCE ALGORITHMS

Las Vegas and Monte Carlo

Permutation Sort

Matrix Multiplication

Counting Animals

Testing Primality

Modular Arithmetic

The Miller-Rabin Test

Non-witness Numbers

Miller-Rabin Performance

Working with Quicksort

Running Quicksort in Python

Experimenting with Quicksort

Exercises

Summary

12

SAMPLING

Introduction to Sampling

Terminology

Bayesian Inference

Discrete Distributions

Sequential Search

Fast-Loaded Dice Roller

Runtime Performance

Two Dimensions

Images

Continuous Distributions

Inverse Transform Rejection

Markov Chain Monte Carlo

Exercises

Summary

RESOURCES

INDEX

FOREWORD

For a good part of the past 5,000 years, humans have been so to speak at odds with randomness Whether it was feared, worshipped, or used for divination or gambling, randomness had the upper hand for much of that time.

Even though the ancient civilizations understood randomness (and philosophized about its role in the universe, causality, and free will), they did not possess the understanding of probabilistic behavior and long-term frequencies. In fact, it wasn’t until the Renaissance that scientists started treating chance with rigor. The great minds of the 17th and 18th centuries including Galileo Galilei, Jacob Bernoulli, Pierre de Fermat, Blaise Pascal, Abraham de Moivre, and Pierre-Simon Laplace realized that the frequencies of random outcomes can be assessed and measured experimentally, allowing for the start of theoretical foundations of probability. Science was finally making progress with chance, much to the chagrin of fortune tellers and soothsayers everywhere.

Later centuries brought even more excitement, as randomness started to permeate almost every scientific field, partly energized by the developments in Brownian motion and stochastic processes, statistical physics, and the ideas based on ensemble averages of statistical samples that allowed scientists to tackle up-to-then impossibly hard questions. However, even though statistical physics held immense promise, the sampling methods of the late 19th and early 20th centuries often done by countless women “calculators” could not scale up nor keep up with the demands of science, which were made even more pressing by the world wars

It was finally due to the development of the 30-ton 18,000-cathode-ray-tube ENIAC (Electronic Numerical Integrator and Computer) that the sampling could be done at 1,000-fold speeds and scales large enough to simulate the physics of a nuclear fission experiment. The whole endeavor was a large effort led by the University of Pennsylvania and Los Alamos National Lab, and included leading physicists, mathematicians, and computer scientists of the time such as Nicholas Metropolis, Stanisław Ulam, John von Neumann, and Enrico Fermi. These efforts finally enabled randomness to find its undisputed place in the sciences. (For a detailed account of

the science in Los Alamos at the time, check out the Los Alamos Science Special Issue dedicated to Stanisław Ulam from 1987, available online at https://la-science lanl gov/lascience15 shtml )

Randomness has since become commonplace, and is now a part of our everyday thinking from deciding whether to bring an umbrella to work to analyzing whether to raise interest rates. Randomized algorithms have allowed us to develop completely novel paradigms in mathematics and computer science, and to extend science fields such as decision theory, sequential optimization and explore-exploit (bandit) schemes, and artificial intelligence. We can now solve many practical but previously intractable problems, from inferring spatial directions of impending solar storms to optimizing bidding streams in online advertising systems.

Dr. Kneusel’s book is about applied randomness, bringing us into that world of scientific thinking and computer algorithms that have been improved by adding randomness, from true/pseudo/quasirandom number generators to the very first Markov Chain Monte Carlo code implementation by Arianna Rosenbluth The book gives a gentle introduction to probability and entropy, with scientific anecdotes and Python examples sprinkled throughout. It leaves the readers with a set of randomness tools that could be used in everyday life, using open source and free resources, all while not requiring more than high school–level algebra.

This book couldn’t be more timely. As our society is embracing artificial intelligence and machine learning at unprecedented scales, the need to understand randomness in the data and algorithms, and many different sources of uncertainty, can only grow. This book is a beginning, opening the door to the exploration of those vast fields of scientific randomness.

University of Colorado, Boulder

May 2023

ACKNOWLEDGMENTS

Gratitude is not only the greatest of virtues, but the parent of all others. Marcus Tullius Cicero

Thanks, first and foremost, to Alex Freed and Eva Morrow, whose gentle approach to editing makes the entire process a joy. The book is better now than when I wrote it.

Thanks to Doug Couwenhoven, MSEE, for his time and thorough review of the book’s technical aspects. Any remaining technical errors are entirely on me for ignoring Doug’s wise advice and suggestions.

Special thanks to Monica Kneusel, MPH, for her review of Chapter 10 on experimental design.

Finally, I want to thank Vanja Dukic, PhD, for taking the time to write the foreword and all the good folks at No Starch Press for believing in the book and helping to make it a reality.

INTRODUCTION

In this book, randomness is produced by a random process, which returns an output when requested. The output is usually a number in the range 0 to 1, but may be any member of a predefined set of things (integers less than 100, letters, colors, dog breeds, and so on) In a random process, knowledge of previous outputs is of no utility in predicting future outputs. The output of a random process must be unpredictable; we can’t know ahead of time what value or element of the set will be returned next.

This definition sidesteps any philosophical concerns. In fact, we aren’t concerned with whether true randomness is possible; we care only that there are processes approximating this definition with sufficient fidelity to allow us to accomplish our goals.

In the end, this is a book about solving problems with randomness by using random processes

Who Is This Book For?

This book is for people curious about, or fascinated by, using random processes to accomplish a nonrandom goal As we’ll learn, randomness offers a powerful way to approach problems that might otherwise be beyond our ken.

You’ll find something of value in this book if you work in computer science, engineering, or mathematics; if you’re a visual artist or a musician; or if you’re a scientist of any stripe. This book is for everyone curious enough to pick it up, page through it, and read these words. In short, this book is for you.

What Can You Expect to Learn?

This book is a topical survey of what we might call applied randomness. By the end, you’ll know when randomness is a viable tool and how to use it

The following provides descriptions of each chapter.

Chapter 1: The Nature of Randomness Explores ways to generate true randomness and approximate it with deterministic algorithms.

Chapter 2: Hiding Information Discusses ways to use randomness as an essential part of steganography, the art of hiding information so that it isn’t even noticed

Chapter 3: Simulate the Real World Explores randomness-driven simulation, which is critical to nearly every area of modern science, engineering, and economics.

Chapter 4: Optimize the World Discusses a surprisingly powerful approach to optimization that involves swarms of agents or the evolution of a solution, both of which use randomness.

Chapter 5: Swarm Optimization Continues to present examples of optimization involving randomness.

Chapter 6: Machine Learning Investigates the ways that neural networks, extreme learning machines, random forests, and other forms of machine learning make heavy use of randomness.

Chapter 7: Art Considers ways to use randomness to create art.

Chapter 8: Music Attempts to generate music and evolve pleasant melodies from scratch.

Chapter 9: Audio Signals Explores how compressed sensing can allow reconstruction of a signal from a sparse collection of random samples.

Chapter 10: Experimental Design Demonstrates how randomness is used in the design of experiments, as well as its importance in producing meaningful results from a study.

Chapter 11: Computer Science Algorithms Explores the randomized algorithms often used

in the world of computer science.

Chapter 12: Sampling Discusses the ways that drawing samples from complex probability distributions is a fundamental requirement when applying probabilistic models and Bayesian analysis. Randomness is key to this process.

The book ends with a list of resources to help you find additional information about each chapter’s topics.

What I Expect You to Know

This is an intermediate-level book You should be familiar with programming, especially in Python, and somewhat comfortable with Python’s standard extensions like NumPy, Matplotlib, and to a lesser degree Pillow, SciPy, and scikit-learn If these names mean nothing to you, you

can find a brief introduction on this book’s GitHub site (https://github com/rkneusel9/TheArtOfRandomness)

You should be comfortable with high school–level math and perhaps a bit beyond. When things get math-y, I’ll explain; in all cases, you’ll profit from reading the code directly, even if some of the math is fuzzy.

How to Use This Book

This is a hands-on book filled with experiments. The code is in Python and uses the previously mentioned standard libraries I describe additional libraries when needed I’m assuming a Linux system running Ubuntu 20.04 or later. Everything will run under Windows or macOS, but installing the Python libraries might be a bit more complicated

To install the core libraries under Ubuntu, or Windows and macOS if pip3 is installed, try the following commands:

> pip3 install numpy

> pip3 install scipy

> pip3 install matplotlib

> pip3 install pillow

> pip3 install scikit-learn

Whatever version these commands install is likely to work fine

If using Windows, install Python from https://www.python.org. Any current version of Python 3 will do. When you install, select any option for installing pip or pip3, and add Python to your path so you can run it from a command prompt. If you do this, the install commands should succeed.

Before reading any further, I recommend downloading all files from the book’s GitHub repository at https://github.com/rkneusel9/TheArtOfRandomness by either cloning the repository from the command line

> git clone https://github.com/rkneusel9/TheArtOfRandomness

or using your browser to download everything as a ZIP file (click Code).

Chapter 1 is the starting point, in which we learn about both truly random processes and those that are deterministic approximations, along with some hybrid approaches. This chapter also develops the randomness engine, a Python class we’ll use for every experiment. The randomness engine supplies random values for the experiments and lets us select between different sources of randomness.

Feel free to read the remaining chapters in any order, though I recommend reading Chapters 4 and 5 sequentially.

Each chapter introduces the topic and then explores it with experiments. Some experiments include low-resolution test images to demonstrate the concepts at work. First, we run the code (after you review the code ahead of time) and interpret the results. Most experiments admit multiple parameter settings to allow you to build intuition. Second, we walk through the essential parts of the code to understand how and where randomness comes into play. Many chapters

conclude with an “Exercises” section proposing questions designed to encourage you to continue exploring

Questions will likely arise. Feel free to contact me. Also, if you find any bugs or if you create something amazing with the materials in this book please let me know: rkneuselbooks@gmail.com .

1

THE NATURE OF RANDOMNESS

Random processes power the systems we’ll develop later in this book. This chapter introduces specific random processes, from those that are truly random to those that are deterministic but still random enough to use that is, pseudorandom and quasirandom processes.

We’ll begin with a brief discussion of the relationship between probability and randomness After learning how to determine whether a process is random, we’ll explore truly random processes, meaning processes strongly influenced by true randomness We’ll also learn the difference between pseudorandom and quasirandom processes. Finally, we’ll use Python to create the RE class, the randomness engine we’ll use in all of our experiments

Probability and Randomness

Probability distributions represent the possible values a random variable can take and how likely each value is to occur. For us, a random variable is the output of a random process.

Probability distributions come in two varieties Continuous probability distributions return values from an infinite set, meaning any real number in the allowed range. Here, the word real means elements of the set of real numbers, denoted ℝ, which are all the numbers on the number line

Discrete probability distributions are restricted to returning values from a finite set of values, like the heads or tails of a coin or the numbers on a die

Random processes generate values, known as samples, that come from some kind of probability distribution, be it continuous or discrete. For example, a coin flip delivers samples that are either

heads or tails, while a die delivers samples from the set {1, 2, 3, 4, 5, 6} (assuming a standard six-sided die)

If a random process returns a single number, how do we know what distribution it’s sampling from? In some cases, we have theoretical knowledge, but in other cases, all we can do is generate many samples. Over time, the relative frequency with which each possible outcome appears will become evident and serve as a stand-in for the true probability distribution.

Discrete Distributions

As an example of a discrete probability distribution, suppose that, thanks to the generosity of a local wizard, I have in my possession a one-of-a-kind die with only three sides. The numbers 0, 1, or 2 appear on the faces of my three-sided die. Therefore, each roll of the die results in one of the three sides face up. When I roll my die 50,000 times, keeping a tally of the number of times each side appears face up, I get the results in Table 1-1.

Table 1-1: Rolling a Three-Sided Die 50,000 Times

The results indicate that the probability of getting a 0, 1, or 2 is not equal: 0 appeared 33,492/50,000 = 66 984 percent of the time, 1 appeared 16 484 percent of the time, and 2 appeared 16.532 percent of the time. If I were to repeat the experiment, the exact count for each outcome would be slightly different, but it’s clear that many such experiments would lead to outcomes in which 0 appears approximately 67 percent of the time and 1 and 2 each appears 16.5 percent of the time Notice that 67 percent + 16 5 percent + 16 5 percent = 100 percent, as it

Another random document with no related content on Scribd:

On his way to the Volsung land Sigurd saw a man walking on the waters, and took him on board, little suspecting that this individual, who said his name was Feng or Fiöllnir, was Odin or Hnikar, the wave stiller. He therefore conversed freely with the stranger, who promised him favorable winds, and learned from him how to distinguish auspicious from unauspicious omens.

After slaying Lygni and cutting the bloody eagle on his foes, Sigurd left his reconquered kingdom and went with Regin to slay Fafnir. A long ride through the mountains, which rose higher and higher before him, brought him at last to his goal, where a one-eyed stranger bade him dig trenches in the middle of the track along which the dragon daily rolled his slimy length to go down to the river and quench his thirst. He then bade Sigurd cower in one of those holes, and there wait until the monster passed over him, when he could drive his trusty weapon straight into its heart.

The fight with the dragon.

Sigurd gratefully followed this advice, and as the monster’s loathsome, slimy folds rolled overhead he thrust his sword under its left breast, and, deluged with blood, sprang out of the trench as the dragon rolled aside in the throes of death.

“Then all sank into silence, and the son of Sigmund stood On the torn and furrowed desert by the pool of Fafnir’s blood, And the serpent lay before him, dead, chilly, dull, and gray; And over the Glittering Heath fair shone the sun and the day, And a light wind followed the sun and breathed o’er the fateful place, As fresh as it furrows the sea plain, or bows the acres’ face.”

Regin, who had prudently remained at a distance until all danger was over, seeing his foe was slain, now came up to Sigurd; and fearing lest the strong young conqueror should glory in his deed and claim a reward, he began to accuse him of having murdered his kin, and declared that instead of requiring life for life, as was his right according to Northern law, he would consider it sufficient atonement if Sigurd would cut out the monster’s heart and roast it for him on a spit.

“Then Regin spake to Sigurd: ‘Of this slaying wilt thou be free? Then gather thou fire together and roast the heart for me, That I may eat it and live, and be thy master and more; For therein was might and wisdom, and the grudged and hoarded lore:— Or else depart on thy ways afraid from the Glittering Heath.’”

Sigurd, knowing that a true warrior never refused satisfaction of some kind to the kindred of the slain, immediately prepared to act as

cook, while Regin dozed until the meat was ready Feeling of the heart to ascertain whether it were tender, Sigurd burned his fingers so severely that he instinctively thrust them into his mouth to allay the smart. No sooner had Fafnir’s blood touched his lips than he discovered, to his utter surprise, that he could understand the songs of the birds, which were already gathering around the carrion. Listening to them attentively, he found they were advising him to slay Regin, appropriate the gold, eat the heart and drink the blood of the dragon; and as this advice entirely coincided with his own wishes, he lost no time in executing it. A small portion of Fafnir’s heart was reserved for future consumption, ere he wandered off in search of the mighty hoard. Then, after donning the Helmet of Dread, the hauberk of gold, and the ring Andvaranaut, and loading Greyfell with as much ruddy gold as he could carry, Sigurd sprang on his horse, listening eagerly to the birds’ songs to know what he had best undertake next.

The sleeping warrior maiden.

Soon he heard them sing of a warrior maiden fast asleep on a mountain and all surrounded by a glittering barrier of flames; through which only the bravest of men could pass in order to arouse her.

“On the fell I know A warrior maid to sleep; Over her waves

The linden’s bane: Ygg whilom stuck

A sleep-thorn in the robe Of the maid who Would heroes choose.”

L F (Thorpe’s tr.).

After riding for a long while through trackless regions, Sigurd at last came to the Hindarfiall in Frankland, a tall mountain whose cloud-wreathed summit seemed circled by fiery flames.

“Long Sigurd rideth the waste, when, lo! on a morning of day, From out of the tangled crag walls, amidst the cloudland gray, Comes up a mighty mountain, and it is as though there burns A torch amidst of its cloud wreath; so thither Sigurd turns, For he deems indeed from its topmost to look on the best of the earth; And Greyfell neigheth beneath him, and his heart is full of mirth.”

Riding straight up this mountain, he saw the light grow more and more vivid, and soon a barrier of lurid flames stood before him; but although the fire crackled and roared, it could not daunt our hero, who plunged bravely into its very midst.

“Now Sigurd turns in his saddle, and the hilt of the Wrath he shifts, And draws a girth the tighter; then the gathered reins he lifts, And crieth aloud to Greyfell, and rides at the wildfire’s heart; But the white wall wavers before him and the flame-flood rusheth apart,

And high o’er his head it riseth, and wide and wild its roar As it beareth the mighty tidings to the very heavenly floor: But he rideth through its roaring as the warrior rides the rye, When it bows with the wind of the summer and the hid spears draw anigh;

The white flame licks his raiment and sweeps through Greyfell’s mane, And bathes both hands of Sigurd and the hilt of Fafnir’s bane, And winds about his war-helm and mingles with his hair, But naught his raiment dusketh or dims his glittering gear; Then it fails and fades and darkens till all seems left behind, And dawn and the blaze is swallowed in mid-mirk stark and blind.”

No sooner had Sigurd thus fearlessly sprung into the very heart of the flames than the fire flickered and died out, leaving nothing but a broad circle of white ashes, through which he rode until he came to a great castle, with shield-hung walls, in which he penetrated

unchallenged, for the gates were wide open and no warders or men at arms were to be seen. Proceeding cautiously, for he feared some snare, Sigurd at last came to the center of the inclosure, where he saw a recumbent form all cased in armor. To remove the helmet was but a moment’s work, but Sigurd started back in surprise when he beheld, instead of a warrior, the sleeping face of a most beautiful woman.

All his efforts to awaken her were quite vain, however, until he had cut the armor off her body, and she lay before him in pure-white linen garments, her long golden hair rippling and waving around her. As the last fastening of her armor gave way, she opened wide her beautiful eyes, gazed in rapture upon the rising sun, and after greeting it with enthusiasm she turned to her deliverer, whom she loved at first sight, as he loved her.

“Then she turned and gazed on Sigurd, and her eyes met the Volsung’s eyes. And mighty and measureless now did the tide of his love arise, For their longing had met and mingled, and he knew of her heart that she loved, And she spake unto nothing but him, and her lips with the speechflood moved.”

The maiden now proceeded to inform Sigurd that she was Brunhild, according to some authorities the daughter of an earthly king. Odin had raised her to the rank of a Valkyr, in which capacity she had served him faithfully for a long while. But once she had ventured to set her own wishes above his, and, instead of leaving the victory to the old king for whom he had designated it, had favored his younger and therefore more attractive opponent.

In punishment for this act of disobedience, she was deprived of her office and banished to earth, where Allfather decreed she must marry like any other member of her sex. This sentence filled Brunhild’s heart with dismay, for she greatly feared lest it might be her fate to mate with a coward, whom she would despise. To quiet

these apprehensions, Odin placed her on Hindarfiall or Hindfell, stung her with the Thorn of Sleep, that she might await in unchanged youth and beauty the coming of her destined husband and surrounded her with a barrier of flame which none but the bravest would venture to pass through.

From the top of the Hindarfiall, Brunhild now pointed out to Sigurd her former home, at Lymdale or Hunaland, telling him he would find her there whenever he chose to come and claim her as his wife; and then, while they stood on the lonely mountain top together, Sigurd placed the ring Andvaranaut upon her hand, in sign of betrothal, swearing to love her alone as long as life endured.

BRUNHILD’S AWAKENING.—Th. Pixis.

“From his hand then draweth Sigurd Andvari’s ancient Gold; There is naught but the sky above them as the ring together they hold,

The shapen-ancient token, that hath no change nor end, No change, and no beginning, no flaw for God to mend: Then Sigurd cries: ‘O Brynhild, now hearken while I swear That the sun shall die in the heavens and the day no more be fair, If I seek not love in Lymdale and the house that fostered thee, And the land where thou awakedst ’twixt the woodland and the sea! And she cried: ‘O Sigurd, Sigurd, now hearken while I swear That the day shall die forever and the sun to blackness wear, Ere I forget thee, Sigurd, as I lie ’twixt wood and sea In the little land of Lymdale and the house that fostered me!’”

According to some authorities, after thus plighting their troth the lovers parted; according to others, Sigurd soon sought out and married Brunhild, with whom he lived for a while in perfect happiness, until forced to leave her and his infant daughter Aslaug. This child, left orphaned at three years of age, was fostered by Brunhild’s father, who, driven away from home, concealed her in a cunningly fashioned harp, until reaching a distant land he was murdered by a peasant couple for the sake of the gold they supposed it to contain. Their surprise and disappointment were great indeed when, on breaking the instrument open, they found a beautiful little girl, whom they deemed mute, as she would not speak a word. Time passed on, and the child, whom they had trained to do all their labor, grew up to be a beautiful maiden who won the affections of a passing viking, Ragnar Lodbrog, King of the Danes, to whom she told her tale. After a year’s probation, during which he won glory in many lands, he came back and married her

The fostering of Aslaug.

“She heard a voice she deemed well known, Long waited through dull hours bygone, And round her mighty arms were cast:

But when her trembling red lips passed From out the heaven of that dear kiss, And eyes met eyes, she saw in his Fresh pride, fresh hope, fresh love, and saw The long sweet days still onward draw, Themselves still going hand in hand, As now they went adown the strand.”

T F A (William Morris).

The story of Sigurd and Brunhild did not end on the Hindarfial, however, for the hero soon went to seek adventures in the great world, where he had vowed, in true knightly fashion, to right the wrong and defend the fatherless and oppressed.

In the course of his wanderings, Sigurd finally came to the land of the Niblungs, the land of continual mist, where Giuki and Grimhild were king and queen. The latter was specially powerful, as she was well versed in magic lore and could not only weave spells and mutter incantations, but could also concoct marvelous potions which would steep the drinker in temporary forgetfulness and make him yield to whatever she wished.

The Niblungs.

The Niblung king was father of three sons, Gunnar, Högni, and Guttorm, who were brave young men, and of one daughter, Gudrun, the gentlest as well as the most beautiful of maidens. Sigurd was warmly welcomed by Giuki, and invited to tarry awhile. He accepted the invitation, shared all the pleasures and occupations of the Niblungs, even accompanying them to war, where he distinguished himself by his valor, and so won the admiration of Grimhild that she resolved to secure him as her daughter’s husband at any price. She therefore brewed one of her magic potions, which she bade Gudrun give him, and when he had partaken of it, he utterly forgot Brunhild and his plighted troth, and gazed upon Gudrun with an admiration which by the queen’s machinations was soon changed to ardent love.

“But the heart was changed in Sigurd; as though it ne’er had been

His love of Brynhild perished as he gazed on the Niblung Queen: Brynhild’s beloved body was e’en as a wasted hearth, No more for bale or blessing, for plenty or for dearth.”

Although haunted by a vague dread that he had forgotten something important, Sigurd asked for and obtained Gudrun’s hand, and celebrated his wedding amid the rejoicings of the people, who loved him very dearly. He gave his bride some of Fafnir’s heart to eat, and the moment she had tasted it her nature was changed, and she began to grow cold and silent to all except him. Sigurd further cemented his alliance with the eldest two Giukings (as the sons of Giuki were called) by stepping down into the doom ring with them, cutting out a sod which was placed upon a shield, beneath which they stood while they bared and slightly cut their right arms, and allowing their blood to mingle in the fresh earth, over which the sod was again laid after they had sworn eternal friendship.

But although Sigurd loved his wife and felt true brotherly affection for her brothers, he could not get rid of his haunting sense of oppression, and was seldom seen to smile as radiantly as of old. Giuki having died, Grimhild besought Gunnar, his successor, to take a wife, suggesting that none seemed more worthy to become Queen of the Niblungs than Brunhild, who, it was reported, sat in a golden hall surrounded by flames, whence she had declared she would issue only to marry the warrior who would dare pass through the fire to her side.

Gunnar immediately prepared to seek this bride, and strengthened by one of his mother’s magic potions, and encouraged by Sigurd, who accompanied him, he felt very confident of success. But when he would daringly have ridden straight into the fire, his steed drew back affrighted and he could not induce him to advance a step. Seeing that Greyfell did not flinch, he asked him of Sigurd; but although the steed allowed Gunnar to mount, he would not stir unless his master were on his back. Gunnar, disappointed, sprang to earth and accepted Sigurd’s proposal to assume his face and form, ride

Gunnar’s stratagem.

through the flames, and woo the bride by proxy. This deception could easily be carried out, thanks to the Helmet of Dread, and to a magic potion which Grimhild had given Gunnar.

The transformation having been brought about, Greyfell bounded through the flames with his master, and bore him to the palace door, where he dismounted, and entering the large hall came into the presence of Brunhild, whom he failed to recognize, owing to Grimhild’s spell. Brunhild started back in dismay when she saw the dark-haired knight, for she had deemed it utterly impossible for any but Sigurd to cross the flames, and she, too, did not know her lover in his altered guise.

Reluctantly she rose from her seat to receive him, and as she had bound herself by a solemn oath to accept as husband the man who braved the flames, she allowed him to take his lawful place by her side. Sigurd silently approached, carefully laid his drawn sword between them, and satisfied Brunhild’s curiosity concerning this singular behavior by telling her that the gods had bidden him celebrate his wedding thus.

“There they went in one bed together; but the foster-brother laid ’Twixt him and the body of Brynhild his bright blue battle-blade, And she looked and heeded it nothing; but, e’en as the dead folk lie, With folded hands she lay there, and let the night go by: And as still lay that image of Gunnar as the dead of life forlorn, And hand on hand he folded as he waited for the morn. So oft in the moonlit minster your fathers may ye see By the side of the ancient mothers await the day to be.”

Three days passed thus, and when the fourth morning dawned, Sigurd drew the ring Andvaranaut from Brunhild’s hand, replaced it by another, and received her solemn promise that in ten days’ time she would appear at the Niblung court to take up her duties as queen and be a faithful wife.

GUDRUN GIVING THE MAGIC DRINK TO SIGURD.—Th. Pixis.

“I thank thee, King, for thy goodwill, and thy pledge of love I take. Depart with my troth to thy people: but ere full ten days are o’er I shall come to the Sons of the Niblungs, and then shall we part no more Till the day of the change of our life-days, when Odin and Freya shall call.”

Then Sigurd again passed out of the palace through the ashes lying white and cold, and joined Gunnar, with whom he hastened to exchange forms once more, after he had reported the success of his venture. The warriors rode homeward together, and Sigurd revealed only to Gudrun the secret of her brother’s wooing, giving her the fatal ring, which he little suspected would be the cause of many woes.

True to her promise, Brunhild appeared ten days later, solemnly blessed the house she was about to enter, greeted Gunnar kindly, and allowed him to conduct her to the great hall, where she saw Sigurd seated beside Gudrun. He looked up at the selfsame moment, and as he encountered Brunhild’s reproachful glance Grimhild’s spell was broken and he was struck by an anguished recollection of the happy past. It was too late, however: they were both in honor bound, he to Gudrun and she to Gunnar, whom she passively followed to the high seat, where she sat beside him listening to the songs of the bards.

But, although apparently calm, Brunhild’s heart was hot with anger, and she silently nursed her wrath, often stealing out of her husband’s palace to wander alone in the forest, where she could give vent to her grief.

In the mean while, Gunnar, seeing his wife so coldly indifferent to all his protestations of affection, began to have jealous suspicions and wondered whether Sigurd had honestly told the whole story of the wooing, and whether he had not taken advantage of his position to win Brunhild’s love. Sigurd alone continued the even tenor of his way, doing good to all, fighting none but tyrants and oppressors, and cheering all he met by his kindly words and smile.

Quarrel of the queens.

One day the queens went down to the Rhine to bathe, and as they were entering the water Gudrun claimed precedence by right of her husband’s courage. Brunhild refused to yield what she deemed her right, and a quarrel ensued, in the course of which Gudrun accused her sister-in-law of infidelity, producing the ring Andvaranaut in support of her charge. Crushed by this revelation, Brunhild hastened homeward, and lay on her bed in speechless grief day after day, until all thought she would die. In vain did Gunnar and all the members of the royal family seek her in turn and implore her to speak; she would not utter a word until Sigurd came and inquired the cause of her great grief. Like a long-pent-up stream, her love and anger now burst forth, and she overwhelmed the hero with reproaches, until his heart swelled with grief for her sorrow and burst the tight bands of his strong armor.

“Out went Sigurd From that interview

Into the hall of kings, Writhing with anguish; So that began to start The ardent warrior’s Iron-woven sark

Off from his sides.”

S’ E (Thorpe’s tr.).

But although he even offered to repudiate Gudrun to reinstate her in her former rights, she refused to listen to his words, and dismissed him, saying that she must never prove faithless to Gunnar. Her pride was such, however, that she could not endure the thought that two living men had called her wife, and the next time her husband sought her presence she implored him to put Sigurd to death, thus increasing his jealousy and suspicions. He refused to grant this prayer because he had sworn good fellowship with Sigurd, and she prevailed upon Högni to work her will. As he, too, did not wish to violate his oath, he induced Guttorm, by means of much persuasion and one of Grimhild’s potions, to do the dastardly deed.

Death of Sigurd.

In the dead of night, Guttorm stole into Sigurd’s chamber, sword in hand; but as he bent over the bed he saw Sigurd’s bright eyes fixed upon him, and fled precipitately. Later on he returned and the same scene was repeated; but towards morning, when he stole in for the third time, he found the hero asleep and traitorously drove his spear through his back.

Mortally wounded, Sigurd raised himself in bed, grasped his wonderful sword hanging beside him, flung it full at the flying murderer, and cut him in two just as he reached the door. His last remaining strength thus exhausted, Sigurd sank back, whispered a last farewell to the terrified Gudrun, and breathed his last.

“‘Mourn not, O Gudrun, this stroke is the last of ill; Fear leaveth the house of the Niblungs on this breaking of the morn; Mayest thou live, O woman belovèd, unforsaken, unforlorn!

It is Brynhild’s deed,’ he murmured, ‘and the woman that loves me well;

Naught now is left to repent of, and the tale abides to tell. I have done many deeds in my life-days; and all these, and my love they lie

In the hollow hand of Odin till the day of the world go by. I have done and I may not undo, I have given and I take not again: Art thou other than I, Allfather, wilt thou gather my glory in vain?’”

Sigurd’s infant son was also slain, and poor Gudrun mourned over her dead in speechless, tearless grief; while Brunhild laughed aloud, thereby incurring the wrath of Gunnar, who repented now, but too late, of his share in the dastardly crime.

While the assembled people were erecting a mighty funeral pyre —which they decorated with precious hangings, fresh flowers, and glittering arms, as was the custom for the burial of a prince—Gudrun was surrounded by women, who, seeing her tearless anguish, and fearing lest her heart would break if her tears did not flow, began to recount the bitterest sorrows they had known, one even telling of the loss of all she held dear. But their attempts to make her weep were

utterly vain, until they laid her husband’s head in her lap, bidding her kiss him as if he were still alive; then her tears began to flow in torrents.

The reaction soon set in for Brunhild also; her resentment was all forgotten when she saw Sigurd laid on the pyre in all his martial array, with the burnished armor, the Helmet of Dread, and the trappings of his horse, which was to be burned with him, as well as several of his faithful servants who could not survive his loss. She withdrew to her apartment, distributed all her wealth among her handmaidens, donned her richest array, and stretching herself out upon her bed stabbed herself.

In dying accents she then bade Gunnar lay her beside the hero she loved, with the glittering, unsheathed sword between them, as it had lain when he had wooed her by proxy. When she had breathed her last, these orders were punctually executed, and both bodies were burned amid the lamentations of all the Niblungs.

“They are gone—the lovely, the mighty, the hope of the ancient Earth: It shall labor and bear the burden as before that day of their birth: It shall groan in its blind abiding for the day that Sigurd hath sped, And the hour that Brynhild hath hastened, and the dawn that waketh the dead: It shall yearn, and be oft-times holpen, and forget their deeds no more, Till the new sun beams on Balder and the happy sealess shore.”

According to another version of the story, Sigurd was treacherously slain by the Giukings while hunting in the forest, and his body was borne home by the hunters and laid at his wife’s feet.

Gudrun, still inconsolable, and loathing the kindred who had thus treacherously robbed her of all her joy, fled from her father’s house and took refuge with Elf, Sigurd’s foster father, who, after Hiordis’s death, had married Thora, the daughter of King Hakon. The two women became great friends, and here Gudrun tarried several

years, working tapestry in which she embroidered the great deeds of Sigurd, and watching over her little daughter Swanhild, whose bright eyes reminded her so vividly of the husband whom she had lost.

Pixis.

In the mean while, Atli, Brunhild’s brother, who was now King of the Huns, had sent to Gunnar to demand atonement for his sister’s

BRUNHILD.—Th.

Atli, King of the Huns.

death; and to satisfy these claims Gunnar had promised that in due time he would give him Gudrun’s hand in marriage. Time passed, and when at last Atli clamored for the fulfillment of his promise, the Niblung brothers, with their mother Grimhild, went to seek the long-absent Gudrun, and by their persuasions and the magic potion administered by Grimhild succeeded in persuading her to leave little Swanhild in Denmark and become Atli’s wife.

Gudrun dwelt, year after year, in the land of the Huns, secretly hating her husband, whose avaricious tendencies were extremely repugnant to her; and she was not even consoled for Sigurd’s death and Swanhild’s loss by the birth of two sons, Erp and Eitel. As she lovingly thought of the past she often spoke of it, little suspecting that her descriptions of the wealth of the Niblungs excited Atli’s greed, and that he was secretly planning some pretext for getting it into his power.

Finally he decided to send Knefrud or Wingi, one of his subjects, to invite all the Niblung princes to visit his court, intending to slay them when he should have them at his mercy; but Gudrun, fathoming this design, sent a runic-written warning to her brothers, together with the ring Andvaranaut, around which she had twined a wolf’s hair. On the way, however, the messenger partly effaced the runes, thus changing their meaning; and when he appeared before the Niblungs, Gunnar accepted the invitation, in spite of Högni’s and Grimhild’s warnings and the ominous dream of his new wife Glaumvor.

Before his departure, however, they prevailed upon him to secretly bury the great Niblung hoard in the Rhine, where it was sunk in a deep hole, the position of which was known to the royal brothers only, and which they took a solemn oath never to reveal.

“Down then and whirling outward the ruddy Gold fell forth, As a flame in the dim gray morning flashed out a kingdom’s worth; Then the waters roared above it, the wan water and the foam

Burial of the Niblung treasure.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.