A general purpose high-level programming language that emphasizes ease of code syntax and readability.

learn more… | top users | synonyms

0
votes
1answer
32 views

Repeated 1d minimization with similar parameters (scipy)

I have a function f(x,k1,k2) and I am trying to minimize it over x for different values of ...
0
votes
1answer
23 views

Probability of reconstructing a word using c substrings from a random sample

Consider a voice recording split into it's phonemes as our sample $S=(s_1,...,s_k) \in \Omega = P^k$. The number of phonemes is $|P| = 40$. Then I have a word $w = (w_1,...,w_n) \in P^n$. I want to ...
0
votes
0answers
8 views

petsc4py: AttributeError for Mat.createBAIJ method

I am trying to experiment how to set up a block linear system using the petsc4py port in fenics. Although there is no documentation available, I suppose BAIJ method should be a means to create a ...
1
vote
1answer
45 views

Common nodes in two FEM grids

There are two independent tetrahedral FEM grids. Second grid is subset of the first. By subset, I mean: nodes from the second grid are exactly in the same positions as some nodes from the first grid. ...
4
votes
2answers
127 views

How to Solve an Integral Equation for an Unknown Integrand numericlaly?

I am working on an astrophysical research in which we relate the cumulative number of Damped Lyman Alpha HI clouds/galaxies, namely their number densities, $\frac{dN_{DLA}}{dz}(>M, z=0),$ to the ...
5
votes
1answer
537 views

What determines the usual chemistry textbook plots of atom orbitals?

In elementary chemistry textbooks you often have pictures like the following one: Are there any conventions how to get them? I am not sure, but I guess that it are contour plots with only one ...
1
vote
1answer
50 views

How to make scatter plots of scalar fields with free software?

How can I make a scatter plot like the following, where the density of points represents the magnitude of the scalar field at that point. Consider for example the probability density for an atom: I ...
3
votes
2answers
97 views

What is the currently recommended way to install the SciPy ecosystem on OS X?

I just got a new Macbook and decided to install everything from scratch instead of migrating. Previously I've always installed SciPy etc. through MacPorts, but lately MacPorts as a whole seems not to ...
0
votes
1answer
97 views

Python Pandas / Numpy indexing faster than np.where between 2 arrays [closed]

I have 2 pandas datasets which have 'RF' field in common. The optionsdata variable is ~60K, which map to at most the histdata ...
0
votes
0answers
41 views

How to create a phase diagram using yt for python?

I'm trying to use yt to create a phase diagram in Python. I have three variables that I will call X,Y,Z from which I have a discrete set of triplets of values (x,y,z). I want to plot for each of these ...
1
vote
1answer
78 views

Addition and subtraction of two floats in Python

Yesterday I was wondering how floats are handled in a computer and what they look like in binary... I learnt about the single-precision floating-point and I tried to see the limit of that format... I ...
4
votes
1answer
89 views

Simulate electric fields due to surface charges in simple circuits using python

I want to simulate the electric fields in simple circuits using Python and only free software. My first goal is to reproduce the images given in (1) which are made by the commercial ANSYS Maxwell ...
5
votes
2answers
202 views

Numerical integration of a single integral

I am trying to evaluate this integral directly using numerical integration functions in Mathematica and Python. $$ \int_0^\infty {y^{-(n+1)}\prod_{i=1}^n \gamma(a_i+1,b_i y) }dy $$ where ...
3
votes
1answer
78 views

(numpy/scipy) Build a random vector given mean vector and covariance matrix

After running several calculations with numpy, I end with the mean vector and covariance matrix for a state vector. Is there a way with numpy or scipy to sample a random vector around this mean and ...
4
votes
1answer
95 views

Open source tool comparable to MATLAB Neural Network Tool Box?

Background I am a graduate student and a researcher. I do not like to rely on commercial products due to cost and also because I feel more comfortable in using and extending existing tools based on ...
3
votes
0answers
49 views

scipy.linalg.sparse.eigsh does not work for generalised eigenvalues

I asked this question over at StackOverflow and someone told me that I'd get a better answer here. So here's my problem: I'm working on a machine learning project which involves doing a Principal ...
4
votes
2answers
277 views

Plot integral function with scipy and matplotlib

I want to plot a numerical integral function of some function $f$ using scipy and matplotlib. How can I do this? I tried the ...
1
vote
2answers
137 views

Programming language for HPC [closed]

I'm planning on building a program that will carry out HPC. I'm aware that C/C++ is significantly better than Python in terms of the speed of computation. However, I'm not yet proficient in C/C++, so ...
2
votes
1answer
95 views

Python Vectorizing a Function Returning an Array

I have the following function that has been vectorized so that for every element in input array t, an array is output: ...
0
votes
0answers
45 views

Solving a nonlinear problem with CDF

I'm trying to solve this problem: $\begin{cases} \partial_t E=-k\left([f(\rho)-i.\left[\delta+\frac{1}{2}a\left[\dfrac{\nabla^2_{\bot}}{4}+1-\rho^2\right]\right]]E - 2CP\right)\\ \partial_t ...
5
votes
2answers
97 views

How to read the number of periods of this complicated graph?

I have two data sets that are quasi-periodic. They have the same period and can be seen clearly by eye. For example when $x\in(100,200)$, both of them have about 32 periods. Below is a zoom-in of ...
1
vote
1answer
35 views

How to use compiled python packages for matrix initialization

Assume I have an expression for an matrix initialization, for example the following: A[i,i-2*j+k] = B[i-k] * C[i] * D[i+j+k] In order to execute such a process, I could loop over all i, j and k. ...
0
votes
1answer
129 views

Finite-difference approximation of the 2nd derivative operator matrix for a staggered grid

I'm working on a computational physics assignment and I was looking for some help as I've got stuck! The question is: Write a function to create the finite-difference approximation of the 2nd ...
2
votes
0answers
108 views

Is it worth switching to timesteppers provided by PETSc if I can't write down a Jacobian for my problem? Case study with “the amoeba” toy problem

I am considering using petsc4py instead of scipy.integrate.odeint (which is a wrapper for Fortran solvers) for a problem ...
0
votes
2answers
234 views

Multiple Coupled Differential Equation solution in Python

I have 4 ordinary differential equations that are coupled. The variables in the 4 equations are functions of time and space and one of them is second order in space. \begin{equation} \frac{ \partial ...
0
votes
1answer
134 views

Heat Equation - PDE

I'm trying to model the Black-Scholes Equation (transformed into a heat equation) using method of lines in Python. The transformed formula is basically \begin{equation*} \frac{\partial u}{\partial ...
0
votes
0answers
110 views

Inverse quadratic method only makes one iteration - python

I'm tryin' to implement this method with python3 but i don't solve the problem. This is my code: ...
3
votes
2answers
83 views

How to separate text from the paper on a black and white page?

I tried to discretize an image into black and white and came into some difficult. The difference between the letters and paper is pretty clear to our eyes: However a simple thresholding trick ...
0
votes
2answers
150 views

Wave Equation PDE [closed]

I'm trying to solve the following PDE wave equation using method of lines: Wave Equation: u_tt = u_xx with initial condition: u(0,x) = sin*pi,u_t(0,x)=0, 0 < x < 1 boundary ...
3
votes
2answers
207 views

Hyperbolic Equation PDE (Python)

I'm trying to solve the following first order hyperbolic PDE problem using method of lines: Hyperbolic Equation: $u_t = -u_x$ with initial condition: $u(0,x) = 0, 0 < x < 1$ ...
1
vote
0answers
58 views

Need suggestions on how to implement this time stepping for wave equation

I have the following system of equations obtained by implementing Sympletic Euler time scheme to wave equation. I want to model this in Fenics. Here 'u' is the displacement and 'p' is corresponding ...
1
vote
3answers
356 views

LCM builtin in Python / Numpy

I can write a function to find LCM (lowest common multiple) of an array of integers, but I thought it must have been implemented in numpy or scipy and was expecting something like ...
0
votes
0answers
55 views

How to model softening of concrete?

I have a question about acquiring the softening part of the compressive stress-stain curve of concrete under uniaxial static loading. I have tried very different options: Concrete Damaged Plasticity ...
0
votes
0answers
54 views

How to Optimisation to return decimal and integer values-Python?

I want to optimize a function, where the optimization algorithm should return parameters of two types, decimal and integer. Is this possible? I am using python.
0
votes
1answer
67 views

Variational Monte Carlo: Variational energy is lower than ground state energy

I'm writing a VMC simulation for hydrogen and helium atoms, but in both my codes my variational energy for certain wavefunctions is not only statistically different from my expectation value, but it ...
1
vote
1answer
38 views

Calculate proportions of exponentially weighted factors avoiding underflow problem

I am trying to implement in Python this ratio: $\frac{w_t(i)}{\sum w_t(j)}$ where $w_t(i) = w_{t-1}(i)\cdot\exp{(-x_{t}(i))}$, i.e. the weights are exponentially decreasing without running into ...
2
votes
0answers
93 views

Solving constrained BVP, singular Jacobian

The boundary value problem is $$ \begin{cases} \dot{x}_i = \begin{cases} (0.5D^{-1}\psi)_i, \text{ if }(0.5D^{-1}\psi)_i \le 0 \\ 0 \text{, otherwise} \end{cases} \\ \dot{\psi} = 2\Sigma x \\ x(0) ...
4
votes
1answer
228 views

Numerical solution of Geodesic differential equations with Python

I have made a solver based on the SymPy.diffgeom library, where I use Scipy.Integrate to solve the following system of second order differential equations : \begin{align} u'' &+ ...
1
vote
2answers
67 views

Heat Equation Solution in One Dimension (x, t)

We're currently solving the heat equation as a part of the PDE sequence in class. We've been given the formula:$$T(i, n+1) = T(i,n)+\alpha \left [\frac{T(i+1,n)-2 T(i, n)+T(i-1,n)}{\Delta x^2} \right ...
1
vote
0answers
101 views

best package choice for visualizing agent based model simulations in python

This is a visualization/programming design problem. I am working on building a geospatial agent based model, meaning that there are multiple agents interacting within some particular spatial ...
2
votes
3answers
247 views

Runge-Kutta Simulation For Projectile Motion With Drag

I am attempting to simulate projectile flight with drag. However, with a timestep of 0.1 seconds, I am consistently getting an error of ~0.1-1%. ...
1
vote
1answer
102 views

Diffusion with space dependent drift in Fipy

I need to solve a diffusion equation in periodic boundary conditions using fipy but I would like to have a drift term that depends on the position so like this: $$ \partial_t u(x,t) = \partial_x^2 ...
0
votes
1answer
42 views

Solve a pair of coupled nonlinear equations within certain limits

This answer to this question works only for situations in which the desired solution to the coupled functions is not restricted to a certain range. But what if, for example, we wanted a solution such ...
0
votes
0answers
22 views

fortran lib for sine weave with vectors as input

Hi i have problem with calculating sine wave. With python numpy, numexpr calculation of sine wave from equation z = sum(Asin(omt+eps),axis=1), takes me something like 1min50sec when shapes of A,om,eps ...
1
vote
1answer
63 views

Python package for large absolute value optimisation

I have an absolute value optimisation problem $$\min_x \sum |r-Cx|$$ where $x$ is small around 200 dimension. But $C$ has lots of rows, $C_{30000\times200}$ and $r$ is $30000\times1$. So this will ...
2
votes
0answers
108 views

Adaptive Finite Element Method - Laplace

I'm currently attempting to turn my code for solving the laplace equation using finite element approximations into an adaptive one using the dual weighted residual as my error estimator: i.e. my ...
0
votes
0answers
55 views

Laplace Operator with PyNFFT

I am learning to use PyNFFT for nonuniform FFT. I try to apply the laplace operator to functions. As a test, I want to take $f(x) = \cos( 2\pi i k \cdot x)$, calcualte (using the package) $\Delta f$ ...
6
votes
1answer
167 views

Test of 3rd-order vs 4th-order symplectic integrator with strange result

In my answer to a question on MSE regarding a 2D Hamiltonian physics simulation, I have suggested using a higher-order symplectic integrator. Then I thought it might be a good idea to demonstrate the ...
1
vote
1answer
91 views

Computation of plane wave scattering on semi infinite plane

I have attempted to code up the simple math required to plot the total field set up by an incident plane wave on a semi-infinite flat plate which can be found here. To summarise: $$\phi_s(r,\theta ) ...
1
vote
0answers
72 views

How to adjust scikit-learn FactorAnalysis() settings to get scores output similar to one from factanal() in R?

I'm new to factor analysis and I need to compute factor scores using Python. I have R code to compute scores and I want to ...