scientific-computing

Python distributions and environments for scientific computing

☆樱花仙子☆ 提交于 2019-11-28 16:03:00
问题 I apologize upfront if this question is too broad. I come from the MATLAB world and have relatively little experience with Python. After having spent some time reading about several Python-based environments and distributions for scientific computing, I feel that I still don't fully understand the landscape of solutions or the precise relationship between some notable packages, including: SciPy Spyderlib Pythonxy Enthought Python Distribution Sage More specifically: Do any of the above

Numercially stable softmax

柔情痞子 提交于 2019-11-28 10:12:39
Is there a numerically stable way to compute softmax function below? I am getting values that becomes Nans in Neural network code. np.exp(x)/np.sum(np.exp(y)) The softmax exp( x )/sum(exp( x )) is actually numerically well-behaved. It has only positive terms, so we needn't worry about loss of significance, and the denominator is at least as large as the numerator, so the result is guaranteed to fall between 0 and 1. The only accident that might happen is over- or under-flow in the exponentials. Overflow of a single or underflow of all elements of x will render the output more or less useless.

Concatenate a large number of HDF5 files

青春壹個敷衍的年華 提交于 2019-11-28 08:38:35
I have about 500 HDF5 files each of about 1.5 GB. Each of the files has the same exact structure, which is 7 compound (int,double,double) datasets and variable number of samples. Now I want to concatenate all this files by concatenating each of the datasets so that at the end I have a single 750 GB file with my 7 datasets. Currently I am running a h5py script which: creates a HDF5 file with the right datasets of unlimited max open in sequence all the files check what is the number of samples (as it is variable) resize the global file append the data this obviously takes many hours, would you

Spectrogram C++ library

只谈情不闲聊 提交于 2019-11-28 04:43:43
For my current project in C++ / Qt I need a library (LGPL is preferred) which can calculate a spectrogram from a signal ( basically an array of doubles ). I already use Qwt for the GUI part. Any suggestions? Thanks. It would be fairly easy to put together your own spectrogram. The steps are: window function (fairly trivial, e.g. Hanning) FFT (FFTW would be a good choice but if licensing is an issue then go for Kiss FFT or similar) calculate log magnitude of frequency domain components (trivial: log(sqrt(re * re + im * im)) David Cary "How do I create a frequency vs time plot?" lists several

How can I use Cython well to solve a differential equation faster?

会有一股神秘感。 提交于 2019-11-28 04:33:38
问题 I would like to lower the time Scipy's odeint takes for solving a differential equation. To practice, I used the example covered in Python in scientific computations as template. Because odeint takes a function f as argument, I wrote this function as a statically typed Cython version and hoped the running time of odeint would decrease significantly. The function f is contained in file called ode.pyx as follows: import numpy as np cimport numpy as np from libc.math cimport sin, cos def f(y, t,

Is the order of a Python dictionary guaranteed over iterations?

大城市里の小女人 提交于 2019-11-27 15:46:00
问题 I'm currently implementing a complex microbial food-web in Python using SciPy.integrate.ode. I need the ability to easily add species and reactions to the system, so I have to code up something quite general. My scheme looks something like this: class Reaction(object): def __init__(self): #stuff common to all reactions def __getReactionRate(self, **kwargs): raise NotImplementedError ... Reaction subclasses that ... implement specific types of reactions class Species(object): def __init__(self

Practices for programming in a scientific environment? [closed]

与世无争的帅哥 提交于 2019-11-27 09:57:55
Background Last year, I did an internship in a physics research group at a university. In this group, we mostly used LabVIEW to write programs for controlling our setups, doing data acquisition and analyzing our data. For the first two purposes, that works quite OK, but for data analysis, it's a real pain. On top of that, everyone was mostly self-taught, so code that was written was generally quite a mess (no wonder that every PhD quickly decided to rewrite everything from scratch). Version control was unknown, and impossible to set up because of strict software and network regulations from

Numercially stable softmax

我怕爱的太早我们不能终老 提交于 2019-11-27 04:37:40
问题 Is there a numerically stable way to compute softmax function below? I am getting values that becomes Nans in Neural network code. np.exp(x)/np.sum(np.exp(y)) 回答1: The softmax exp( x )/sum(exp( x )) is actually numerically well-behaved. It has only positive terms, so we needn't worry about loss of significance, and the denominator is at least as large as the numerator, so the result is guaranteed to fall between 0 and 1. The only accident that might happen is over- or under-flow in the

Concatenate a large number of HDF5 files

我的未来我决定 提交于 2019-11-27 02:20:39
问题 I have about 500 HDF5 files each of about 1.5 GB. Each of the files has the same exact structure, which is 7 compound (int,double,double) datasets and variable number of samples. Now I want to concatenate all this files by concatenating each of the datasets so that at the end I have a single 750 GB file with my 7 datasets. Currently I am running a h5py script which: creates a HDF5 file with the right datasets of unlimited max open in sequence all the files check what is the number of samples

Spectrogram C++ library

江枫思渺然 提交于 2019-11-27 00:37:12
问题 For my current project in C++ / Qt I need a library (LGPL is preferred) which can calculate a spectrogram from a signal ( basically an array of doubles ). I already use Qwt for the GUI part. Any suggestions? Thanks. 回答1: It would be fairly easy to put together your own spectrogram. The steps are: window function (fairly trivial, e.g. Hanning) FFT (FFTW would be a good choice but if licensing is an issue then go for Kiss FFT or similar) calculate log magnitude of frequency domain components