Calculating e (base of the natural log) to high precision in Python?

Is it possible to calculate the value of the mathematical constant, *e* with high precision (2000+ decimal places) using Python? I am particularly interested in a solution either in or that...

ValueError: could not convert string to float: id

I'm running the following python script: #!/usr/bin/python import os,sys from scipy import stats import numpy as np f=open('data2.txt', 'r').readlines() N=len(f)-1 for i in range(0,N): ...

A tool to convert MATLAB code to Python

I have a bunch of MATLAB code from my MS thesis which I now want to convert to Python (using numpy/scipy and matplotlib) and distribute as open-source. I know the similarity between MATLAB and...

Inter-rater agreement in Python (Cohen's Kappa)

I have ratings for 60 cases by 3 raters. These are in lists organized by document - the first element refers to the rating of the first document, the second of the second document, and so...

How to find all neighbors of a given point in a delaunay triangulation using scipy.spatial.Delaunay?

I have been searching for an answer to this question but cannot find anything useful. I am working with the python scientific computing stack (scipy,numpy,matplotlib) and I have a set of 2...

Finding the roots of a large number of functions with one variable

I'm working with Python/numpy/scipy to write a small ray tracer. Surfaces are modelled as two-dimensional functions giving a height above a normal plane. I reduced the problem of finding the point...

How to calculate rolling / moving average using python + NumPy / SciPy?

There seems to be no function that simply calculates the moving average on numpy/scipy, leading to convoluted solutions. My question is two-fold: What's the easiest way to (correctly) implement a...

Solve an implicit ODE (differential algebraic equation DAE)

I'm trying to solve a second order ODE using odeint from scipy. The issue I'm having is the function is implicitly coupled to the second order term, as seen in the simplified snippet (please...

Count consecutive occurences of values varying in length in a numpy array

Say I have a bunch of numbers in a numpy array and I test them based on a condition returning a boolean array: np.random.seed(3456) a = np.random.rand(8) condition = a>0.5 And with this boolean...

Generating low discrepancy quasi-random sequences in python/numpy/scipy?

There is already a question on this but the answer contains a broken link, and being over two years old, I'm hoping there's a better solution now :) Low discrepancy quasi-random sequences, e.g....

python equivalent of qnorm, qf and qchi2 of R

I need the quantile of some distributions in python. In r it is possible to compute these values using the qf, qnorm and qchi2 functions. Is there any python equivalent of these R functions? I...

ImportError: No module named scipy

I am using Python 2.7 and trying to get PyBrain to work. But I get this error even though scipy is installed - Traceback (most recent call last): File "<stdin>", line 1, in <module> File...

Error while trying to install sklearn from Pycharm | arrayobject.h cannot be absolute

Complete error statement: ValueError: path '/home/andy/anaconda3/lib/python3.5/sitepackages/numpy/core/include/numpy/arrayobject.h' cannot be absolute I have installed Scipy and numpy (mkl)...

Running Jupyter notebook in a virtualenv: installed sklearn module not available

I have installed a created a virtualenv machinelearn and installed a few python modules (pandas, scipy and sklearn) in that environment. When I run jupyter notebook, I can import pandas and scipy...

TensorFlow: Blas GEMM launch failed

When I'm trying to use TensorFlow with Keras using the gpu, I'm getting this error message: C:\Users\nicol\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\__main__.py:2: UserWarning: Update...

One Sided One Sample T Test Python

In Python I'm using SciPy for a one sample t test: from scipy import stats one_sample_data = [177.3, 182.7, 169.6, 176.3, 180.3, 179.4, 178.5, 177.2, 181.8, 176.5] one_sample =...

Numeric integral of sin(x)/x

I want to calcultate the definite integral with quadratures of sin(x)/x in python using scipy. With n = 256. It doesnt seem to work well: from scipy import integrate exact =...

How do you feed Scipy's bvp only the BCs you have?

The only example/docs I can find are on the Scipy docs page. To test, I'm looking at a time-independent Schrod eq in a 1d infinite potential well. This has a neat analytic solution found by...

PyTorch Cuda with anaconda not available

I'm using anaconda to regulate my environment, for a project i have to use my GPU for network training. I use pytorch for my project and i'm trying to get CUDA working. I installed cudatoolkit,...

Jupyter Notebook - Cannot Connect to Kernel

I've tried installing jupyter notebook using pip3 install jupyter. Every time i launch a new jupyter notebook, the notebook is unable to connect to the kernel. See screenshot below Attaching my...

Fast key-value disk storage for Python

I'm wondering if there is a fast on-disk key-value storage with Python bindings which supports millions of read/write calls to separate keys. My problem involves counting word co-occurrences in a...

Building docs fails due to missing pandoc

The problem I am having trouble getting my docs to build successfully when clicking "Build" on the readthedocs.io web interface, but it builds just fine on my local machine. To test that it is an...

How do I import sklearn on python 3.5.0 without a Type error?

I installed the prerequisites to install sklearn via this page: https://scikit-learn.org/stable/install.html and everything installed fine. However, when I attempt to import sklearn I receive the...

tensorflow image detection package installation problem

I am trying to install the image detection https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md When I am running this final command: python -m pip install...

landau Random number generator

I am trying to generate 1000 values with landau distribution with an MPV(most probable value) of 25, can't find a landau random number generator in scipy or numpy. I tried pylandau {pip install...

Tensorflow Object Detection Api M1 Macbook Conflict Error

Machine: MacBook Air M1 2020 OS: macOs BigSur 11.4 Python version of venv: Python 3.8.6 Tensorflow version: ATF Apple Tensorflow 0.1a3 Pip version: 21.2.4 I have installed Tensorflow from...

ERROR: No matching distribution found for scipy==1.7.1

ERROR: Could not find a version that satisfies the requirement scipy==1.7.1 (from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1,...

Getting DLL error when running tensorflow/keras program on python gpu 3.8

I am trying to run my simple AI program but I keep getting this DLL error: ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a...

How to find peaks of FFT graph using Python?

I am using Python to perform a Fast Fourier Transform on some data. I then need to extract the locations of the peaks in the transform in the form of the x-values. Right now I am using Scipy's fft...

Tensorflow Object Detection API taking forever to install in a Google Colab and failing

I am trying to install the Tensorflow Object Detection API on a Google Colab and the part that installs the API, shown below, takes a very long time to execute (in excess of one hour) and...