scientific-computing

MATLAB: Block matrix multiplying without loops

点点圈 提交于 2019-12-06 11:55:14
I have a block matrix [A B C...] and a matrix D (all 2-dimensional). D has dimensions y-by-y, and A, B, C , etc are each z-by-y. Basically, what I want to compute is the matrix [D*(A'); D*(B'); D*(C');...] , where X ' refers to the transpose of X . However, I want to accomplish this without loops for speed considerations. I have been playing with the reshape command for several hours now, and I know how to use it in other cases, but this use case is different from the other ones and I cannot figure it out. I also would like to avoid using multi-dimensional matrices if at all possible. Honestly

plotting a parabola within part of a repeating signal using numpy

爷,独闯天下 提交于 2019-12-06 10:49:23
I have a repeating signal that varies a little bit with each cycle of a process that repeats roughly every second, though the duration and the contents of each cycle vary from each other a little bit within some parameters. There are a thousand x,y coordinates for every second of my signal data. A small, but important, segment of the data within each cycle is corrupted, and I want to replace each corrupted segment with an upward facing parabola. For each data segment that needs to be replaced by the parabola, I have the x,y coordinates of three points. The vertex/minimum is one of those points

Python (scikit learn) lda collapsing to single dimension

痞子三分冷 提交于 2019-12-06 10:37:36
问题 I'm very new to scikit learn and machine learning in general. I am currently designing a SVM to predict if a specific amino acid sequence will be cut by a protease. So far the the SVM method seems to be working quite well: I'd like to visualize the distance between the two categories (cut and uncut), so I'm trying to use the linear discrimination analysis, which is similar to the principal component analysis, using the following code: from sklearn.discriminant_analysis import

Performance comparison of FPU with software emulation

安稳与你 提交于 2019-12-06 02:13:35
问题 While I know (so I have been told) that Floating-point coprocessors work faster than any software implementation of floating-point arithmetic, I totally lack the gut feeling how large this difference is, in order of magnitudes. The answer probably depends on the application and where you work, between microprocessors and supercomputers. I am particularly interested in computer simulations. Can you point out articles or papers for this question? 回答1: A general answer will obviously very vague,

HDF5 Storage Overhead

我怕爱的太早我们不能终老 提交于 2019-12-06 00:41:58
问题 I'm writing a large number of small datasets to an HDF5 file, and the resulting filesize is about 10x what I would expect from a naive tabulation of the data I'm putting in. My data is organized hierarchically as follows: group 0 -> subgroup 0 -> dataset (dimensions: 100 x 4, datatype: float) -> dataset (dimensions: 100, datatype: float) -> subgroup 1 -> dataset (dimensions: 100 x 4, datatype: float) -> dataset (dimensions: 100, datatype: float) ... group 1 ... Each subgroup should take up

Using scipy gaussian kernel density estimation to calculate CDF inverse

我怕爱的太早我们不能终老 提交于 2019-12-05 19:17:56
The gaussian_kde function in scipy.stats has a function evaluate that can returns the value of the PDF of an input point. I'm trying to use gaussian_kde to estimate the inverse CDF. The motivation is for generating Monte Carlo realizations of some input data whose statistical distribution is numerically estimated using KDE. Is there a method bound to gaussian_kde that serves this purpose? The example below shows how this should work for the case of a Gaussian distribution. First I show how to do the PDF calculation to set up the specific API I'm trying to achieve: import numpy as np from scipy

What kind of work benifits from OpenCL

我们两清 提交于 2019-12-05 07:06:48
First of all: I am well aware that OpenCL does not magically make everything faster I am well aware that OpenCL has limitations So now to my question, i am used to do different scientific calculations using programming. Some of the things i work with is pretty intense in regards to the complexity and number of calculations. SO i was wondering, maybe i could speed things up bu using OpenCL. So, what i would love to hear from you all is answers to some of the following [bonus for links]: *What kind of calculations/algorithms/general problems is suitable for OpenCL *What is the general guidelines

Efficient ways to write a large NumPy array to a file

前提是你 提交于 2019-12-05 06:14:00
I've currently got a project running on PiCloud that involves multiple iterations of an ODE Solver. Each iteration produces a NumPy array of about 30 rows and 1500 columns, with each iterations being appended to the bottom of the array of the previous results. Normally, I'd just let these fairly big arrays be returned by the function, hold them in memory and deal with them all at one. Except PiCloud has a fairly restrictive cap on the size of the data that can be out and out returned by a function, to keep down on transmission costs. Which is fine, except that means I'd have to launch

Tracing Python warnings/errors to a line number in numpy and scipy

╄→гoц情女王★ 提交于 2019-12-05 00:43:40
I am getting the error: Warning: invalid value encountered in log From Python and I believe the error is thrown by numpy (using version 1.5.0). However, since I am calling the "log" function in several places, I'm not sure where the error is coming from. Is there a way to get numpy to print the line number that generated this error? I assume the warning is caused by taking the log of a number that is small enough to be rounded to 0 or smaller (negative). Is that right? What is the usual origin of these warnings? Putting np.seterr(invalid='raise') in your code (before the errant log call) will

How to deal with underflow in scientific computing?

扶醉桌前 提交于 2019-12-04 17:49:51
问题 I am working on probabilistic models, and when doing inference on those models, the estimated probabilities can become very small. In order to avoid underflow, I am currently working in the log domain (I store the log of the probabilities). Multiplying probabilities is equivalent to an addition, and summing is done by using the formula: log(exp(a) + exp(b)) = log(exp(a - m) + exp(b - m)) + m where m = max(a, b) . I use some very large matrices, and I have to take the element-wise exponential