SYSU
博学
审问
慎思
明辨
笃行
SYR
Suos
Cultores
Scientia
Coronat

Recent Posts

  • Scientific Python 5: Enhancing Scientific Writing With Python

    Despite being lengthy and obscure, is still one of the most popular typesetting systems for academic literature. Fortunately, being a compiled (scripting) language, has a much larger room for customization, and it can do many things that WYSIWYG editors can only dream of. LuaTex is already a very unique and successful attempt to expose the low-level features of the compiler to a generic programming language. But due to the prevalence of pdflatex and xetex, I seldom use LuaTex.

  • Scientific Python 4: Simple Interactive Scientific Program With matplotlib

    Sometimes scientific research has to do with a large number of repetitive experiments. In certain cases, the researcher has to adjust some key parameters of his/her application frequently. It may be inefficient to modify the code directly to do so, but it is also too demanding to write a special GUI for this scenario. Fortunately, matplotlib provides us with a concession, for it is able to generate simple interactive GUI with little effort. you can refer to the documentation of matplotlib.widgets if you want to know more.

  • Scientific Python 3: The Power Of scipy

    The scipy package provides a variety of functionalities, which can be applied to a broad range of scientific research. It is quite common for us to ignore that fact that a function already exists in scipy and waste time on finding other packages or reinventing the wheels. In this post, I would show a series of applications for most scipy submodules, just to let readers get a grasp of how versatile this package is. Before the decision of writing one’s own code, it is always better to refer to scipy documentation and see if there is anything helpful.

  • Scientific Python 2: Elegant Arrays

    Unlike programming in C++, where loops are extremely efficient, the loops in Python are notoriously slow. Usually we need a lot of workarounds to eliminate loops in Python to achieve high performance. In my opinion, numpy can make loop unnecessary in at least 80 percent of scenarios. In this post, I demonstrate some common scenarios where proper numpy techniques can reduce the amount of code and improve performance. I would recommend that every time someone finds it necessary to write loops in Python for scientific computation, he/she should refer to the documentation of numpy/scipy or stackoverflow to see if there is built-in functions to help eliminate loops. Surprisingly, such functions usually exist (because we usually underestimate the number of APIs in numpy/scipy).

  • Scientific Python 1: Introduction

    When I first started doing research, I would try to use C++ to write my programs because of “performance concerns”. My instructor and facts soon made me realize that it is extremely inefficient to do so. I am starting to realize that in scientific research (especially for machine learning), Python almost always yields less total time consumption. The development time with Python is obviously less than that of C++ by magnitudes. But believe it or not, carefully written Python code can also run as fast as C/C++ code. Together with simple multithreading, serialization and graphing makes Python the ideal language for research. I am slowly changing my views towards Python from “an extremely slow and hard-to-read” language to “the best language ever if not for its relatively slower speed”.