Mathematica Data Analysis Learn and explore the fundamentals of data analysis with the power of Mathematica Sergiy Suchok BIRMINGHAM - MUMBAI Mathematica Data Analysis Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: December 2015 Production reference: 1151215 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78588-493-1 www.packtpub.com [ FM-2 ] Credits Author Project Coordinator Sergiy Suchok Dinesh Rathe Reviewer Proofreader Shivranjan P Kolvankar Safis Editing Commissioning Editor Indexer Amarabha Banerjee Rekha Nair Acquisition Editor Graphics Manish Nainani Jason Monteiro Content Development Editor Production Coordinator Sumeet Sawant Aparna Bhagat Technical Editor Cover Work Vivek Arora Aparna Bhagat Copy Editor Kausambhi Majumdar [ FM-3 ] About the Author Sergiy Suchok graduated in 2004 with honors from the Faculty of Cybernetics, Taras Shevchenko National University of Kyiv (Ukraine), and since then, he has a keen interest in information technology. He is currently working in the banking sector and has a PhD in Economics. Sergiy is the coauthor of more than 45 articles and has participated in more than 20 scientific and practical conferences devoted to economic and mathematical modeling. [ FM-4 ] About the Reviewer Shivranjan P Kolvankar is a teacher and a passionate embedded system developer. He did his masters in instrumentation science from the University of Pune in 2014. He has worked on statistical process control charts and data analysis for his masters' thesis. He has experience in working with Bluetooth low energy, embedded system development, C#.NET, VB.NET, and Android application development. Currently, he is working with Teach for India as a teacher with underprivileged and low income kids. He believes that quality education that caters to the learning ability of a child is their fundamental right. He applies a head-heart-hand strategy to teach mathematics. When he is free, he loves to play the flute and tinker with Arduino and Sensor Interfacing. [ FM-5 ] www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books. Why subscribe? • Fully searchable across every book published by Packt • Copy and paste, print, and bookmark content • On demand and accessible via a web browser Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access. [ FM-6 ] Table of Contents Preface v Chapter 1: First Steps in Data Analysis 1 System installation 1 Setting up the system 8 The Mathematica front end and kernel 10 Main features for writing expressions 11 Summary 14 Chapter 2: Broad Capabilities for Data Import 15 Permissible data format for import 15 Importing data in Mathematica 16 Additional cleaning functions and data conversion 20 Checkpoint 2.1 – time for some practice!!! 22 Importing strings 25 Importing data from Mathematica's notebooks 26 Controlling data completeness 28 Summary 33 Chapter 3: Creating an Interface for an External Program 35 Wolfram Symbolic Transfer Protocol 35 Interface implementation with a program in С/С++ 38 Calling Mathematica from C 40 Interacting with .NET programs 45 Interacting with Java 49 Interacting with R 52 Summary 54 [ i ] Table of Contents Chapter 4: Analyzing Data with the Help of Mathematica 55 Data clustering 55 Data classification 58 Image recognition 63 Recognizing faces 65 Recognizing text information 68 Recognizing barcodes 70 Summary 72 Chapter 5: Discovering the Advanced Capabilities of Time Series 73 Time series in Mathematica 74 Mathematica's information depository 77 Process models of time series 80 The moving average model 80 The autoregressive process – AR 81 The autoregression model – moving average (ARMA) 82 The seasonal integrated autoregressive moving-average process – SARIMA 83 Choosing the best time series process model 84 Tests on stationarity, invertibility, and autocorrelation 88 Checking for stationarity 88 Invertibility check 89 Autocorrelation check 89 Summary 91 Chapter 6: Statistical Hypothesis Testing in Two Clicks 93 Hypotheses about the mean 93 Hypotheses about the variance 100 Checking the degree of sample dependence 103 Hypotheses on true sample distribution 106 Summary 110 Chapter 7: Predicting the Dataset Behavior 111 Classical predicting 112 Image processing 117 Probability automaton modelling 122 Summary 124 [ ii ] Table of Contents Chapter 8: Rock-Paper-Scissors – Intelligent Processing of Datasets 125 Interface development in Mathematica 125 Markov chains 133 Creating a portable demonstration 138 Summary 140 Index 141 [ iii ]