0% found this document useful (0 votes)
5 views65 pages

100475

The document promotes a collection of ebooks focused on numeric computation, statistical data analysis, and advanced programming techniques using Java and R. It highlights various titles available for download, including works by Sergei V. Chekanov and others, aimed at students and professionals in data science and analysis. The content emphasizes practical programming approaches and the integration of different programming languages for scientific computations.

Uploaded by

logrodeliu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views65 pages

100475

The document promotes a collection of ebooks focused on numeric computation, statistical data analysis, and advanced programming techniques using Java and R. It highlights various titles available for download, including works by Sergei V. Chekanov and others, aimed at students and professionals in data science and analysis. The content emphasizes practical programming approaches and the integration of different programming languages for scientific computations.

Uploaded by

logrodeliu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Explore the full ebook collection and download it now at textbookfull.

com

Numeric Computation and Statistical Data Analysis


on the Java Platform Advanced Information and
Knowledge Processing Chekanov Sergei V

https://textbookfull.com/product/numeric-computation-and-
statistical-data-analysis-on-the-java-platform-advanced-
information-and-knowledge-processing-chekanov-sergei-v/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Scientific Data Analysis using Jython Scripting and Java


Advanced Information and Knowledge Processing 2010th
Edition Chekanov Sergei V
https://textbookfull.com/product/scientific-data-analysis-using-
jython-scripting-and-java-advanced-information-and-knowledge-
processing-2010th-edition-chekanov-sergei-v/
textbookfull.com

Advanced R Statistical Programming and Data Models:


Analysis, Machine Learning, and Visualization 1st Edition
Matt Wiley
https://textbookfull.com/product/advanced-r-statistical-programming-
and-data-models-analysis-machine-learning-and-visualization-1st-
edition-matt-wiley/
textbookfull.com

Metaprogramming in R: Advanced Statistical Programming for


Data Science, Analysis and Finance 1st Edition Thomas
Mailund
https://textbookfull.com/product/metaprogramming-in-r-advanced-
statistical-programming-for-data-science-analysis-and-finance-1st-
edition-thomas-mailund/
textbookfull.com

Real Estate Analysis in the Information Age Techniques for


Big Data and Statistical Modeling 1st Edition Winson-
Geideman
https://textbookfull.com/product/real-estate-analysis-in-the-
information-age-techniques-for-big-data-and-statistical-modeling-1st-
edition-winson-geideman/
textbookfull.com
Functional Programming in R: Advanced Statistical
Programming for Data Science, Analysis and Finance 1st
Edition Thomas Mailund
https://textbookfull.com/product/functional-programming-in-r-advanced-
statistical-programming-for-data-science-analysis-and-finance-1st-
edition-thomas-mailund/
textbookfull.com

Advanced Object-Oriented Programming in R: Statistical


Programming for Data Science, Analysis and Finance 1st
Edition Thomas Mailund
https://textbookfull.com/product/advanced-object-oriented-programming-
in-r-statistical-programming-for-data-science-analysis-and-
finance-1st-edition-thomas-mailund/
textbookfull.com

Statistical Data Analysis using SAS Intermediate


Statistical Methods Mervyn G. Marasinghe

https://textbookfull.com/product/statistical-data-analysis-using-sas-
intermediate-statistical-methods-mervyn-g-marasinghe/

textbookfull.com

Advanced linear modeling statistical learning and


dependent data 3rd Edition Christensen R

https://textbookfull.com/product/advanced-linear-modeling-statistical-
learning-and-dependent-data-3rd-edition-christensen-r/

textbookfull.com

Advanced Information Networking and Applications:


Proceedings of the 33rd International Conference on
Advanced Information Networking and Applications
(AINA-2019) Leonard Barolli
https://textbookfull.com/product/advanced-information-networking-and-
applications-proceedings-of-the-33rd-international-conference-on-
advanced-information-networking-and-applications-aina-2019-leonard-
barolli/
textbookfull.com
Advanced Information and Knowledge Processing

Sergei V. Chekanov

Numeric
Computation and
Statistical Data
Analysis on the
Java Platform
Advanced Information and Knowledge
Processing

Series editors
Lakhmi C. Jain
Bournemouth University, Poole, UK and
University of South Australia, Adelaide, Australia

Xindong Wu
University of Vermont
Information systems and intelligent knowledge processing are playing an increasing
role in business, science and technology. Recently, advanced information systems
have evolved to facilitate the co-evolution of human and information networks
within communities. These advanced information systems use various paradigms
including artificial intelligence, knowledge management, and neural science as well
as conventional information processing paradigms. The aim of this series is to
publish books on new designs and applications of advanced information and
knowledge processing paradigms in areas including but not limited to aviation,
business, security, education, engineering, health, management, and science. Books
in the series should have a strong focus on information processing—preferably
combined with, or extended by, new results from adjacent sciences. Proposals for
research monographs, reference books, coherently integrated multi-author edited
books, and handbooks will be considered for the series and each proposal will be
reviewed by the Series Editors, with additional reviews from the editorial board and
independent reviewers where appropriate. Titles published within the Advanced
Information and Knowledge Processing series are included in Thomson Reuters’
Book Citation Index.

More information about this series at http://www.springer.com/series/4738


Sergei V. Chekanov

Numeric Computation
and Statistical Data Analysis
on the Java Platform

123
Sergei V. Chekanov
HEP Division
Argonne National Laboratory
Lemont, IL
USA

Additional material to this book can be downloaded from http://extras.springer.com/.

ISSN 1610-3947 ISSN 2197-8441 (electronic)


Advanced Information and Knowledge Processing
ISBN 978-3-319-28529-0 ISBN 978-3-319-28531-3 (eBook)
DOI 10.1007/978-3-319-28531-3

Library of Congress Control Number: 2016932001

© Springer International Publishing Switzerland 2016


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained herein or
for any errors or omissions that may have been made.

Printed on acid-free paper

This Springer imprint is published by SpringerNature


The registered company is Springer International Publishing AG Switzerland
This book is dedicated to my family
Preface

Numerical and statistical algorithms are typically confined within a specific pro-
gramming language. For example, the R open-source data-analysis software uses a
specialized scripting language, which is an implementation of the “S” programming
language. Many commercial mathematical programs follow this trend. This book is
about a platform for statistical calculations using algorithms that are not confined by
a chosen language. For example, this platform allows mixing Python and Java
numerical libraries, or using them on their own. Or, one can use this book to
program statistical code using other languages, such as Groovy, Ruby, and
BeanShell. This book is about an approach to scientific programming and visual-
ization that does not set strict requirements on specific programming languages, nor
on operating systems where such calculations are performed.
There are many books written about Java—one of the most popular program-
ming languages. There are many books written about Python, which is another very
popular programming language. This book explains how to mix them, bringing
incredible algorithmic power and cutting-edge numeric libraries to scientific com-
putations and data visualization.
In this book I did not go deep inside particular scientific research area, since the
aim was to give concrete examples which illustrate which Java libraries should be
used to perform computations. In the cases when I could not cover the subject in
detail, a sufficient number of relevant references was given, so the reader can easily
find necessary information for each chapter using external sources.
Thus this book presents practical approaches to numerical computations, data
analysis, and knowledge discovery, focusing on programming techniques. Each
chapter describes the conceptual underpinning for numerical and statistical calcu-
lations using Java libraries, covering many aspects from simple multidimensional
arrays and histograms to clustering analysis, curve fitting, neural networks, and
symbolic calculations. To make the examples as simple as possible from the
computational point of view, I fully embrace the scripting approach in the course of
this book. This leads to short and clear analysis codes, so you could concentrate on
the logic of analysis flow rather than on language-specific details.

vii
viii Preface

This book uses Python as the main programming language, since it is elegant and
easy to learn. It is a great language for teaching scientific computation. For devel-
opers, this is an ideal language for fast prototyping and debugging. The book dis-
cusses how to design code snippets for numeric computation and statistics on the
Java platform. To be more exact, we will use Jython (Python implemented in Java), a
language that uses not only native Python modules, but can also access very com-
prehensive Java classes. The reader will learn how to write analysis codes, while
numerous code snippets will give you some ideas on numeric algorithms which can
easily be incorporated into realistic research application. The book includes more
than 300 code snippets to produce data-visualization plots in 2D and 3D.
I am almost convinced myself that this book is self-contained and does not
depend on detailed knowledge of computing language, although knowledge of
Python and Java is desirable. However, the reader may still need some programming
background in order to use this book with other languages, such as Groovy,
BeanShell, and Ruby, since I did not give very detailed coverage of these languages.

Who Is This Book for

This book is intended for general audiences, for those who use computing to make
sense of data surrounding us. It can be used as a source of knowledge on data
analysis and statistical calculations for students and professionals of all disciplines.
This book was written for undergraduate and graduate students, academics, pro-
fessors, and professionals of any field and any age. The book could be used as a
textbook for students.
We also hope that this book will be useful for those who study financial markets,
since the numeric algorithms discussed in this book are undoubtedly common to any
knowledge discovery research. This book equips readers with the description of a
computational platform for statistical calculations which can be viewed as an inex-
pensive alternative to costly commercial products used by financial-market analysts.
I assume the readers are not familiar with Python/Jython, the main programming
language used for code snippets in this book. But some basic understanding of
statistics and mathematics would be very helpful to understand the material of this
book.
All example codes of this book can easily be transformed to Java, Groovy,
Ruby/JRuby, or BeanShell codes. You are presumed to have knowledge of pro-
gramming in Java, if you will choose the path of moving the examples to Java, or if
you will decide to create Java libraries to be deployed as jar files for a new project.
The book will discuss how to do this, and a few Java examples will be provided.
Transformations of the example snippets to scripting languages, such as Groovy,
Ruby/JRuby, or BeanShell, may require some knowledge of these scripting
languages. The good thing is that the analysis algorithms and numerical libraries
will be exactly the same, so a little effort is required to move to other languages.
Again, we will show you how to convert Jython codes to these languages. In most
Preface ix

cases, our examples should be sufficient to get started with a new language. The
more knowledge about Groovy and Ruby/JRuby you can bring, the more you will
get out of this book.

Books You May Read Before

The material of this book is self-contained. However, to understand the material


deeper, you may need to look at other sources. First of all, there are plenty of good
books [1–5] on Python and Jython, which are more complete for language-specific
topics than the information given in this book. If you program in Java that forms the
backbone of numerical and graphical libraries discussed in this book, a great deal of
supplementary information can be found in Java books [6–10].
Secondly, there are several books on Groovy, a popular scripting language that
can be used to work with the Java numerical libraries discussed in this book [11,
12]. If your choice is JRuby, the Ruby programming language on the Java platform,
look at these books [13, 14] to get started.
Thirdly, as you read, you may need to look at external sources to understand the
material better, especially when we come to statistical interpretations of data. We will
supply the reader with the necessary references, so he or she can choose the most
appropriate (and affordable) books to discover the world of data analysis and data
mining.

References

1. Pilgrim M (2004), Dive into Python, Apress


2. Guzdial M (2005) Introduction to computing and programming in Python, a multimedia
approach, Prentice Hall
3. Martelli A (2006) Python in a nutshell (in a nutshell (O’Reilly)), O’Reilly Media, Inc.
4. Lutz M (2007) Learning Python, 3rd edn. O’Reilly Media, Inc.
5. Langtangen H (2008) Python scripting for computational science. Springer-Verlag, Berlin,
Heidelberg
6. Richardson C, Avondolio D, Vitale J et al (2005) Professional Java, JDK 5 Edition, Wrox
7. Arnold K, Gosling J, Holmes D (2005) Java(TM) programming language. In: The Java Series,
4th edn. Addison-Wesley Professional
8. Flanagan D (2005) Java in a nutshell, 5th edn. O’Reilly Media, Inc.
9. Eckel B (2006) Thinking in Java, 4th edn. Prentice Hall PTR
10. Bloch J (2008) Effective Java. In: The Java Series, 2nd edn. Prentice Hall PTR
11. Subramaniam V (2013) Programming Groovy 2: dynamic productivity for the Java
Developer, Pragmatic Programmers, LLC
12. King D, Glover A (2013) Groovy in action, Manning Publications, 2007, https://www.
manning.com/books/groovy-in-action
13. Edelson J, Liu H (2008) JRuby cookbook, O’Reilly Media
14. Bini O (2007) Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java,
Apress
Acknowledgements

This book describes a software which is a collective work of many developers who
have dedicated themselves to scientific computing. The author is grateful to all
people who contributed to scientific software, and for their inspiration and dedi-
cation to science and knowledge-discovery software.
Many numeric and graphic libraries discussed in this book were released as
open-source projects. I am grateful to the authors of such open-source programs for
their enthusiasm to share their work, and for making their software publicly
available.
You can find a list of contributions to the software packages described in this
book on the jWork.ORG web page (http://jwork.org/dmelt/). A special note of
thanks to those of you who reported bugs in a constructive way, helped with
solutions, and shared your knowledge and experience with others.
Much of this project grew out of fruitful collaboration with many of my col-
leagues who devoted themselves to high energy physics. Over the course of the past
twenty-five years I have learned a lot about programming aspects of scientific
research. I would like to thank my colleagues for checking and debugging the
examples shown in this book, and here the list will be endless.
I would like to thank everyone at Springer for their help with the production
process. In particular, managing editors H. Desmond and J. Robinson, who helped
start this book in its present form.
Not least, personal thanks go to my dear wife, Tania, and my sons, Alexey
(Alosha) and Roman, for their love and patience to a husband and father who was
only half (mentally) present after coming from his work. Without their patience and
understanding, this book would not have been possible. Finally, I also thank my
parents and sister for their support of my interests in all aspects of science.

Chicago Sergei V. Chekanov


January 2016

xi
Contents

1 Java Computational Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Programming in Java. . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 The DMelt Software Platform. . . . . . . . . . . . . . . . 3
1.1.3 Some Warnings . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.4 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Scripting with DMelt . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.1 Learning by Example . . . . . . . . . . . . . . . . . . . . . 7
1.2.2 Using Jython for Code Examples . . . . . . . . . . . . . 8
1.2.3 Differences with Other Math Software . . . . . . . . . . 9
1.3 Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4 DMelt Workbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.1 Source Code Editor . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.2 DMelt Libraries . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.3 Jython and BeanShell Consoles . . . . . . . . . . . . . . 15
1.4.4 Accessing Methods of Instances . . . . . . . . . . . . . . 17
1.4.5 Editing Jython Scripts . . . . . . . . . . . . . . . . . . . . . 17
1.4.6 Running Jython Scripts . . . . . . . . . . . . . . . . . . . . 17
1.4.7 Macro Files of the DMelt IDE . . . . . . . . . . . . . . . 18
1.4.8 Running BeanShell Scripts . . . . . . . . . . . . . . . . . . 19
1.4.9 Compiling and Running Java Code . . . . . . . . . . . . 19
1.4.10 DMelt Code Assist . . . . . . . . . . . . . . . . . . . . . . . 20
1.4.11 Other Features . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.4.12 Working with Images . . . . . . . . . . . . . . . . . . . . . 23
1.4.13 DMelt License . . . . . . . . . . . . . . . . . . . . . . . . . . 24
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

xiii
xiv Contents

2 Introduction to Jython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.1 Code Structure and Jython Objects . . . . . . . . . . . . . . . . . . . 27
2.1.1 Numbers as Objects . . . . . . . . . . . . . . . . . . . . . . 30
2.1.2 Formatted Output . . . . . . . . . . . . . . . . . . . . . . . . 32
2.1.3 Mathematical Functions . . . . . . . . . . . . . . . . . . . . 32
2.2 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.3 Strings as Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4 Import Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.4.1 Executing Native Applications . . . . . . . . . . . . . . . 37
2.5 Comparison Tests and Loops . . . . . . . . . . . . . . . . . . . . . . . 38
2.5.1 The “if-else” Statement . . . . . . . . . . . . . . . . . . . . 38
2.5.2 Loops. The “for” Statement . . . . . . . . . . . . . . . . . 39
2.5.3 The “continue” and “break” Statements . . . . . . . . . 39
2.5.4 Loops. The “while” Statement . . . . . . . . . . . . . . . 40
2.6 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.6.1 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.6.2 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.6.3 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.6.4 Functional Programming . . . . . . . . . . . . . . . . . . . 48
2.7 Java Collections in Jython . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.7.1 List. An Ordered Collection . . . . . . . . . . . . . . . . . 50
2.7.2 Set. A Collection Without Duplicate Elements . . . . 53
2.7.3 SortedSet. Sorted Unique Elements . . . . . . . . . . . . 54
2.7.4 Map. Mapping Keys to Values . . . . . . . . . . . . . . . 55
2.7.5 Java Map with Sorted Elements . . . . . . . . . . . . . . 55
2.7.6 Real-Life Example: Sorting and Removing
Duplicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.8 Random Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
2.9 Time Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
2.9.1 Benchmarking . . . . . . . . . . . . . . . . . . . . . . . . . . 59
2.10 Python Functions and Modules. . . . . . . . . . . . . . . . . . . . . . 60
2.11 Python Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.11.1 Initializing a Class . . . . . . . . . . . . . . . . . . . . . . . 65
2.11.2 Classes Inherited from Other Classes. . . . . . . . . . . 65
2.11.3 Java Classes in Jython . . . . . . . . . . . . . . . . . . . . . 66
2.11.4 Not Covered Topics . . . . . . . . . . . . . . . . . . . . . . 66
2.12 Parallel Computing and Threads . . . . . . . . . . . . . . . . . . . . . 67
2.13 Arrays in Jython. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
2.13.1 Array Conversion and Transformations . . . . . . . . . 69
2.13.2 Performance Issues . . . . . . . . . . . . . . . . . . . . . . . 69
2.13.3 Used Memory . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.14 Exceptions in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Contents xv

2.15 Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72


2.15.1 User Interaction . . . . . . . . . . . . . . . . . . . . . . . . . 72
2.15.2 Reading and Writing Files . . . . . . . . . . . . . . . . . . 72
2.15.3 Input and Output for Arrays . . . . . . . . . . . . . . . . . 74
2.15.4 Working with CSV Python Module. . . . . . . . . . . . 74
2.15.5 Saving Objects in a Serialized File . . . . . . . . . . . . 76
2.15.6 Storing Multiple Objects . . . . . . . . . . . . . . . . . . . 77
2.15.7 Using Java for I/O . . . . . . . . . . . . . . . . . . . . . . . 78
2.15.8 Reading Data from the Network . . . . . . . . . . . . . . 79
2.16 Real-Life Example. Collecting Data Files . . . . . . . . . . . . . . 80
2.17 Using Java for GUI Programming. . . . . . . . . . . . . . . . . . . . 82
2.18 Concluding Remarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3 Mathematical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.1 Python Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.2 Functions in DMelt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.2.1 Java Implementation of F1D . . . . . . . . . . . . . . . . 89
3.2.2 Manipulations with 1D Functions . . . . . . . . . . . . . 90
3.3 Plotting 1D Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
3.3.1 Building a Graphical Canvas . . . . . . . . . . . . . . . . 93
3.3.2 Drawing 1D Functions . . . . . . . . . . . . . . . . . . . . 97
3.3.3 Plotting Functions on Different Pads . . . . . . . . . . . 99
3.3.4 Short Summary of HPlot Methods . . . . . . . . . . . . 99
3.3.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
3.4 2D Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.4.1 Functions in Two Dimensions . . . . . . . . . . . . . . . 102
3.4.2 Displaying 2D Functions . . . . . . . . . . . . . . . . . . . 103
3.4.3 Using a Contour Plot. . . . . . . . . . . . . . . . . . . . . . 105
3.5 3D Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.5.1 Functions in Three Dimensions. . . . . . . . . . . . . . . 106
3.6 Functions in Many Dimensions . . . . . . . . . . . . . . . . . . . . . 107
3.6.1 FND Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.6.2 Drawing FND Functions . . . . . . . . . . . . . . . . . . . 108
3.7 Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
3.7.1 Custom Functions and Their Methods . . . . . . . . . . 109
3.7.2 Custom Functions Using Expression Builder . . . . . 112
3.7.3 Custom Functions in Jython . . . . . . . . . . . . . . . . . 114
3.8 Parametric Surfaces in 3D . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.8.1 FPR Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.8.2 3D Mathematical Objects . . . . . . . . . . . . . . . . . . . 122
xvi Contents

3.9 Function Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . 122


3.9.1 Minimization of Multidimensional Functions . . . . . 125
3.9.2 Calling Migrad Directly . . . . . . . . . . . . . . . . . . . . 126
3.10 File Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
4 Data Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
4.1 1D Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
4.1.1 P0D Data Container . . . . . . . . . . . . . . . . . . . . . . 132
4.1.2 P0D Transformations. . . . . . . . . . . . . . . . . . . . . . 135
4.1.3 Statistical Summary. . . . . . . . . . . . . . . . . . . . . . . 136
4.1.4 Displaying P0D Data. . . . . . . . . . . . . . . . . . . . . . 138
4.1.5 File Input and Output . . . . . . . . . . . . . . . . . . . . . 139
4.2 Arrays for Two Dimensions . . . . . . . . . . . . . . . . . . . . . . . . 143
4.2.1 Data with Errors . . . . . . . . . . . . . . . . . . . . . . . . . 144
4.2.2 Viewing P1D Data . . . . . . . . . . . . . . . . . . . . . . . 150
4.2.3 Plotting P1D Data. . . . . . . . . . . . . . . . . . . . . . . . 151
4.2.4 Contour Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
4.2.5 Manipulations with P1D Data. . . . . . . . . . . . . . . . 153
4.2.6 Advanced P1D Operations . . . . . . . . . . . . . . . . . . 155
4.2.7 Weighted Average and Systematical
Uncertainties . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
4.2.8 File Input and Output . . . . . . . . . . . . . . . . . . . . . 159
4.2.9 Example I: Henon Attractor . . . . . . . . . . . . . . . . . 162
4.2.10 Example II. Weighted Average . . . . . . . . . . . . . . . 163
4.3 Other Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
4.3.1 P2D Data Container . . . . . . . . . . . . . . . . . . . . . . 166
4.3.2 P3D Data Container . . . . . . . . . . . . . . . . . . . . . . 169
4.3.3 PND Data Container . . . . . . . . . . . . . . . . . . . . . . 171
4.3.4 File Input and Output . . . . . . . . . . . . . . . . . . . . . 174
4.4 Third-Party Data Containers. . . . . . . . . . . . . . . . . . . . . . . . 174
4.4.1 Math Arrays. . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
4.4.2 Jaida Data Containers . . . . . . . . . . . . . . . . . . . . . 175
4.4.3 jMathTools Arrays . . . . . . . . . . . . . . . . . . . . . . . 178
4.4.4 Colt Data Containers . . . . . . . . . . . . . . . . . . . . . . 181
4.4.5 Lorentz Vector . . . . . . . . . . . . . . . . . . . . . . . . . . 182
4.5 Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 185
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
5 Linear Algebra and Equations . . . . . . . . . . . . . . . . . . . . . . . . . . 187
5.1 Vector and Matrix Packages . . . . . . . . . . . . . . . . . . . . . . . 187
5.1.1 Basic Matrix Arithmetic. . . . . . . . . . . . . . . . . . . . 189
5.1.2 Elements of Linear Algebra . . . . . . . . . . . . . . . . . 190
5.1.3 Jampack Matrix Computations . . . . . . . . . . . . . . . 191
5.1.4 La4J Library . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Contents xvii

5.1.5 EJML Matrix Library . . . . . . . . . . . . . . . . . . . . . 195


5.1.6 Multithreaded Matrix Computations . . . . . . . . . . . 196
5.1.7 JBlas and Other Matrix Packages . . . . . . . . . . . . . 199
5.1.8 Python Vector and Matrix Operations . . . . . . . . . . 199
5.1.9 Matrix Operations in SymPy . . . . . . . . . . . . . . . . 201
5.2 Algebraic Manipulations with Tensors. . . . . . . . . . . . . . . . . 202
5.3 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
5.3.1 Polynomial Equations . . . . . . . . . . . . . . . . . . . . . 203
5.3.2 Linear Systems of Equations . . . . . . . . . . . . . . . . 204
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
6 Symbolic Computations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
6.1 Using the Octave Language . . . . . . . . . . . . . . . . . . . . . . . . 207
6.2 Java Symbolic Computing Library . . . . . . . . . . . . . . . . . . . 208
6.2.1 Conversion to Elementary Functions . . . . . . . . . . . 210
6.2.2 Numeric Calculations . . . . . . . . . . . . . . . . . . . . . 210
6.2.3 Simplify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
6.2.4 Substitutions. . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
6.2.5 Differentiate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
6.2.6 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
6.2.7 Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
6.2.8 MathML Output . . . . . . . . . . . . . . . . . . . . . . . . . 213
6.2.9 Integration with DMelt Plotting Canvases . . . . . . . 213
6.3 Using SymPy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
7 Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
7.1 One-Dimensional Histogram . . . . . . . . . . . . . . . . . . . . . . . 220
7.1.1 Probability Distribution and Probability Density . . . 224
7.1.2 Histogram Characteristics. . . . . . . . . . . . . . . . . . . 225
7.1.3 Initialization and Filling Methods . . . . . . . . . . . . . 225
7.1.4 Accessing Histogram Values . . . . . . . . . . . . . . . . 228
7.1.5 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
7.1.6 Histogram Operations . . . . . . . . . . . . . . . . . . . . . 230
7.1.7 Accessing Low-Level Jaida Classes. . . . . . . . . . . . 231
7.1.8 Graphical Attributes . . . . . . . . . . . . . . . . . . . . . . 232
7.2 Histogram in 2D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
7.2.1 Histogram Operations . . . . . . . . . . . . . . . . . . . . . 236
7.2.2 Graphical Representation . . . . . . . . . . . . . . . . . . . 236
7.3 Histograms in Jaida . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
7.4 Histogram in 3D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
7.5 Profile Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
xviii Contents

7.6 Histogram Input and Output. . . . . . . . . . . . . . . . . . . . . . . . 244


7.6.1 External Programs for Histograms. . . . . . . . . . . . . 246
7.7 Analyzing Histograms from Multiple Files. . . . . . . . . . . . . . 247
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
8 Scientific visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.1 Graphical Canvases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
8.2 HPlot Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
8.2.1 Working with the HPlot Canvas . . . . . . . . . . . . . . 255
8.2.2 Saving Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
8.2.3 Reading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
8.2.4 Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
8.2.5 Summary of the HPlot Methods . . . . . . . . . . . . . . 259
8.2.6 Exporting to Image Files . . . . . . . . . . . . . . . . . . . 261
8.2.7 Labels and Keys . . . . . . . . . . . . . . . . . . . . . . . . . 262
8.2.8 Geometrical Primitives. . . . . . . . . . . . . . . . . . . . . 265
8.2.9 Text Strings and Symbols . . . . . . . . . . . . . . . . . . 266
8.3 Interconnected Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
8.4 Showing Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
8.5 Lightweight Canvases . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
8.5.1 Henon Attractor Again . . . . . . . . . . . . . . . . . . . . 275
8.6 Canvas for Interactive Drawing . . . . . . . . . . . . . . . . . . . . . 276
8.6.1 Drawing Diagrams . . . . . . . . . . . . . . . . . . . . . . . 277
8.6.2 SHPlotJa Class . . . . . . . . . . . . . . . . . . . . . . . . . . 279
8.7 Custom Plotting in XY . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
8.7.1 HPlotXY Canvas . . . . . . . . . . . . . . . . . . . . . . . . 279
8.7.2 WPlot Canvas . . . . . . . . . . . . . . . . . . . . . . . . . . 280
8.7.3 HPlotJas Canvas . . . . . . . . . . . . . . . . . . . . . . . . . 281
8.8 HPlot2D Canvas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
8.9 Visualization in 3D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
8.9.1 HPlot3D Canvas . . . . . . . . . . . . . . . . . . . . . . . . . 285
8.9.2 HPlot3DP Canvas . . . . . . . . . . . . . . . . . . . . . . . . 285
8.9.3 Mathematical Objects in 3D . . . . . . . . . . . . . . . . . 289
8.10 Plotting Real-Time Data . . . . . . . . . . . . . . . . . . . . . . . . . . 291
8.10.1 Real-Time Data Using SPlot . . . . . . . . . . . . . . . . 292
8.10.2 Real-Time Data Using HPlotRT . . . . . . . . . . . . . . 293
8.11 Graphs and Java GUI Components . . . . . . . . . . . . . . . . . . . 293
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
9 File Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
9.1 Nonpersistent Data: Memory-Based Data. . . . . . . . . . . . . . . 297
9.2 Object Serialization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
9.3 Persistent Event Records . . . . . . . . . . . . . . . . . . . . . . . . . . 300
9.3.1 Sequential Input and Output . . . . . . . . . . . . . . . . . 300
9.3.2 Opening Data in a Browser . . . . . . . . . . . . . . . . . 302
Contents xix

9.3.3 Saving Event Records Persistently. . . . . . . . . . . . . 303


9.3.4 Buffer Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
9.3.5 XML File Format . . . . . . . . . . . . . . . . . . . . . . . . 305
9.4 PFile Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
9.4.1 Browser for PFile File Data . . . . . . . . . . . . . . . . . 308
9.5 HBook XML Data Output . . . . . . . . . . . . . . . . . . . . . . . . . 309
9.6 Text File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
9.6.1 Working with ASCII Files . . . . . . . . . . . . . . . . . . 311
9.6.2 CSV File Format . . . . . . . . . . . . . . . . . . . . . . . . 312
9.6.3 EDN File Format . . . . . . . . . . . . . . . . . . . . . . . . 315
9.6.4 DIF File Format . . . . . . . . . . . . . . . . . . . . . . . . . 316
9.7 Reading ROOT and AIDA Files. . . . . . . . . . . . . . . . . . . . . 317
9.7.1 ROOT Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
9.7.2 AIDA Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
9.8 Google’s Protocol Buffer Format . . . . . . . . . . . . . . . . . . . . 318
9.8.1 Prototyping Data Records . . . . . . . . . . . . . . . . . . 319
9.8.2 Dealing with Data Using Java . . . . . . . . . . . . . . . 321
9.8.3 Switching to Jython . . . . . . . . . . . . . . . . . . . . . . 323
9.8.4 Adding New Data Records. . . . . . . . . . . . . . . . . . 324
9.8.5 Using C++ with the Protocol Buffers. . . . . . . . . . . 325
9.8.6 Some Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . 327
9.9 Creating Excel Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
9.10 Non-SQL Object Databases . . . . . . . . . . . . . . . . . . . . . . . . 330
9.10.1 Nonsequential Input and Output . . . . . . . . . . . . . . 330
9.10.2 Persistent Map . . . . . . . . . . . . . . . . . . . . . . . . . . 332
9.10.3 MapDB Database . . . . . . . . . . . . . . . . . . . . . . . . 333
9.10.4 NeoDatis Database . . . . . . . . . . . . . . . . . . . . . . . 334
9.11 Relational SQL Databases . . . . . . . . . . . . . . . . . . . . . . . . . 335
9.11.1 Derby SQL Database. . . . . . . . . . . . . . . . . . . . . . 336
9.11.2 HyperSQL Database . . . . . . . . . . . . . . . . . . . . . . 341
9.11.3 SQLite Database . . . . . . . . . . . . . . . . . . . . . . . . . 342
9.12 Miscellaneous Input–Output Topics . . . . . . . . . . . . . . . . . . 343
9.12.1 Building List of Files . . . . . . . . . . . . . . . . . . . . . 343
9.12.2 Reading Configuration Files . . . . . . . . . . . . . . . . . 344
9.13 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
9.13.1 Dealing with Single Objects . . . . . . . . . . . . . . . . . 347
9.13.2 Dealing with Object Collections . . . . . . . . . . . . . . 347
9.13.3 Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
9.13.4 Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
10 Probability and Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
10.1 Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
10.1.1 Comparing Data . . . . . . . . . . . . . . . . . . . . . . . . . 355
10.2 Statistical Analysis Using Python . . . . . . . . . . . . . . . . . . . . 356
xx Contents

10.3 Random Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359


10.3.1 Using Random Numbers . . . . . . . . . . . . . . . . . . . 360
10.3.2 Random Numbers in Colt . . . . . . . . . . . . . . . . . . 362
10.3.3 Other Packages with Random Numbers . . . . . . . . . 364
10.4 Random Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
10.4.1 Methods of 1D Arrays. . . . . . . . . . . . . . . . . . . . . 368
10.4.2 Methods of 2D Arrays. . . . . . . . . . . . . . . . . . . . . 370
10.4.3 Sampling Using the Colt Package . . . . . . . . . . . . . 372
10.5 Statistical Significance and Confidence Levels . . . . . . . . . . . 373
10.5.1 Statistical Significance . . . . . . . . . . . . . . . . . . . . . 373
10.5.2 Discovery Sensitivity. . . . . . . . . . . . . . . . . . . . . . 376
10.5.3 Confidence Interval . . . . . . . . . . . . . . . . . . . . . . . 377
10.5.4 Confidence Levels for Small Statistics . . . . . . . . . . 378
10.5.5 Statistical Tests. . . . . . . . . . . . . . . . . . . . . . . . . . 382
10.5.6 Confidence Levels for Distributions. . . . . . . . . . . . 385
10.6 Error Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
10.6.1 Propagation Using Monte Carlo Technique . . . . . . 395
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
11 Linear Regression and Curve Fitting . . . . . . . . . . . . . . . . . . . . . 399
11.1 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
11.1.1 Creating Input Data. . . . . . . . . . . . . . . . . . . . . . . 400
11.1.2 Performing a Linear Regression . . . . . . . . . . . . . . 400
11.2 Curve Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
11.2.1 Preparing a Fit . . . . . . . . . . . . . . . . . . . . . . . . . . 404
11.2.2 Creating a Fit Function . . . . . . . . . . . . . . . . . . . . 406
11.2.3 Displaying Fit Functions . . . . . . . . . . . . . . . . . . . 410
11.2.4 Making a Fit . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
11.3 Real-Life Example. Signal Plus Background . . . . . . . . . . . . 413
11.3.1 Preparing a Data Sample . . . . . . . . . . . . . . . . . . . 413
11.3.2 Performing Curve Fitting . . . . . . . . . . . . . . . . . . . 413
11.3.3 Fitting Multiple Peaks . . . . . . . . . . . . . . . . . . . . . 415
11.3.4 Fitting Histograms in 3D . . . . . . . . . . . . . . . . . . . 417
11.4 Interactive Fit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
11.4.1 HFit Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
11.4.2 JAS Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
11.5 Polynomial Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
11.6 Advanced Data Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
11.7 Fitting Using Parametric Equations . . . . . . . . . . . . . . . . . . . 425
11.8 Symbolic Regression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
12 Data Analysis and Data Mining . . . . . . . . . . . . . . . . . . . . . . . . . 431
12.1 First Steps in Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . 432
Contents xxi

12.2 Real Life Example. Analyzing a Gene Catalog . . . ..... . . . 434


12.2.1 Data Transformation . . . . . . . . . . . . . . ..... . . . 435
12.2.2 Data Skimming. . . . . . . . . . . . . . . . . . ..... . . . 435
12.2.3 Data Slimming . . . . . . . . . . . . . . . . . . ..... . . . 436
12.2.4 Data Sorting. . . . . . . . . . . . . . . . . . . . ..... . . . 436
12.2.5 Removing Duplicate Records . . . . . . . . ..... . . . 438
12.2.6 Sorting and Duplicate Removal in Java . ..... . . . 439
12.3 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... . . . 440
12.3.1 Using Built-In Metadata File . . . . . . . . ..... . . . 441
12.3.2 External Metadata Files . . . . . . . . . . . . ..... . . . 444
12.4 Multithreaded Programming . . . . . . . . . . . . . . . . ..... . . . 445
12.4.1 Reading Data in Parallel . . . . . . . . . . . ..... . . . 446
12.4.2 Reading a Single File in Parallel . . . . . . ..... . . . 448
12.4.3 Numerical Computations Using Multiple Cores. . . . 451
12.5 Data Consistency and Security . . . . . . . . . . . . . . ..... . . . 452
12.5.1 MD5 Fingerprint at Runtime . . . . . . . . ..... . . . 453
12.5.2 Fingerprinting Files . . . . . . . . . . . . . . . ..... . . . 454
12.6 Real-Life Examples . . . . . . . . . . . . . . . . . . . . . ..... . . . 455
12.6.1 Single-Particle Densities . . . . . . . . . . . ..... . . . 455
12.6.2 Fluctuations and Correlations . . . . . . . . ..... . . . 458
12.6.3 Analyzing Nearby Galaxies . . . . . . . . . ..... . . . 468
12.6.4 Analyzing Elementary Particles. . . . . . . ..... . . . 470
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... . . . 473
13 Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
13.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
13.2 A Basic Neural Network . . . . . . . . . . . . . . . . . . . . . . . . . . 476
13.2.1 Encog Approach . . . . . . . . . . . . . . . . . . . . . . . . . 477
13.2.2 Using Neuroth . . . . . . . . . . . . . . . . . . . . . . . . . . 479
13.3 Backpropagation with Multiple Outputs. . . . . . . . . . . . . . . . 480
13.4 Numeric Predictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
13.4.1 Generating a Data Sample . . . . . . . . . . . . . . . . . . 483
13.4.2 Data Preparation . . . . . . . . . . . . . . . . . . . . . . . . . 484
13.4.3 Building a Neural Net . . . . . . . . . . . . . . . . . . . . . 486
13.4.4 Training and Verifying . . . . . . . . . . . . . . . . . . . . 488
13.5 Bayesian Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
13.5.1 Creating Bayesian Network Using Scripts . . . . . . . 491
13.5.2 HBayes Method . . . . . . . . . . . . . . . . . . . . . . . . . 494
13.6 Kohonen Self-organizing Map . . . . . . . . . . . . . . . . . . . . . . 494
13.6.1 Kohonen SOFM in 2D . . . . . . . . . . . . . . . . . . . . 495
13.6.2 Kohonen SOFM in 3D . . . . . . . . . . . . . . . . . . . . 497
xxii Contents

13.7 Bayesian Self-organizing Map . . . . . . . . . . . . . . . . . . . . . . 498


13.7.1 Noninteractive BSOM . . . . . . . . . . . . . . . . . . . . . 500
13.8 Neural Network Using Python Libraries . . . . . . . . . . . . . . . 502
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
14 Finding Regularities and Data Classification . . . . . . . . . . . . . . . . 505
14.1 Cluster Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
14.1.1 Preparing a Data Sample . . . . . . . . . . . . . . . . . . . 507
14.1.2 Clustering Analysis . . . . . . . . . . . . . . . . . . . . . . . 509
14.1.3 Interactive Clustering Analysis . . . . . . . . . . . . . . . 512
14.2 Clustering Particles into Jets. Real-Life Example . . . . . . . . . 513
14.3 Smoothing and Interpolation . . . . . . . . . . . . . . . . . . . . . . . 515
14.4 Peak Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
14.5 Principal Component Analysis . . . . . . . . . . . . . . . . . . . . . . 522
14.6 Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
15 Miscellaneous Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
15.1 Working with Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
15.1.1 Downloading Files from the Web . . . . . . . . . . . . . 527
15.1.2 Extracting Data from Figures . . . . . . . . . . . . . . . . 528
15.1.3 Tables and Spreadsheets . . . . . . . . . . . . . . . . . . . 529
15.2 Measurements with Units . . . . . . . . . . . . . . . . . . . . . . . . . 531
15.3 Cellular Automaton. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
15.4 Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
15.4.1 Image Modification . . . . . . . . . . . . . . . . . . . . . . . 537
15.4.2 Transforms Using Multiple Cores . . . . . . . . . . . . . 538
15.5 Market and Financial Analysis . . . . . . . . . . . . . . . . . . . . . . 539
15.5.1 Time Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
15.5.2 Financial Charts . . . . . . . . . . . . . . . . . . . . . . . . . 544
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
16 Using Other Languages on the Java Platform . . . . . . . . . . . . . . . 547
16.1 Python Scripting with DMelt . . . . . . . . . . . . . . . . . . . . . . . 547
16.1.1 Operations with Data Holders. . . . . . . . . . . . . . . . 550
16.1.2 Adding Python Modules . . . . . . . . . . . . . . . . . . . 551
16.2 Using Java Programming. . . . . . . . . . . . . . . . . . . . . . . . . . 551
16.2.1 External Java Libraries . . . . . . . . . . . . . . . . . . . . 554
16.2.2 Working Java Projects . . . . . . . . . . . . . . . . . . . . . 554
16.2.3 Embedding DMelt in Applets . . . . . . . . . . . . . . . . 555
16.3 Using BeanShell Language . . . . . . . . . . . . . . . . . . . . . . . . 558
16.4 Using Groovy Language . . . . . . . . . . . . . . . . . . . . . . . . . . 560
16.5 Using Ruby Language. . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
16.6 Using Octave Language . . . . . . . . . . . . . . . . . . . . . . . . . . 564
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Contents xxiii

17 Octave-Style Scripting Using Java. . . . . . . . . . . . . . . . . . . . . . . . 567


17.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
17.2 Variables and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 569
17.2.1 Symbolic Variables . . . . . . . . . . . . . . . . . . . . . . . 572
17.2.2 Operators and Commands . . . . . . . . . . . . . . . . . . 573
17.3 Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
17.4 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
17.5 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
17.5.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
17.5.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
17.6 Flow Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
17.6.1 Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
17.6.2 File Input and Output . . . . . . . . . . . . . . . . . . . . . 590
17.7 Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
17.7.1 Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . 590
17.7.2 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
17.7.3 Indefinite Integral . . . . . . . . . . . . . . . . . . . . . . . . 592
17.7.4 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . 593
17.7.5 Simplifying Expressions . . . . . . . . . . . . . . . . . . . 594
17.8 Data Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
17.8.1 Plotting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
17.8.2 Plot2D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
17.8.3 Plot3D. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
17.9 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
17.9.1 Systems of Linear Equations . . . . . . . . . . . . . . . . 604
17.9.2 Nonlinear Equations . . . . . . . . . . . . . . . . . . . . . . 605
17.9.3 Systems of Equations . . . . . . . . . . . . . . . . . . . . . 606
17.9.4 Differential Equations . . . . . . . . . . . . . . . . . . . . . 607
17.10 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
17.10.1 Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . 608
17.10.2 Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . 610
17.10.3 Data Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610
17.10.4 Histograms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
17.11 Again About Integration with Java . . . . . . . . . . . . . . . . . . . 611
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Conventions and Acronyms

This book uses the following typographical convention: A box with a code inside
usually means interactive Python/Jython commands typed in the “Jython Shell.” All
such commands start with the symbol [[[ which is the usual invitation in
Python to type a command. This is shown in the example below:

Working interactively with the Jython prompt has the drawback that it is
impossible to save typed commands. In most cases, the code snippets are not so
short, although they are still much shorter than in any other programming language.
Therefore, it is desirable to save the typed code in a file for further modification and
execution. In this case, we use Jython macro files, i.e., we write a code using the
DMelt (or any other) editor [15], save it in a file with the extension “.py”, and run it
using the keyboard shortcut [F8] or the button “run” from the DMelt tool bar
menu. Such code examples are also shown inside the box, but code lines do not
start with the Python invitation symbol [[[ . In such situations, the example
codes will be shown as:

For examples written in the Python language, double quotes and apostrophe are
interchangeable. For Java and other languages, this is not the case. So, to make our
code to be easily convertible to Java or Groovy, we will use double quotes around
strings. As in the above example, we will try to comment code lines as much as we
can. For Python, comments are preceded by the hash character.
If a code snippet is used as a Python/Jython module by other programs, then we
should write our code inside a file. A Python code always imports an external
module using its file name. Since the file names are important, we will indicate
exactly which file name should be used under the box with a code. For example, if a
program code is considered a module that has to be imported by another code
example, we will show it as:

xxv
xxvi Conventions and Acronyms

Listing 1 File “hello.py”

with the description indicating the file name. For instance,

imports the file “hello.py” and executes it, printing the string. In other cases, we
will use arbitrary file names for the code snippets.
We use typewriter font for Jython and Java classes and methods. For file
names and directories, we also use the same font style with additional parentheses.
We remind that the directory name separators are backward slashes for
Windows, and slashes for Linux and Mac computers. For example, the directory
with examples will be shown as:
macro/examples/
For Windows computers, the same directory should be shown as:
macro\examples\
The dots in this example are used to indicate the upper-level directory.
We will try to avoid using abbreviations. When we use abbreviations, we will
explain their meaning directly in the text. When space allows, we will use mean-
ingful names for variables. This is all.
Chapter 1
Java Computational Platform

1.1 Introduction

Java is both a programming language and a computing platform which runs Java
code. This book uses both. But the Java programming language is not necessary
for the approach adopted in this book, since the Java platform allows the usage of
scripting languages, such as Jython/Python, Groovy, Ruby/JRuby, BeanShell, and
others.
The heart of the Java platform is the Java Virtual Machine (JVM) that runs
programs converted to Java bytecode programs. The conversion to bytecode is done
by Java compiler. Bytecode is the optimized and effective machine language of
JVM. The JVM reads this bytecode, interprets it, and executes the program.
In fact, even if you write your code using other programming languages, such as
Python and Groovy, which are simpler than the Java language, your code still will
be converted to Java bytecode programs.
The JVM is ported to different platforms and insulates the program from the
underlying hardware and operating system. Thus it provides hardware- and
operating-system independence. The Java application programming interface (API)
is also a part of the Java platform. Java API classes are used for building software
applications.

1.1.1 Programming in Java

First, let us discuss the Java programming language, one of the most popular
object-oriented programming languages in use. The statistics of SourceForge reports
that the number of open-source applications written in Java is close to those
written in C++. According to the TIOBE software index (http://www.tiobe.com/), a


c Springer International Publishing Switzerland 2016 1
S.V. Chekanov, Numeric Computation and Statistical Data Analysis
on the Java Platform, Advanced Information and Knowledge Processing,
DOI 10.1007/978-3-319-28531-3_1
2 1 Java Computational Platform

programming-language popularity website, Java is among the most popular object-


oriented languages at the time when this book is written.
Let us briefly discuss the main features of Java that make this language number
one in the industry:
• Java is multi-platform with the philosophy of “write once, run anywhere”;
• Well structured, clean, efficient, simpler (no pointers);
• Stable, robust, and well supported: Java programs written (or compiled) many
years from now can be compiled (or executed) without modifications even today.
This is true even for Java source code with graphic widgets. In contrast, C/C++
programs usually require continuous time-consuming maintenance in order to
follow up the development of C++ compilers and graphic desktop environment;
• Java has the reflection technology, which is not present in C++. The reflec-
tion allows an application to discover information about created objects, thus a
program can design itself at runtime. In particular, this is considered to be an
essential feature for building integrated development environments (IDEs);
• Java has several “intelligent” IDEs, which are indispensable tools for large soft-
ware projects. Some of them, such as Eclipse or Netbeans, are free. We probably
should note that one can also use free IDEs for C/C++, but they are not as intelli-
gent as those for Java and usually miss many important features;
• Automatic garbage collection: Having in hand this feature, a programmer does
not need to perform a low-level memory management;
• Extensive compile-time and runtime checking;
• Java always passes references to objects instead of objects themselves, therefore,
independent of how you program in Java, your code will be rather efficient;
• Java is truly multithreaded. This significantly simplifies the development of appli-
cations that should run in parallel on multi-core machines;
• Advanced serialization: Almost any Java object can be written/retrieved to/from
a file;
• Programs written in Java can be embedded to the Web. This is important for dis-
tributed analysis environment (Java WebStart, plugins, applets), especially when
data-analysis tools are not localized in one single place but scattered over the Web
(nowadays, this is the most common situation).
Sometimes, one can hear that Java is slower than C++. The subject itself is con-
troversial, since the answer totally depends on the nature and the goal of an applica-
tion. Nowadays, most people agree that after introduction of Just-in-Time compiler
(JIT), Java is as fast as C++. Probably, in some areas, Java is still slower than C++,
but the nature of such controversy is already a sign that the performance gap is now
quite small and there is no alarming difference in speed between Java and C++ pro-
grams. And anyway, the proper comparisons with C++ is usually unfair: Java does
a tremendous amount of runtime checks, such as array bound checking, thread syn-
chronization, runtime checking, garbage collection, etc., to make sure that a Java
code runs without problems, and without putting extra stress on a programmer.
Execution of a code on the JVM has a feel of “slowness” since it takes a few mil-
liseconds for the JVM to startup. But when JVM runs a bytecode code, the execution
1.1 Introduction 3

is as fast as for any other program. The JIT compilation converts Java bytecode into
native machine code at runtime. The conversion step can be slow; however, this
does not matter as much for numerical calculations involving large loops due to JIT
compilation.
One should however mention that Java uses more memory than C or FORTRAN.
The main reason—JVM does a lot of internal bookkeeping for garbage collection,
program optimization at runtime, and providing a safeguard for the Java program.
Well, it is better to assign such tasks to the JVM—people who need to use Java
will have more time to think about numeric algorithms and how to advance their
respective applied disciplines.

1.1.2 The DMelt Software Platform

Numerical and statistical calculations explained in this book use the DataMelt
(shorter, DMelt) software platform [1] that runs on the Java platform. It is a collec-
tion of libraries integrated with different programming languages. Unlike other sta-
tistical programs, it is not limited to a single programming language: DMelt can be
used with several scripting languages such as Python/Jython, Groovy, Ruby/JRuby,
as well as with Java. Generally, the DMelt computational platform extends the stan-
dard Java software platform in several areas:
• Adds a support for Jython, Groovy, JRuby, BeanShell, and GNU Octave high-
level scripting languages.
• Adds an IDE and interactive shells to work with these scripting languages and
with Java. It also adds a support to process programs in the command line (i.e., in
a batch mode).
• Adds comprehensive Java libraries for numeric computation and visualization,
incorporating free scientific packages from more than a hundred Java developers
around the world. At the moment when this book is written, DMelt includes more
than 30,000 Java classes from more than a hundred open-source Java libraries.
• DMelt includes online resources for library updates, class documentation, and for
example databases. The Web-based package descriptions are directly accessible
from the DMelt IDE. We will discuss this topic later.
Figure 1.1 illustrates the DMelt program structure. DMelt includes a support for
several scripting languages that can be run on JVM, third-party numerical libraries
integrated with IDE, and online services for update and documentation.
DMelt was designed to enable researches to spend their time thinking about
problems and their solutions, rather than diving into low-level coding using pro-
gramming languages. DMelt analysis macros for data manipulations are based on
Jython, an implementation of the high-level language Python. Thus, one can fully
benefit from a variety of programming possibilities offered by Python, including its
syntax clarity and high-level libraries. But Jython is not a prerequisite for this frame-
work: Java and other languages supported by DMelt can also be used to access the
mathematical and graphical libraries of DMelt.
4 1 Java Computational Platform

Fig. 1.1 The structure of


the DMelt program. It
includes Java-based DMelt
API, third-party numerical
libraries, DMelt IDE, and
Web services for
documentation and updates.
This plot was created using a
DMelt Jython script shown
in Listing 8.11 of Sect. 8.6.1

With time, any computational framework based on a simple-to-learn program-


ming language naturally gets large and difficult to handle; this is quite an inevitable
feature of modern life. Properly chosen computation language is essential to main-
tain simplicity of user communication with exponentially growing programs. This
is where Java comes to its power: Java virtual machine and various integrated devel-
opment environments (Eclipse, NetBeans, IntelliJ, and other IDE) can help develop
programing codes, tell about errors or mistyped classes, and in general, provide a
layer of intelligent activity between a human, who writes a code or interprets its
algorithmic logic, and a machine designed for program execution. This is rather
different from low-level languages like C/C++ or FORTRAN which are often used
for numerical calculations. For such languages, a researcher is usually on his own
with a text editor and a programming language itself which typically requires good
programming skills and several manuals on a bookshelf.
DMelt is by no means a simple framework, although it is based on Java and
high-level Python language. As mentioned before, it has tens of thousands Java
classes and methods designed for scientific computation, data analysis, and data
visualization. The DMelt library core for statistical and graphical analysis is based
on the jhplot package, which contains more than a thousand Java classes and
methods. However, you will be surprised to find how easy it is to work with this
program. Partially, this is because of Python language implemented in Java (Jython)
and, partially, because of Java itself.
DMelt [1] is a successor of the jHepWork program that has its origin in high-
energy physics in the middle of 2000. The “Hep” part of jHepWork abbreviates
“High-Energy Physics.” The jHepWork program was described in the book [2].
DMelt substantially extends jHepWork in many areas, but remains backward com-
patible with jHepWork.

1.1.3 Some Warnings

We should immediately warn you: the DMelt numerical and graphical libraries can
be considered neither as most efficient nor error-free. The code of DMelt does not
always follow the coding recommendations for Java developers including naming
1.1 Introduction 5

conventions and code layout. We even admit that some parts were not designed
with the highest possible performance for code execution in mind. The reason is
simple: it was not written by professional programmers. The numerical libraries
were written by many people at different times, most of them were students and
scientists who had to develop numerical and data visualization algorithms for their
own research programs, since commercial software companies either could not offer
similar programs or their products were too expensive. Many contributed packages
have been discontinued many years ago, but have been brought to life after their
inclusion into DMelt. In addition, some packages were written using Java 1.1, and
this had also some impact on the coding style of certain libraries.
Thus, a professional programmer may immediately find some parts of the code
that look unprofessionally written. This is true even for some examples shown in
this book. The reason for this was not because we were not aware of such coding
issues. In some cases, we did not find appealing reasons to keep very strict coding
standard at the expense of simplicity. For example, in most cases, we import all
classes inside a package using the statement:

>>> from PackageName import *

instead of importing only certain classes as

>>> from PackageName import class1,class2

We did not enforce the latter case to keep the examples of this book short and con-
cise, so we could fit the code snippets into the pages of this book. Also, it is possible
that you may not like to type long lists of imported classes during a code prototyp-
ing (personally, I do not like this style), since this can be done later during code
deployment.
A professorial programmer might find some other odds, like why some object
containers are designed to store only double values (like the P1D class to be
discussed below), while it is more practical to store integer values when necessary.
Again, the motivation was not because of omissions. The reason was that the reader
may not want to dive into extra complexity of dealing with different types, since
integers are only a subset of float values. There are plenty of other classes which are
well suited for storing integer values (we will discuss them in this book).
The main motivation for the DMelt project was to develop an accessible and
friendly tool to be used in scientific search, with a syntax oriented toward scientists
rather than programmers. The design of this project was mainly motivated by
simplicity: there are many programming languages which are required to learn for
many years before starting to write useful scientific and engineering projects. The
approach discussed in this book is very different: generally, the reader does not need
to know any programming language to start writing analysis codes using DMelt
libraries. However, if it happens that the reader knows either Java or Python (or
both) already, he or she will find this book to be also interesting, since DMelt is not
just a simplified entry to the world of the Java and Python computer programming. It
6 1 Java Computational Platform

shows how to use programming for practical purposes such as numeric calculations,
statistics, and data analysis.
The reader may also notice that a little attention has been paid to how to write and
use Java or Jython classes. Of course, classes are necessary for any object-oriented
language. The reason for this is the following: for the majority of scientific data
analysis programs, the logic of scripting programs is linear, i.e., an analysis code
typically consists of a well-defined sequence of statements to be evaluated one by
one, from the top to the bottom of the code. It is very unlikely that data analysis logic
will contain highly parallel algorithmic branches as those for the usual graphical
user interface (GUI) development.1 Certainly, the classes are necessary when one
develops Java libraries to be used by a scripting language. But, in this book, we
mainly concentrate on the scripting examples based on the existing Java libraries of
DMelt, rather than discussing how to write classes for numerical computation to be
deployed as external libraries.

1.1.4 Errors

This book may contain typos, omissions, or even errors. DMelt can also contain
bugs. If you notice any errors or if you have suggestions regarding the book and
code examples, I would be happy to hear from you. You can send your comments
to:

[email protected]

One can also post bug reports to the DMelt forum accessible from the main Web
page:

http://jwork.org/dmelt/

DMelt is not a software that stands still. Therefore, this book represents a snap-
shot of the time when the DMelt version 1.4 was in use, therefore, some examples
may fall out of date. Therefore, the reader is encouraged to look at the Web page
given above to find corrected examples.

1 We should probably say that this may not be totally true in future when multi-core machines will
be rather common and one will face with the question of how to parallelize analysis codes to gain
high performance. We briefly discuss this topic in this book.
Random documents with unrelated
content Scribd suggests to you:
fugitives now pass to their pursuers, that it would have been easy
for them to have conversed, had they been so disposed. Not a word
was spoken, however, but Mulford went by, leaving Spike about a
hundred yards astern. This was a trying moment to the latter, and
the devil tempted him to seek his revenge. He had not come
unarmed on his enterprise, but three or four loaded muskets lay in
the stern-sheets of his yawl. He looked at his men, and saw that
they could not hold out much longer to pull as they had been
pulling. Then he looked at Mulford’s boat, and saw it gliding away
from him at a rate that would shortly place it another half mile in
advance. He seized a musket, and raised it to his shoulder, nay, was
in the act of taking aim at his mate, when Rose, who watched his
movements, threw herself before Harry, and if she did not actually
save his life, at least prevented Spike’s attempt on it for that
occasion. In the course of the next ten minutes the fugitives had
again so far gained on their pursuers, that the latter began to see
that their efforts were useless. Spike muttered a few bitter curses,
and told his men to lay on their oars.
“It’s well for the runaway,” he added, “that the gal put herself
between us, else would his grog have been stopped forever. I’ve
long suspected this; but had I been sure of it, the Gulf Stream would
have had the keeping of his body, the first dark night we were in it
together. Lay on your oars, men, lay on your oars; I’m afeard the
villain will get through our fingers, a’ter all.”
The men obeyed, and then, for the first time, did they turn their
heads, to look at those they had been so vehemently pursuing. The
other boat was quite half a mile from them, and it had again tacked.
This last occurrence induced Spike to pull slowly ahead, in quest of
another short passage to cut the fugitives off; but no such opening
offered.
“There he goes about again, by George!” exclaimed Spike. “Give
way, lads—give way; an easy stroke, for if he is embayed, he can’t
escape us!”
Sure enough, poor Mulford was embayed, and could see no
outlet by which to pass ahead. He tacked his boat two or three
times, and he wore round as often; but on every side shoals or
rocks, that actually rose above the surface of the water, impeded his
course. The fact was not to be concealed; after all his efforts, and so
many promises of success, not only was his further progress ahead
cut off, but equally so was retreat. The passage was not wide
enough to admit the hope of getting by his pursuers, and the young
man came to the conclusion that his better course was to submit
with dignity to his fate. For himself he had no hope—he knew Spike’s
character too well for that; but he did not apprehend any great
immediate danger to his companions. Spike had a coarse, brutal
admiration for Rose; but her expected fortune, which was believed
to be of more amount than was actually the case, was a sort of
pledge that he would not willingly put himself in a situation that
would prevent the possibility of enjoying it. Strange, hurried, and
somewhat confused thoughts passed through Harry Mulford’s mind,
as he brailed his sail, and waited for his captors to approach and
take possession of his boat and himself. This was done quietly, and
with very few words on the part of Spike.
Mulford would have liked the appearance of things better had his
old commander cursed him, and betrayed other signs of the fury
that was boiling in his very soul. On the contrary, never had Stephen
Spike seemed more calm, or under better self-command. He smiled,
and saluted Mrs. Budd, just as if nothing unpleasant had occurred,
and alluded to the sharpness of the chase with facetiousness and
seeming good humor. The females were deceived by this manner,
and hoped, after all, that the worst that would happen would be a
return to their old position on board the Swash. This was being so
much better off than their horrible situation on the wreck, that the
change was not frightful to them.
“What has become of the schooner, Mr. Mulford?” asked Spike, as
the boats began to pass down the channel to return to the brig—two
of the Swash’s men taking their seats in that which had been
captured, along with their commander, while the other two got a tow
from the use of the sail. “I see you have the boat here that we used
alongside of her, and suppose you know something of the craft
itself.”
“She capsized with us in a squall,” answered the mate, “and we
only left the wreck this morning.”
“Capsized!—hum—that was a hard fate, to be sure, and denotes
bad seamanship. Now I’ve sailed all sorts of craft these forty years,
or five-and-thirty at least, and never capsized any thing in my life.
Stand by there for’ard to hold on by that rock.”
A solitary cap of the coral rose above the water two or three feet,
close to the channel, and was the rock to which Spike alluded. It
was only some fifty feet in diameter, and of an oval form, rising quite
above the ordinary tides, as was apparent by its appearance. It is
scarcely necessary to say it had no other fresh water than that which
occasionally fell on its surface, which surface being quite smooth,
retained very little of the rain it received. The boat was soon
alongside of this rock, where it was held broadside-to by the two
seamen.
“Mr. Mulford, do me the favor to step up here,” said Spike,
leading the way on to the rock himself. “I have a word to say to you
before we get on board the old Molly once more.”
Mulford silently complied, fully expecting that Spike intended to
blow his brains out, and willing the bloody deed should be done in a
way to be as little shocking to Rose as circumstances would allow.
But Spike manifested no such intention. A more refined cruelty was
uppermost in his mind; and his revenge was calculated, and took
care to fortify itself with some of the quibbles and artifices of the
law. He might not be exactly right in his legal reservations, but he
did not the less rely on their virtue.
“Hark’e, Mr. Mulford,” said Spike, sharply, as soon as both were
on the rock, “you have run from my brig, thereby showing your
distaste for her; and I’ve no disposition to keep a man who wishes
to quit me. Here you are, sir, on terrum firm, as the scholars call it;
and here you have my full permission to remain. I wish you a good
morning, sir; and will not fail to report, when we get in, that you left
the brig of your own pleasure.”
“You will not have the cruelty to abandon me on this naked rock,
Captain Spike, and that without a morsel of food, or a drop of
water.”
“Wather is a blessed thing!” exclaimed Biddy. “Do not think of
lavin’ the gentleman widout wather.”
“You left me, sir, without food or water, and you can fit out your
own rock—yes, d—e, sir, you left me under fire, and that is a thing
no true-hearted man would have thought of. Stand by to make sail,
boys, and if he offer to enter the boat, pitch him out with the boat-
hooks.”
Spike was getting angry, and he entered the boat again, without
perceiving that Rose had left it. Light of foot, and resolute of spirit,
the beautiful girl, handsomer than ever perhaps, by her excited
feelings and disheveled hair, had sprung on the rock, as Spike
stepped into the boat forward, and when the latter turned round,
after loosening the sail, he found he was drifting away from the very
being who was the object of all his efforts. Mulford, believing that
Rose was to be abandoned as well as himself, received the noble girl
in his arms, though ready to implore Spike, on his knees, to return
and at least take her off. But Spike wanted no solicitation on that
point. He returned of his own accord, and had just reached the rock
again when the report of a gun drew all eyes toward the brig.
The Swash had again run out of the passage, and was beating
up, close to the reef as she dared to go, with a signal flying. All the
seamen at once understood the cause of this hint. The strange sail
was getting too near, and everybody could see that it was the sloop-
of-war. Spike looked at Rose, a moment, in doubt. But Mulford raised
his beloved in his arms, and carried her to the side of the rock,
stepping on board the boat.
Spike watched the movements of the young man with jealous
vigilance, and no sooner was Rose placed on her seat, than he
motioned significantly to the mate to quit the boat.
“I cannot and will not voluntarily, Capt. Spike,” answered Harry,
calmly. “It would be committing a sort of suicide.”
A sign brought two of the men to the captain’s assistance. While
the latter held Rose in her place, the sailors shoved Harry on the
rock again. Had Mulford been disposed to resist, these two men
could not very easily have ejected him from the boat, if they could
have done it at all, but he knew there were others in reserve, and
feared that blood might be shed, in the irritated state of Spike, in
the presence of Rose. While, therefore, he would not be accessory
to his own destruction, he would not engage in what he knew would
prove not only a most harassing, but a bootless resistance. The
consequence was that the boats proceeded, leaving him alone on
the rock.
It was perhaps fortunate for Rose that she fainted. Her condition
occupied her aunt and Biddy, and Spike was enabled to reach his
brig without any further interruption. Rose was taken on board still
nearly insensible, while her two female companions were so much
confused and distressed, that neither could have given a reasonably
clear account of what had just occurred. Not so with Jack Tier,
however. That singular being noted all that passed, seated in the
eyes of the boat, away from the confusion that prevailed in its stern-
sheets, and apparently undisturbed by it.
As the party was sailing back toward the brig, the light-house
boat towing the Swash’s yawl, Jack took as good an observation of
the channels of that part of the reef as his low position would allow.
He tried to form in his mind a sort of chart of the spot, for, from the
instant Mulford was thus deserted, the little fellow had formed a
stern resolution to attempt his rescue. How that was to be done,
however, was more than he yet knew; and when they reached the
brig’s side, Tier may be said to have been filled with good intentions,
rather than with any very available knowledge to enable him to put
them in execution.
As respects the two vessels, the arrival of Spike on board his own
was not a moment too soon. The Poughkeepsie, for the stranger to
the northward was now ascertained to be that sloop-of-war, was
within long gun-shot by this time, and near enough to make certain,
by means of her glasses, of the character of the craft with which she
was closing. Luckily for the brig she lay in the channel so often
mentioned, and through which both she and her present pursuer
had so lately come, on their way to the northward. This brought her
to windward, as the wind then stood, with a clear passage before
her. Not a moment was lost. No sooner were the females sent below,
than sail was made on the brig, and she began to beat through the
passage, making long legs and short ones. She was chased, as a
matter of course, and that hard, the difference in sailing between
the two crafts not being sufficiently great to render the brigantine’s
escape by any means certain, while absolutely within the range of
those terrible missiles that were used by the man-of-war’s men.
But Spike soon determined not to leave a point so delicate as
that of his own and his vessel’s security to be decided by a mere
superiority in the way of heels. The Florida Reef, with all its dangers,
windings, and rocks, was as well known to him as the entrances to
the port of New York. In addition to its larger channels, of which
there are three or four, through which ships of size can pass, it had
many others that would admit only vessels of a lighter draught of
water. The brig was not flying light, it is true, but she was merely in
good ballast trim, and passages would be available to her, into which
the Poughkeepsie would not dare to venture. One of these lesser
channels was favorably placed to further the escape of Spike, and he
shoved the brig into it after the struggle had lasted less than an
hour. This passage offered a shorter cut to the south side of the reef
than the main channel, and the sloop-of-war, doubtless perceiving
the uselessness of pursuit, under such circumstances, wore round on
her heel, and came down through the main channel again, just
entering the open water, near the spot where the schooner had
sunk, as the sun was setting.
[To be continued.
CAROLAN’S PROPHECY.
———
BY WILLIAM H. C. HOSMER.
———

(INSCRIBED TO SAMUEL LOVER, ESQ.)

The castle hall is lighted—


Its roof with music rings,
For Carolan is sweeping
The clairsheck’s quivering strings;
And, catching inspiration
From faces fair around,
His voice is richer far than gush
Of instrumental sound.

Of Erin’s banner, green and bright,


Of Tara’s mighty kings,
Who never to invader knelt,
Exultingly he sings;
And on the glittering sands that edge
The blue and bellowing main,
Beneath the blade of Bryan falls
The yellow-bearded Dane.
The master touches other chords—
His brow is overcast—
And tears, from his old, withered orbs,
Are falling warm and fast:
In soul he looks on Athunrée,
Disastrous field of gore!
The glory of O’Conner’s house
Expires to wake no more.

As died, in mournful echoings,


The wond’rous strain away,
Approving smile and word requite
The minstrel for his lay;
And by the hand of high-born maid
The golden cup was filled,
Commotion in a heart to hush
By grief too wildly thrilled.

When tuned to lighter airs of love


His harp of magic tone,
Quoth Carolan—“What bard will not
The sway of Beauty own?
Kind hostess! I will now compose
A planxty, promised long,
In honor of thy daughter fair,
Oh! matchless theme for song!”

A few preluding notes he woke,


So clear and passing sweet,
That, timing to the melody,
The heart of listener beat;
But when the white-haired bard began
His tributary lay,
The Soul of Music from the strings
Wild Discord drove away.
Thrice, with the same result, his hand
Upon the chords he laid—
He turned the keys, but harsher sound
The trembling clairsheck made:
In honor of the mother, then,
A planxty he composed,
And perfect was the harmony
Until the strain was closed.

Then other ladies urged the bard


To celebrate their charms,
But he replied—“No rapture now
My fainting spirit warms;
By shadows from another world
My soul is clouded o’er—
Oh! would that I might never see
The light of morning more!”

“What gives a paleness to thy cheek,


Meet only for the dead—
What sorrow weighs upon thy heart?”
His noble hostess said:
The minstrel whispered in reply—
“The daughter of thy heart,
Before the flowers of summer-time
Are faded, will depart.”

Ere morning dawned, old Carolan


Went sadly on his way;
To bid green Erin’s Flower farewell
He could not, would not stay;
But sought, ere vanished many days,
That lordly hall again,
And through its gateway, moving slow,
Defiled a funeral train.
NOTE.
It is related of Carolan, Twalogh, the Irish Handel, that in his
gayest mood he could not compose a planxty on a Miss Brett, the
daughter of a noble house in the county of Sligo.
One day, after a vain attempt to compose something in honor of
the young lady, in a mixture of rage and grief he threw his clairsheck
aside, and, addressing her mother in Irish, whispered—“Madam, I
have often, from my great respect to your family, attempted a
planxty to celebrate your daughter’s perfections, but to no purpose.
Some evil genius hovers over me, there is not a string in my
discordant harp that does not vibrate a melancholy sound—I fear
she is not long for this world.” Tradition says that the event verified
the prediction. See Sketch of Carolan in the Edinburgh Encyclopedia.
THE LOVE-CHASE.
A TRUE STORY.

———
BY MRS. CAROLINE H. BUTLER.
———
CHAPTER I.
“Each ambushed Cupid I’ll defy—
In cheek, or chin, or brow!”

Exclaimed Auburn, at the same time casting an admiring glance


upon his easel, where a young and lovely face peeped forth from the
canvas with such a roguish, bewitching look, as seemed to laugh to
scorn the bold defiance of the young painter.
“No! painting shall be my mistress,” he continued, “my pallet and
brush my defence against the witcheries of the fair; for me there is
no peril in a lady’s eyes; my heart is an impregnable castle—no
admittance there, fair lady.”
“Most wisely and heroically said!” exclaimed a young girl, who
had stood for some moments at the elbow of the artist unobserved,
now suddenly bursting into a merry laugh, and placing herself before
him. “Bravo, Harry, you are, indeed, a hero!”
“Pshaw! Kate, who would have thought you so near!” cried
Auburn, reddening with vexation.
“Alas! coz, my heart already aches for those unhappy damsels
who will be sueing for admittance at that impregnable castle of
yours,” continued the young girl, with mock gravity.
“Have mercy, do—you have overheard my nonsense, now pray
spare me; for, after all, Kate, if I should ever fall off from my
allegiance, here is the face would tempt me,” pointing as he spoke to
the easel.
“Indeed! what a vain fellow you are, Harry. I suppose you think I
should make a humble courtesy for this concession in my favor. It is
well you leave the city to-morrow, or I should be tempted to set my
cap at you, and boldly revenge the sex. I don’t think,” she added,
archly, “I should find the castle invincible.”
“You are a dear girl, Kate, I know that,” answered Auburn; “but
come, take your seat at once—you have just the expression now I
have so often tried to catch, to make your picture perfect. There—
don’t move—no more raillery for at least five minutes—so shut your
mouth.”
For five minutes, then, the work went rapidly on, when, springing
triumphantly from his chair, Auburn exclaimed,
“There, coz, it is done! not a feature but is perfect. Come, judge
for yourself, if it is not to the life.”
Kate admitted the correctness of her cousin’s pencil, and then
added,
“You had best unsay that rash oath of yours, however; for I have
come to summon you to tea this evening, where you will meet one
whose slightest glance will subdue at once your boasted intrepidity.”
“I have no fears, Kate, yet must decline; as I have already
several engagements on hand for the evening.”
“Better own that, coward-like, you shun the encounter—and well
you may; for, ah, Harry, such a charming girl!”
“Who is she?—have I ever seen her?”
“Seen her! and yet ask that question. Why you cool, self-satisfied
fellow! Think you, you could have asserted such heresy as just now
fell from your lips had you ever met my lovely friend?”
“But you have not yet told me the name of your paragon.”
“No—nor shall I, in revenge for your obstinacy. But here I sit
chatting with you when ma’ma is waiting for me at home. I suppose,
my dainty cousin, you will condescend to be my escort.”
“And esteem myself most fortunate, I assure you, to enjoy that
privilege.”
Arm in arm, therefore, they then proceeded to the street, and
were soon immerged with the gay, moving throng up Broadway.
Leaving Kate at the door of her father’s residence, in the upper
part of the city, Auburn turned and strolled leisurely down this great
thoroughfare of fashion. And no small ordeal is it for a bachelor, let
him be even as inexorable to all the fascinations of beauty as Auburn
has declared himself to be—no small thing is it to pass unscathed
along this rendezvous of fair foes. It was really provoking, however,
to see with what an air of nonchalance he suffered many a graceful,
lovely form to flit by him; and sweet young faces, which ought to
have set his heart beating, and eyes which should have dazzled by
their brilliancy; to see their claims to admiration so stubbornly
unrecognized would have tried the patience of any reasonable man.
Absorbed in his own reflections, Auburn proceeded slowly en
route down Broadway, until attracted by some gem of art displayed
at the window of Colman, he stopped for some moments to admire
it, with several other loungers like himself. Turning suddenly to
pursue his walk, he found himself very awkwardly vis-à-vis two
young ladies. He stepped quickly on one side to allow of their
passing—most provokingly, they did the same, and in the same
direction; with a half-uttered apology, and in much confusion,
Auburn again attempted to give them the pave; but now, hemmed in
by the crowd, egress either way seemed impossible; and thus the
three, so awkwardly drawn together, remained very foolishly, (I
speak only for the artist,) looking at each other. There was a spice of
mischief, too, mingling with the half-repressed smiles of the young
girls, which only added to his embarrassment. In a moment,
however, the multitude passed on, and with another glance at our
plainly perplexed hero, they did the same.
But not from the mind of Auburn did they thus easily glide away.
Why throbs his heart thus tumultuously? What sends the sudden
thrill through his frame? Those persons less charitable than
ourselves, considerate reader, might deem the impregnable fortress
of the valiant artist already undermined by Cupid’s random shot.
“Heavens, what divine eyes!” suddenly occurred to Auburn, as
very slowly he passed on his way.
“What a lovely mouth—how much expression!” and his step
became still slower and slower.
“Fancy never formed aught half so lovely!” Here he paused,
undeterminate; then exclaiming almost audibly, “I must see her
again, I must know who it is whose breathing charms so far excel
even the painter’s art.” He suddenly turned, and swiftly retraced his
steps, hoping to overtake the one fair enslaver; for so decisive had
been the attraction of the taller of the two girls, that the other, had
she been fair as Venus, or even ugly as Hecate, the result would
have been the same.
On, on rushes the busy throng—a ceaseless tide of human hopes
and worldly ambition, cares and disappointments; and on, on
presses Auburn. At length he catches a glimpse of that charming
figure; not for an instant does he doubt its identity—so on, on he
presses, while nearer, still nearer to his eager vision floats the white
robe of the pursued. Small respect has he for persons, as he elbows
his way through the crowd. Bravo! his aim is now accomplished, and
close behind the unconscious maidens he follows in their dainty
footsteps. Trinity was open, and into its holy aisles the young girls
passed, nor did our hero hesitate to follow. Choosing a seat which
commanded a view of the pew into which they had entered, he
remained unobserved, gazing upon the object of his sudden passion.
She was beautiful, at least in his eyes, and evidently young. Her
dress, more marked for its uniform simplicity than fashionable
display, while her manner, at once so earnest and sincere during the
sacred rites, might well rebuke the inappropriate thoughts of Auburn
within that holy pile, who, in short, during those few brief moments,
quaffed deeply of love’s soul-entrancing draught.
The services over, the two girls left the church, still followed by
Auburn. A thousand rash resolves floated through his dizzy brain. He
would address them; he would even boldly declare the interest
awakened; he would demand in return the name of the fair one. O,
that some lucky chance, or mischance, might call forth the offer of
his services. Why might they not be terrified by the cry of “mad
dog,” or nearly run over by some careless cab-man; any thing, in
fact, short of absolute death, so that he might attract their notice.
But, to his great chagrin, nothing of this kind seemed likely to
happen. Like two beautiful swans, side by side, gracefully glided the
fair ones along, until reaching the corner of a fashionable street,
they turned down. Auburn was about to do the same, his heart
leaping at the thought of discovering at least the residence of his fair
enslaver, when his arm was suddenly seized, and a good-humored
voice exclaimed,
“Ha! my dear fellow, I am glad to meet you! I have been looking
all over town for you; but whither so fast? Stop, I want to say a
word to you.”
“Not just now, Evans—I—I—the fact is I am engaged—I—”
“Engaged!—how?—where?” continued his friend, holding on
perseveringly to his arm. “Come, I want you to go with me; but
what are you looking at—who do you see?” following the direction of
Auburn’s eyes eagerly straining down C—— street.
“No one,” answered Auburn, in a tone of vexation; for, alas! in
that very moment, when his attention had been unavoidably given to
his friend, the fair vision had disappeared, and, like a vision, “left not
a rack behind.”

——
CHAPTER II.
From the pave we will now step into a spacious drawing-room.
A lively Italian air, exquisitely sung by a fair young girl, falls with
delightful cadence upon the ear, while touched by the fingers of one
scarcely less fair, the piano adds its pleasing accompaniment, filling
the lofty apartment with thrilling melody. Seated in a comfortable
lolling chair, is a gentleman of middle age—the only listener, by the
by, to the charming music of his niece and daughter, yet more than
compensating by his true love of the “art divine,” and the heartiness
of his approval, for the superficial plaudits of a fashionable assembly.
This is evidently the dwelling of a man of fortune and of taste.
Elegance without ostentation mark its adornments. A choice
collection of paintings from the old masters decorate the walls, and
scattered around are various specimens of rare artistic skill and
beauty.
The song ended, a lively conversation ensued.
“So I find, Margaret, you have been gadding as usual this
morning,” said Mr. Belden, “and filling your cousin’s little head with
more folly and nonsense than her good mother can eradicate in a
twelve-month.”
“O, no, papa, I have done nothing of the kind, I assure you; and
yet I should not like to be answerable for all the mischief done that
little head and heart, too, to-day,” answered Margaret, looking archly
at her cousin. “See how she blushes. Now confess, Emma, the
image of a certain person, who so awkwardly beset us this morning,
still haunts your fancy.”
“Well, Margaret, I do confess,” replied Emma, while a crimson
glow mantled her cheeks, “that I think he possessed one of the
finest faces I ever saw. He was not more awkward, certainly, than
we were; and I much doubt whether, in fact, we were not the most
so of the three.”
“Speak for yourself, if you please,” was the reply; “for my part, I
never enjoyed any thing more. Such sideling and bowing; such
blushing, and such bobbing about; why a dancing-master might
make a fortune out of this new pas de trois. And as for you, Emma,
you really looked like a little simpleton.”
“What is all this, girls—what new adventure have you met with?”
inquired Mr. Belden.
“Only one of those awkward rencounters, papa, which happen
every day, except, perhaps, that one seldom sees a handsomer
young man than the poor fellow who came so near running us
down. Tall and erect, eyes like stars, brows black as night, and, but
for his awkwardness, a very—but, mercy, Emma, look, look—there
he is—yes, it certainly is,” she suddenly exclaimed; “do come here,
quick. See, he is evidently looking for some number. Now he is at
87; there, he stops at 91—no that is not it; see how he gazes this
way. As I live, the fellow is crossing over! Why the audacious—he
bows. Emma, Emma, he is coming up the steps!” and even as she
spoke there was a ring at the door. The girls quickly disappeared,
and the next moment Auburn was ushered into the presence of the
astonished Mr. Belden; doubtless no less astonished himself at his
position and daring errand.
Daring, indeed—but what will not love dare!
After so suddenly losing sight of his inamorata, without the
shadow of a hope that he might ever again behold her, Auburn
turned, and gloomily accompanied his friend Evans to his lodgings,
wishing, nevertheless, that he had been many fathoms deep, ere he
had thus inopportunely encountered him. His unusual taciturnity
drew forth the raillery of his friend. Auburn vainly endeavored to
shake off this depression; but the very effort only caused him to talk
the more wildly, then plunged him again into the same moody
silence. Evans jested the more, until finally, already in no very
amiable frame of mind, he became provoked; high words ensued,
and the two friends parted in anger.
“Alas! how light a cause may move
Dissension between hearts that love.”

Auburn now took refuge in his studio, vainly striving to forget his
chagrin in his late all-engrossing pleasure—painting—the mistress to
whom but that morning he had sworn eternal fealty. At length
throwing down the brush in despair, he exclaimed,
“Heavens, how that face haunts me! And must I leave the city to-
morrow, and thus lose the only chance I may ever have of meeting
her again. No, I cannot do it! and yet what folly,” he added, “why
should I allow such a trifle to disturb me thus? Even should I
discover who she is, what good can result to me!” And now the poor
artist paced the room despairingly; again he soliloquized:
“Yes, I will postpone my journey. I will haunt Broadway, Trinity,
the Opera, theatres—I will neither eat nor sleep until I have found
her.”
At this moment his eye rested upon the roguish face of his cousin
Kate, still upon his easel; and the conversation of the morning at
once flashed upon him.
“Pshaw!” he exclaimed, “it can’t be—I can’t be such a simpleton
as to have fallen in love! Pooh! no, no—it can’t be. Love! ha! ha! ha!
ridiculous!—in love! No, Miss Kate, all right yet. Let me shake off this
idle mood. Love!—nonsense!” and seizing his pallet, he first,
somewhat spitefully, removed the provoking portrait from its
position, and then commenced copying a beautiful head of Titian.
But in vain he toiled. It was soon evident he had forgotten his
subject; his head drooped upon his breast; his brush motionless, and
for many moments he remained buried in deep thought. Suddenly
starting up with such vehemence as nearly to overturn the easel, he
seized his hat and rushed from the room, plunged down stairs, and
into the street. Up Broadway he once more pushed along, nor
paused until C—— street was attained. Here, for a moment, he
halted, irresolute, then turning the corner, commenced a deliberate
survey of every house, and gazing most pertinaciously at the
windows in particular, careless of the attention which his peculiar
manner attracted. When, then, he really caught a glimpse of the
object of his search peeping through the rich hangings at the
window of Mr. Belden, it is no wonder his senses forsook him, and
that without a moment’s consideration, he impulsively rushed up the
steps, rang the bell, and found himself, as has already been shown,
in the presence of that gentleman.
One rapid glance around the room betrayed the fair object of his
search had disappeared. Then the awkwardness of his position
dawned faintly through the maze in which his wits were wandering.
But it was too late to retreat, so summoning courage to address Mr.
Belden, he inquired,
“Can I have the pleasure of speaking with Miss—Miss—your
daughter, sir?”
A frown gathered dark on the brow of Mr. Belden, as he replied,
“Who are you, sir?—and what is your business with Miss Belden,
may I ask?”
“Here is my card,” answered Auburn. “I am aware my presence
here may appear somewhat singular, yet as I leave town early to-
morrow, I must urge a few moments conversation with that young
lady.”
“Your boldness, sir, is unsurpassed. Miss Belden cannot have the
honor of seeing you.”
The reply of Auburn was interrupted by the sudden appearance
of that young lady, whom, we must frankly confess, had, with
Emma, been playing the part of eaves-dropper, and fearing her
father would really drive the rash youth away without an interview,
which her love of mischief tempted her to grant. She broke from the
entreaties of her cousin, and stepped quietly into the room.
“Ah, here is my daughter,” added Mr. Belden. “Now, sir, your
business—what have you to say?”
But poor Auburn had nothing to say. That Miss Belden was not
the one he sought, a glance sufficed to assure him; and Margaret,
too, most provokingly assumed a stately never-saw-you-before-sir
air, which rendered his embarrassment tenfold.
“I beg your pardon for this intrusion, Miss Belden,” said he at
length, “for which I can offer no excuse, except that I have been
laboring under a delusion,” and bowing, he was about to leave the
apartment, when, by chance, his eye fell upon a music-book, on
which the name of “Emma Willis” was inscribed. A drowning man will
catch at a straw—so will a desperate lover. Turning abruptly he now
hazarded the inquiry,
“Is Miss Willis at home?”
“Miss Willis is at home,” coldly answered Mr. Belden.
Auburn’s heart throbbed tumultuously.
“Can I see her for a moment?” he eagerly demanded.
“No, sir, you cannot!” exclaimed Mr. Belden now rising, and
angrily confronting his visiter; “and by what right, sir, do you longer
intrude upon my family? Your conduct at least warrants suspicion.
You first inquire for Miss Belden—you equivocate—you acknowledge
yourself mistaken, and then demand an interview with my niece.
Pray, what authority have you for such proceedings—you are not
acquainted with the young lady, I believe?”
“No, sir, I am not,” replied Auburn, now fully restored to his
senses, “and until to-day I acknowledge I never saw either this lady
(bowing to Miss Belden,) or Miss Willis. Again I ask pardon for my
intrusion. I know appearances are much against me; but the interest
awakened in my bosom for your lovely niece, even in those few brief
moments when it was my happiness to see her, and the fact that I
am forced to leave the city to-morrow, is all I can urge in favor of
my rashness; it was this alone which inspired me with boldness to
call here.”
“Boldness, indeed! If this is all you have to say in extenuation, I,
young sir, shall have the boldness to show you the door, and request
a speedy retreat therefrom,” cried Mr. Belden.
Forgetting in his anger that Mr. Belden had any grounds for such
uncourteous treatment, mortified, and disappointed, Auburn turned
indignantly upon his heel and left the house—a merry laugh from the
drawing-room ringing discordantly in his ear as he passed out.
——
CHAPTER III.
It was evening of the same eventful day in the history of our
hero, that a merry little circle of young girls were assembled at Kate
Kennedy’s; and to the amused group Miss Belden related the
adventures of the morning, giving to the whole scene an effect so
truly ludicrous, as elicited many a merry peal of laughter from her
joyous listeners. Even Emma Willis, though made to figure so largely
in the story, could not resist a smile at the ridiculous light in which
she was shown up by her provokingly mischievous cousin.
“And to think, after all,” cried Kate, “that this sudden conquest
has been achieved by a simple country girl—our own blushing Emma
here, who never before even lost sight of her lambs and chickens.
Why, from your grandiloquent description, Margaret, I should not
wonder if he should prove some foreign count.”
“Or a play-actor, from his tragic air,” said another.
“Or a poet,” cried a third.
“Or a fugitive from the Insane Hospital,” added a fourth.
“Or a writer of romances, stealing his characters from real life. I’ll
warrant his name to be Adolphus Gustavus Augustus Fitz—
something or other—”
“O, no,” interrupted Miss Belden, “his name is a thousand times
prettier than any of your Sts. and Fitz.—it is Auburn—Henry C.
Auburn.”
“Henry C. Auburn!” screamed Kate. “Say that again, Margaret!
Henry C. Auburn!—delightful!” and bursting into a fit of
uncontrollable laughter, the little gypsy clapped her hands, and
danced about the room apparently in an ecstasy of delight. The next
moment she vanished from the room, and hastily dispatched the
following note to the lodgings of Auburn.

“Dear Cousin Harry—


“One so imperturbable to all the blandishments of
beauty; one who has sworn fealty to pencil and pallet, and
jests at all the powers of Cupid, can surely fear no danger
in coming hither this evening, even though to meet the
charming friend of whom I told you this morning. I
therefore once more entreat, nay, I command your
presence, though at the eleventh hour. I will only hint that
if you come you may not leave town to-morrow. In haste,
“Kate.”

Auburn received the note, but, ingrate that he was to his pretty
cousin, and feeling in no amiable mood of mind, he returned this
brief reply.

“Dear Kate—
“I cannot come—I told you so. Don’t annoy me any
more about your ‘charming friend.’ I hate all women but
you! Kate, I go to-morrow.
“Harry.”

He remained that night until a late hour writing and arranging his
things for his departure. Then bidding the servant call him at an
early hour in the morning, he threw himself upon the bed—but not
to sleep.
What the fair vision continually flitting through his brain and
repelling the powers of the drowsy god, needs not be told.

——
CHAPTER IV.
Summer has come with its fruits and flowers; and away from the
dust and turmoil of the city, our story takes us to a beautiful village
overlooking the bright waters of the Cayuga Lake.
It is evening. The laborers are returning from their daily toil,
some with their cradles and scythes thrown over their lusty
shoulders, others, sunk amid the fresh and fragrant new-mown hay,
are driving their teams homeward. From every branch the birds are
gayly singing; cheerful sounds greet the ear from the farm-yard, and
sweet on the gentle evening air floats the fragrance of the countless
blossoms which adorn the neat garden-plots, and climb around the
windows of the villagers.
Seated in the piazza of the comfortable inn is a traveler, who but
a half hour since alighted from the stage, and made known his
intention of spending some weeks in the village; consequently, the
best room in the house is at his service, as also the best bows of
Boniface and his attendants.
One glance will suffice us to recognize in the stranger our young
artist, yet at the second we shall wonder what can have wrought so
great a change in the outward man; why that happy, joyous air is
exchanged for one so grave and even gloomy; why that fresh and
blooming countenance is now so wan and haggard!
O, this love—this love!
Either absorbed in the beauty of the scene around him, or in his
own moody thoughts, most probably the latter, the moments passed
unheeded away, nor until aroused by his host with the
announcement of supper, did he once move from his half-recumbent
position. After slightly partaking of this repast, to the evident
discomfiture of the good landlady, who attributed the dainty appetite
of her guest, to nothing less than a dislike for her excellent fare,
Auburn strolled forth from the inn, and proceeded slowly along the
now almost deserted street.
The moon had by this time risen, casting her mild radiance over
the peaceful village, and silvering the bosom of the placid lake
below, while many a gambol did the shadows play upon the dewy
green-sward, and upon the house-tops, as the leaves of the large
elms flittered and danced in the soft evening breeze.
Suddenly a strain of delicious music broke the stillness. It
aroused Auburn from his revery; he paused, and found himself near
a small cottage, standing at some little distance from the street, the
peculiar beauty of which at once attracted him. An avenue of horse-
chestnuts and other ornamental trees led up to the entrance, while
for some distance the road and enclosures were lined with the tall,
silvery poplar. Clusters of beautiful flowers nodded their fragrant
heads in the moonlight, while the soothing murmur of a brook
winding through a grove of willows, shadowing one end of the
cottage, fell pleasantly upon the ear.
Still the music floated around him—now pensive, now gay. Well
known airs brought back the memory of other scenes; one voice,
too, was strangely familiar—he could almost fancy he was listening,
as of old, to the sweet notes of his cousin, Kate Kennedy.
The music ceased, yet still Auburn lingered. Two ladies,
accompanied by a gentleman, now appear in the piazza which
encircles the cottage. Arm in arm they saunter down the walk,
talking and laughing gayly. When near the gate, they pause for a
moment; an affectionate good-night is interchanged—one lady
returns slowly to the house, while the other two persons continuing
their walk are in a moment close to Auburn.
“Harry!”
“Kate!” were simultaneous exclamations, and the next instant the
cousins affectionately embraced.
“My husband, Harry,” said Kate, disengaging herself; and to add
to the surprise of our hero, his friend Evans claimed that happy
privilege—and a warm, cordial greeting was exchanged.
“How singular we should have thus met! I must have had some
prescience there was pleasure in store for me!” exclaimed Auburn.
“This half hour, dear Kate, have I been listening to the songs you
used to sing me, with a strange conviction that it was your voice I
heard.”
“But you surely must have known of my intended marriage,
Harry?” said Kate. “And that reminds me that you never even
answered my letter inviting you to the ceremony; and here is
George, too, who also wrote, requesting you to act upon the
interesting occasion conjointly with my dear friend—but I forget—
you do not like to hear about her—the more your loss. Say, why did
you not answer?”
“Simply because I never received your letter. The fact is, I have
been a rover since I left the city—to no place ‘constant ever.’ How
long have you been here?” continued Auburn—“I trust I have not
arrived just as you are about leaving?”
“Oh, no, we have been here but a few days, on a visit to
George’s parents. That same annoying friend of mine also dwells
here, and possibly we may remain to attend her wedding—but what
brought you here?”
“Partly pleasure—partly the hope of profit. You both know my
ardent desire to visit Italy, and the small means I possess to carry
my wishes into effect. Apart from my own desire to improve the
superior facilities which the old world affords, you are aware that in
this country it is rarely an artist arrives to eminence, or even a
reputation above the medium, unless he has first sunned himself
beneath the vine-clad hills of Italy—a foreign stamp is needed ere he
can pass current with the multitude. To Italy, then, must I go, ere I
can realize my ambitious hopes. By leading a sort of strolling life, for
a season, roaming from village to village, in the exercise of my
profession, I hope to raise a sufficient sum for the undertaking.”
“I have no doubt of your success,” said Evans. “Indeed in this
place there are several wealthy families who would doubtless be
glad of an opportunity to transmit themselves to posterity through
your fadeless tints.”
“I should not wonder, George,” said Kate, “if Emma —”
“Emma!” exclaimed Auburn.
“Yes, Emma—why, what is the matter with you—one would think
I had uttered some charm. I was going to say perhaps Emma might
sit for her portrait—her lover would like it, I dare say.”
At the word lover, the heart of Auburn, just now in his mouth,
sunk like lead—and yet he knew not why.
“Do you think,” added Kate, “you could portray

‘That loveliness, ever in motion, which plays


Like the light upon Autumn’s soft shadowy days,
Now here and now there, giving warmth as it flies
From the lips to the cheek—from the cheek to the
eyes;’

but excuse me again—I always forget myself when speaking of


Emma Willis.”
“Emma Willis!” cried Auburn. “Kate, who are you talking of—good
heavens, you don’t say that—”
“Say what!” interrupted Kate. “What ails the man? All I said was,
that, as I have told you a thousand times, Emma Willis is a charming
girl; and I hope to attend her wedding ere I leave the village—but
here we are at home—good-night, we shall see you to-morrow”—
and breaking from Auburn, who vainly endeavored to detain her, the
mischievous girl ran into the house, followed by Evans, who also
seemed in an unaccountable hurry to get away from his friend—and
such a laugh as came wafted to poor Harry’s ears and was too much
for any Christian to bear.

——
CHAPTER V.
Did Auburn sleep that night? “To sleep—perchance to dream—ay,
there’s the rub”—for dream he did, when at length worn out with
fatigue and a mind ill at ease, he sought his pillow. None but lovers
were ever tormented with such fancies as that night haunted the
half crazed brain of the artist. At one moment he was again walking
Broadway, and gliding before him the sylph-like form of Emma—then
within the holy walls of Trinity he listens to the solemn rites of
marriage, but, O distraction! in the fair bride he discovers Emma—
while beneath the reverend wig of the officiating priest, the roguish,
wicked face of Kate Kennedy peeps out upon him—then the scene
changes, and through the most beautiful groves he is wandering
with Emma by moonlight—when suddenly the enraged Mr. Belden
starts up before him and tears her from his arms! But Auburn
awakes and finds only his friend Evans standing by his bedside, and
the bright sunshine flickering through the sweet-briar at his window.
Up with the birds, and singing as gayly, too, was Kate, and long
ere the sun had parted the rosy curtains of the eastern sky, she was
lightly tripping o’er the dew-begemmed grass toward the cottage
where dwelt her friend. To enter the little gate, to spring with the
lightness of a fawn up the walk, scattering the bright tinkling drops
from the overhanging branches of the trees upon the flowers
nestling below, to softly open the door, and through the hall, and up
the stairs to the little chamber of Emma, arousing her from her
gentle slumbers with a soft kiss upon her rosy lips, was but the work
of a moment.
“Why, Kate, what has brought you here thus early, sweet bird?”
cried Emma, raising herself from the pillow, and drawing down the
sweet mouth of Kate again toward her.
“Come, my lady fair, up, up, and don your robes quickly,” was the
reply—“We have a delightful plan in our heads—that is George and I
—and you are to breakfast with us, George says, as also another
person, so that no time may be lost—come, haste thee, haste.”
“But where are we going?” cried Emma, springing quickly from
her couch, and removing the little muslin cap which shaded her
temples, letting escape her luxuriant raven tresses, which swept
almost to the floor.
“Oh, I have promised to be secret,” said Kate, laughing, “and
what is more for a woman—I mean to be so. Now let me play the
tire-woman,” and seizing the comb she began platting the beautiful
hair of Emma, rattling on in her usual lively strain as she did so.
“We are to have a sail on the lake, I presume—but who is the
person you spoke of as our companion?” said Emma.
“A painter and a poet—a sworn bachelor—a woman-hater—
hating you in particular—a—”
“Why, Kate, you are crazy—who do you mean?”
“Nous verrons, my dear—come, are you ready?” and throwing a
light scarf over the shoulders of her friend, away they lightly tripped.
The breakfast scene passes the powers of my pen. That Emma
Willis at once recognized in our hero the daring youth who had so
pertinaciously sought her, the vivid blush upon her cheek at once
betrayed, and that the recognition was not displeasing, the sequel
will testify. As for Auburn—no matter—suffice it to say that ere long
Emma sat to him for her portrait—not for her lover, as Kate once
maliciously hinted, but for her parents, ere they bestowed the dear
original upon our happy hero.
Kate did attend her friend’s wedding before she left the village,
and Mr. and Mrs. Henry C. Auburn are now in Italy.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like