programming:scientific

- Some thoughts on what setups to use for scientific programming.
- Python Introduction for Econometrics, Statistics and Data Analysis Python is best for extensibility and full vertical integration.

- http://www.scipy.org/PerformancePython. Numpy is about the same speed as Matlab (both 50X faster than just Python), and about a 10X speedup is gained by going to some form of C++ (good examples in the document)

- Matlab looks great for analyzing files quickly, code is quite efficient character-wise for prototyping, but not really for long-term usage apparently.
- Costs a lot of money ($5000+) once you get to industry and is a lot of headache to deal with license server and stuff

Another great option is the scientific toolboxes in Python.

- See top link for great Python tutorial
- Python(x,y) is the best to start with. Includes most packages you need
- DIVISION IN PYTHON TAKES FLOOR
*In Python 3.0, integer division will return a float, e.g., 1/3 will be 0.3333… At Scipy 2006, Guido explicitly stated in his keynote talk that the design choice he made in Python (i.e., that n/m is floor(n/m)) was a mistake.**In Sage (http://sagemath.org), which is built on Python, we do some very minimal preparsing of input, so that 1/3 is the exact rational number 1/3 (instead of Python's stupid 1/3 == 0). We also replace, e.g., 2^3 by 23. Sage is does a lot of exact symbolic and high precision arithmetic, so 1/3 staying the rational 1/3 makes sense as the default (though one can easily change this).*

- Print out stack (useful for try / except stuff):
`traceback.print_exc()`

# By Peter Norvig ranks = ['--23456789TJQKA'.index(r) for r,c in hand] #outputs index of char...nice

list = [] for i in range(10): list.append([i,i+1]) numpy.concatenate(tuple(self.dict[key]), axis=0)

- Use numpy.fromfile: StackOverflow and documentation example: Numpy Fromfile. Does complex datatypes too! 80 sec mmap → .8 seconds
- Doing things with generators: http://stackoverflow.com/questions/102535/what-can-you-use-python-generator-functions-for

#Gather all the elements returning from the generator big_list = list(the_generator)

- Put very eloquently by a Quora user in a great thread:

I use matlab for offline analysis and python for on the fly processing <and GUIs, and end products>. Matlab is more complete but heavier. Python is open source and faster. I use both, for different purposes.

programming/scientific.txt · Last modified: 2017/09/15 17:58 (external edit)