Standing for IoP Council Elections

The Institute of Physics is holding Council Elections and I am proud to announce that I am standing for election as President-Elect. It is an honour to be standing alongside three other candidates, including one of my very own PhD supervisors… 🤣

I am standing for election because I am interested in making physics a subject that is approachable and enjoyable to all. In order to do that, being able to speak on behalf of the different sectors that make up our community is important. I am interested in contributing to the diversity and inclusion agenda of the IoP. I firmly believe that having representatives with varied backgrounds makes our community stronger. 🤛🏼

Programming First Steps: Java or Python?

I am posting this as an extended response to the quesiton that a medic friend of mine asked me the other day. The main question was whether learning Java or Python was best for getting “a basic understanding of coding (medically related)” and “which one will serve best in the future within a remit of medical apps“.

The short answers is that it depends… and my answer is not only valid for medical applications, but in general. I believe that both are very good popular programming languages. Learning the basics of programming can be done in any programming language of your choice, including both Python and Java. If the aim is to get to grips with what programming is all about even getting to learn a bit of Scratch or Blocky could be a good start. I recommend looking as well at Swift Playgrounds. They all will let you have a look at the basics of programming and will get you started in an easy way.

In this case the query is mor nuance and the answer is also “it depends”. For example are there any other people around you who are already using a particualr programming language for their medical (or any other area of knowledge) application? For example, when doing a PhD I recommend you look at what other candidates are using for their work and stick to it. The reason for this is that if you have any questions there are people around you that may be able to support you. Also you may end up working with them and programming in the same language helps. In this case, if there are a number of medics that are already getting their hands dirty with one particular programming language I’d say go for that. And notice that it does not have to be neither Java nor Python.

In short you can’t go wrong with picking one of them to start with. Once you start, you may pick up the other with less trepidation.

If you are stuck, I would probably recommend using Python, but then again I may be biased. After all, I have written a couple of books for pythonistas, ok, ok I have also written one for Matlab. That is also an excellent language although not open source. In that case take a look at Octave… but I digress.

In the rest of the post I will look at some of the similarities and differences between Python and Java in the hope this may help you decide.

Learning curve

The learning curve for Java and Python is very diffterent. I believe that Python is a much easier language to get started. However, once you have picked up the basics in any of them you can contribute to production level code quite easily. Both languages are object oriented and depending on your level of knowledge you may be able to read through a program an figure out what it is doing.

The learning curve for anything depends on what you already know, how interested you are in learning the topic, and the learning environment. For example, if you have already done some type of coding or scripting, even if it is pasting some JavaScript into a web page, you may be familiar with the code structure you will run into with a language like Java. Here is an example of Java code. Let us look at a Hello World program in Java:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
}

What about Python? Well take a look:

print("Hello, world!")

Readability is part of the philosophy of writing Python code and we can see that in the example above. In this way, if you have never programmed before, Python tends to be easier to read.

Syntax

Syntax refers to the rules that we need to follow to write correct “sentences” in the language. Java’s syntax requires a bit more effort than Python’s. Let us take a look. The following program calculates the averge of some a collection of numbers in Java

public class Average {
    public static void main(String args[]){
       int i,total;
       int a[] = {0,6,9,2,7};
       int n = 5;
       total = 0;
 ​
       for(i=0; i<n; i++) {
          total += a[i];
      }
       System.out.println("Average :"+ total/(float)n);
    }
 
  • Curly braces define the blocks of code.
  • Each statement must end in a semicolon (;)
  • Each time you create a new variable, it must have a type. When we instantiate the i and total objects we define them as int and later on casted the value of n as a float to be able to obtain a decimal number
  • Formatting and spacing is not important. Although the code above looks nice, the programme will run even if all of it were in a single line (don’t do that…)(
  • You will also notice how verbose the code is. You will usually end up typing more writing Java code than you would with Python code.

In Python we can calculate the average with something like this:

def average(a):
   avg = sum(a)/len(a)
   return avg
   
 a = [0,6,9,2,7]
 avg = average(a)
 print("Average : {0}".format(avg))
  • Line breaks and indentation define blocks of code in Python. There are no extra symbols like semicolons at the end of a line
  • Python uses a colon to start classes, methods, and loops. You see that in the definition of average
  • Whitespace is important to Python. Developers use it to define blocks of code, so the lines in the code above could not run on one line.

Executing code

A big difference between Java and Python is how both languages execute code. Java is a compiled language and this means that the code needs to be “translated” so that the machine can run it. Python is an interpreted language and this means that the code is executed line by line without the need for compilation.

If you are interested in performance, the distinction above means that Python could be a bit slower that Java, but I think that for the type of programming you may start with this does not matter all that much.

In a nutshell

If you are interested in learning more about programming, either of them should be able to get you started. There may be a number of pros and cones to each languaage and I would recommend you ask colleagues what they are using for the type os applications you are interested in. All in all it does not matter which one you chose. My recommendation is to stick with your choice and in no time you will pick up the nunances and idiosyncrasies of the language.

Statistics and Data Visualisation with Python – First Chapter Done

As you know I am writing a new book. This time it is a book about statistics and data visualisation using Python as the main language to analyse data. It was thinking that I was a bit behind with my plan for the book, but I managed to surprise myself by being bang on time completing the first chapter.

This is the introductory chapter where we cover some background on the importance of statistics, a bit of history and the personalities behind some concepts widely used in stats and data visualisation. We then cover some background in formulating questions to be answered with data and how to communicate our results.

On to the next chapter! 🐍📊📖

Advanced Data Science and Analytics with Python – Video

Hello again this is a video I recorded for my publisher about my book “Advanced Data Science and Analytics with Python”. This is a video I made for my publisher about my book “Data Science and Analytics with Python”. You can get the book here and more about the book here.

This companion to “Data Science and Analytics with Python” is the result of arguments with myself about writing something to cover a few of the areas that were not included in that first volume, largely due to space/time constraints. Like the previous book, this one exists thanks to the discussions, stand-ups, brainstorms and eventual implementations of algorithms and data science projects carried out with many colleagues and friends.

As the title suggests, this book continues to use Python as a tool to train, test and implement machine learning models and algorithms. The book is aimed at data scientists who would like to continue developing their skills and apply them in business and academic settings.

The subjects discussed in this book are complementary and a follow-up to the ones covered in Volume 1. The intended audience for this book is still composed of data analysts and early-career data scientists with some experience in programming and with a background in statistical modelling. In this case, however, the expectation is that they have already covered some areas of machine learning and data analytics. The subjects discussed in this book are complementary and a follow-up to the topics discussed in “Data Science and Analytics with Python”. Although there are some references to the previous book, this volume is written to be read independently.

I have tried to keep the same tone as in the first book, peppering the pages with some bits and bobs of popular culture, science fiction and indeed Monty Python puns. The aim is still to focus on showing the concepts and ideas behind popular algorithms and their use.

In summary, “Advanced Data Science and Analytics with Python” presents each of the topics addressed in the book tackles the data science workflow from a practical perspective, concentrating on the process and results obtained. The material covered includes machine learning and pattern recognition algorithms including: Time series analysis, natural language processing, topic modelling, social network analysis, neural networks and deep learning. The book discusses the need to develop data products and addresses the subject of bringing models to their intended audiences – in this case, literally to the users’ fingertips in the form of an iPhone app.

I hope you enjoy it and if you want to know more about my other books, please check the related videos here:

Meet the Newest Member of the Fluorescent Mammal Club

www.nytimes.com/2021/02/18/science/fluorescent-mammal-springhare.html

Meet the Newest Member of the Fluorescent Mammal Club The springhare — whose coat glows a patchy pinkish-orange under UV light — joins the platypus and other mammals with this perplexing trait

Relates post Fluorescent Platypuses (??) and A Question Hidden in the Platypus Genome: Are We the Weird Ones? – The New York Times

Data Science and Analytics with Python – Video

This is a video I made for my publisher about my book “Data Science and Analytics with Python”. You can get the book here and more about the book here.

The book provides an introduction to some of the most used algorithms in data science and analytics. This book is the result of very interesting discussions, debates and dialogues with a large number of people at various levels of seniority, working at startups as well as long-established businesses, and in a variety of industries, from science to media to finance.

“Data Science and Analytics with Python” is intended to be a companion to data analysts and budding data scientists that have some working experience with both programming and statistical modelling, but who have not necessarily delved into the wonders of data analytics and machine learning. The book uses Python as a tool to implement and exploit some of the most common algorithms used in data science and data analytics today.

Python is a popular and versatile scripting and object-oriented language, it is easy to use and has a large active community of developers and enthusiasts, not to mention the richness oall of this helped by the versatility of the iPython/Jupyter Notebook.

In the book I address the balance between the knowledge required by a data scientist sucha as mathematics and computer science, with the need for a good business background. To tackle the prevailing image of a unicorn data scientist, I am convinced that the use of a new symbol is needed. And a silly one at that! There is an allegory I usually propose to colleagues and those that talk about the data science Unicorn. It seems to me to be a more appropriate one than the existing image: It is still another mythical creature, less common perhaps than the unicorn, but more importantly with some faint fact about its actual existence: a Jackalope. You will have to read the book to find out more!

The main purpose of the book is to present the reader with some of the main concepts used in data science and analytics using tools developed in Python such as Scikit-learn, Pandas, Numpy and others. The book is intended to be a bridge to the data science and analytics world for programmers and developers, as well as graduates in scientific areas such as mathematics, physics, computational biology and engineering, to name a few.

The material covered includes machine learning and pattern recognition, various regression techniques, classification algorithms, decision tree and hierarchical clustering, and dimensionality reduction. Though this text is not recommended for those just getting started with computer programming,

There are a number of topics that were not covered in this book. If you are interested in more advanced topics take a look at my book called “Advanced Data Science and Analytics with Python”. There is a follow up video for that one! Keep en eye out for that!

Related Content: Please take a look at other videos about my books:

Essential MATLAB and Octave – Video

This is a video I made for my publisher about my book “Essential MATLAB and Octave”. You can get the book here and more about the book here.

The book is a primer for programming in Matlab and Octave within the context of numerical simulations for a variety of applications. Matlab and Octave are powerful programming languages widely used by scientists and engineers. They provide excellent capabilities for data analysis, visualisation and more.

The book started as lecture notes for a course on Computational Physics – later turning into a wider encompassing syllabus covering aspects of computational finance, optimisation and even biology and economics

The aim of the book is to learn and apply programming in Matlab and octave using straightforward explanations and examples from different areas in mathematics, engineering, finance, and physics.

Essential MATLAB and Octave explains how MATLAB and Octave are powerful tools applicable to a variety of problems. This text provides an introduction that reveals basic structures and syntax, demonstrates the use of functions and procedures, outlines availability in various platforms, and highlights the most important elements for both programs.

The book can be considered as a companion for programmers (new and experienced) that require the use of computers to solve numerical problems.

Code is presented in individual boxes and explanations are added as margin notes. Although both Matlab and Octave share a large number of features, they are not strictly the same. In cases where code is specific to one of the languages the margin notes provide clarity.

This text requires no prior knowledge and it is self-contained, allowing the reader to use the material whenever needed rather than follow a particular order.

Compatible with both languages, the book material incorporates commands and structures that allow the reader to gain a greater awareness of MATLAB and Octave, write their own code, and implement their scripts and programs within a variety of applicable fields.

It is always made clear when particular examples apply only to MATLAB or only to Octave, allowing the book to be used flexibly depending on readers’ requirements.