A general purpose high-level programming language that emphasizes ease of code syntax and readability.
Questions tagged [python]
921 questions
6
votes
3 answers
What is the best way to get erfi with scipy?
I want this:
http://mathworld.wolfram.com/Erfi.html
But apparently scipy does not have this in its extensive special functions library.
http://docs.scipy.org/doc/scipy/reference/special.html
It is not the same as erfinv. Right now I am using an…
none
- 508
- 1
- 5
- 7
6
votes
2 answers
How to generate a rotated (by 90 degrees) logistic sigmoid function in Python
I created this Python function to generate a sigmoid function where I can modify position and width:
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(x,a,b):
# sigmoid function with parameters a = center; b = width
return…
MyCarta
- 163
- 1
- 5
5
votes
1 answer
creating a flat surface in python
I'm trying to create a figure of particle distribution from a reference surface in python. I plan to get a distribution in python and then prettify it with tikz. I tried this:
xs = np.linspace(-1, 1, 10)
ys = np.linspace(-1, 1, 10)
X, Y =…
Yotam
- 181
- 1
- 5
5
votes
1 answer
Python: Underflow vs. exp of large negative numbers
Suppose I have values of log(P(x_i)), i.e. log-probabilities to events x_i. The probabilities are very small, so that these log-values are of the order of -1e3.
I want to compute an expectation value. In order to evaluate the corresponding sum, I…
reloh100
- 153
- 6
5
votes
2 answers
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 $\gamma(a,x)=\int_0^x dt\ t^{a-1}e^{-t}$ is the lower…
reg
- 51
- 2
4
votes
1 answer
divide an array using a changing length sequence of boolean var as index
i have an array of boolean variables. The array has a sort of structure, it's formed of many sequences of zeros and ones, sequences of different length. such as:
[1111111100001111111111000000000000001111111000000111111111111111110000]
"commas…
arj
- 155
- 1
- 8
3
votes
1 answer
Getting a list of coordinate points of a Cartesian grid in Python
I have a regular three dimensional Cartesian Grid with numpy.linspace(a1,an,na), numpy.linspace(b1,bn,nb), numpy.linspace(c1,cn,nc) along their respective dimensions.
I now want to evaluate a function at all points $(a_i,b_j,c_k)$ on this grid. The…
ertl
- 133
- 1
- 4
2
votes
0 answers
Split Operator 2D-->3D
I am trying to modify my simulations on population dynamics using the split-operator method from 2D two-level real Hamiltonain $$H_{2D} =T(x,y)\otimes1_2 +\begin{pmatrix} -z & y\\
y & z\\
\end{pmatrix},$$ to a complex 3D two level…
New2Python
- 21
- 3
2
votes
1 answer
How is the fuzzy logic calculated in scikit-fuzzy?
I am following this example from documentation of scikit-fuzzy library, but cannot figure out the math behind fuzzy rules there.
Here is a short version of the example.
Food quality was 6.5 (medium)
Service was 9.8 (great)
Food quality and service…
Ewelina Luczak
- 123
- 3
2
votes
3 answers
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 be as cleanly maintained as it once was, and I…
N. Virgo
- 1,223
- 1
- 10
- 23
2
votes
5 answers
Computing the Madelung constant
I am self teaching myself python and computational physics via Mark Newmans book Computational Physics the exercise is 2.9 of Computational Physics I have to compute the Madelung constant. .
I have two different solutions worked out I wanted to…
FireFistAce
- 35
- 1
- 6
1
vote
0 answers
How to simulate a multi propagation of a laser beam in atmospheric turbulence?
I want to simulate how a Gaussian beam would look like at the receiver plane when propagated through an atmospheric turbulence. For this I am using AO package. Since I didn't see any function for multipropagation i.e. choosing multiple phase screens…
Rima
- 111
- 2
1
vote
0 answers
Is there a way to generate a sample $(X_i, Y_i, Z_i)$ from custom distribution?
I'm newbie here.
I'm wondering if it's possible to generate $(X_i, Y_i, Z_i)$ from my own distribution function? I know that there is a way to make own class for 1D variable. But what about 3D case?
openspace
- 111
- 2
1
vote
1 answer
Looping in Python to find additional vectors using a given initial condition
My question relates to looping in Python.
I have an original $6$-sized vector, $F(n,t=0)=[1,0,0,0,0,0]$
Hence, the $n$-values range from $0 \rightarrow 5$.
This output for the original vector is just a series of values such as $F(0,0)=1, F(1,0) = 0$…
David
- 21
- 2
1
vote
0 answers
How to translate Python infinitely big integer into Cython?
I want to factorize very huge numbers (e.g. 100-bits, 200-bits numbers) with Cython.
Hi everyone, I implemented the Elliptic Curve Method for factorization into Python 3.6. Now, I want to speed up my code using Cython (version 29.13). I'm a beginner…
G.F
- 11
- 2