scientific-computing

Integrating a multidimensional integral in scipy

亡梦爱人 提交于 2019-12-02 19:26:53
Motivation: I have a multidimensional integral, which for completeness I have reproduced below. It comes from the computation of the second virial coefficient when there is significant anisotropy: Here W is a function of all the variables. It is a known function, one which I can define a python function for. Programming Question: How do I get scipy to integrate this expression? I was thinking of chaining two triple quads ( scipy.integrate.tplquad ) together, but I'm worried about performance and accuracy. Is there a higher dimensional integrator in scipy , one that can handle an arbitrary

sigmoidal regression with scipy, numpy, python, etc

吃可爱长大的小学妹 提交于 2019-12-02 15:51:45
I have two variables (x and y) that have a somewhat sigmoidal relationship with each other, and I need to find some sort of prediction equation that will enable me to predict the value of y, given any value of x. My prediction equation needs to show the somewhat sigmoidal relationship between the two variables. Therefore, I cannot settle for a linear regression equation that produces a line. I need to see the gradual, curvilinear change in slope that occurs at both the right and left of the graph of the two variables. I started using numpy.polyfit after googling curvilinear regression and

what changes when your input is giga/terabyte sized?

ⅰ亾dé卋堺 提交于 2019-12-02 15:38:28
I just took my first baby step today into real scientific computing today when I was shown a data set where the smallest file is 48000 fields by 1600 rows (haplotypes for several people, for chromosome 22). And this is considered tiny. I write Python, so I've spent the last few hours reading about HDF5, and Numpy, and PyTable, but I still feel like I'm not really grokking what a terabyte-sized data set actually means for me as a programmer. For example, someone pointed out that with larger data sets, it becomes impossible to read the whole thing into memory, not because the machine has

What can MATLAB do that R cannot do? [closed]

喜欢而已 提交于 2019-12-02 13:46:12
I often hear people complain how expensive MATLAB licenses are. Then I wonder why they don't just use Octave or R . But is the latter right? Can you use R to replace MATLAB? Shane Can you use R to replace MATLAB? Yes. I used MATLAB for years but switched primarily to R in the last 3 years. At this point, they have much more in common than not. It partially depends on your field and use-case. And as Spencer Graves said previously , it also depends on which "church you happen to frequent". It's best if you look at the MATLAB toolkit vs. CRAN for a specific task before you decide. A similar

How to make up lost reference to declare a field (numpy)?

强颜欢笑 提交于 2019-12-02 07:57:26
Let's say I have class that contains a lot of fields and I want to make initializer that work for all fields so that I don't need to write an initializer for each of them. class Foo(): def __init__(n): self.n = n self.x = None self.m = None self.v = None but method def init_x(self, x): # initialize or erase x to zeros x = np.zeros(self.n) doesn't work because x= loses reference to x . But @staticmethod def get_x(x, i): return x[i] @staticmethod def set_x(x, i): x[i] = val works. What could possibly make my init_x to work? I want to set the fields to None initially cuz there are other things

Calculating the outer product for a sequence of numpy ndarrays [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-02 03:29:16
问题 This question already has an answer here : numpy elementwise outer product (1 answer) Closed last year . I have a list of 3D points p stored in an ndarray with shape (N, 3). I want to compute the outer product for each 3d point with itself: N = int(1e4) p = np.random.random((N, 3)) result = np.zeros((N, 3, 3)) for i in range(N): result[i, :, :] = np.outer(p[i, :], p[i, :]) Is there a way to compute this outer product without any python-level loops? The problem is that np.outer does not

Solving Exponential equation in MATLAB

拈花ヽ惹草 提交于 2019-12-01 09:29:24
I am now trying to solve an exponential equation in MATLAB as a part of my assignment. It is easy to see that the equation exp(-t)+t*exp(-t)-n=0 would have two solutions, one greater than zero and one smaller. However, using just the solve function, MATLAB returns something called lambertw function and it can only eval() to the solution below zero, which happens not to be the one I want for the answer. Could anyone help me here? Thanks in advance for all the answers and comments! p.s. As an alternative, I am thinking about using Newton-Raphson method to solve it, but I wonder how is the speed

Solving Exponential equation in MATLAB

拥有回忆 提交于 2019-12-01 07:01:32
问题 I am now trying to solve an exponential equation in MATLAB as a part of my assignment. It is easy to see that the equation exp(-t)+t*exp(-t)-n=0 would have two solutions, one greater than zero and one smaller. However, using just the solve function, MATLAB returns something called lambertw function and it can only eval() to the solution below zero, which happens not to be the one I want for the answer. Could anyone help me here? Thanks in advance for all the answers and comments! p.s. As an

Efficiently construct FEM/FVM matrix

≯℡__Kan透↙ 提交于 2019-12-01 05:59:43
问题 This is a typical use case for FEM/FVM equation systems, so is perhaps of broader interest. From a triangular mesh à la I would like to create a scipy.sparse.csr_matrix . The matrix rows/columns represent values at the nodes of the mesh. The matrix has entries on the main diagonal and wherever two nodes are connected by an edge. Here's an MWE that first builds a node->edge->cells relationship and then builds the matrix: import numpy import meshzoo from scipy import sparse nx = 1600 ny = 1000

ImportError: No module named fixedpickle when running PyDsTool on Windows 7

自闭症网瘾萝莉.ら 提交于 2019-12-01 00:48:28
I have downloaded PyDsTool for Windows. And I believe I have pointed python in the correct location. But I get the following error from PyDSTool import * Traceback (most recent call last): File "<ipython-input-1-7b811358a37e>", line 1, in <module> from PyDSTool import * File "C:\Anaconda\lib\site-packages\pydstool-0.88.140328-py2.7.egg\PyDSTool\__init__.py", line 85, in <module> from .Events import * File "C:\Anaconda\lib\site-packages\pydstool-0.88.140328-py2.7.egg\PyDSTool\Events.py", line 13, in <module> from .Variable import * File "C:\Anaconda\lib\site-packages\pydstool-0.88.140328-py2.7