def fibonacci(n): if 0 <= n <= 1: return n n_minus1, n_minus2 = 1, 0 result = None for f in range(n – 1): result = n_minus2 + n_minus1 n_minus2 = n_minus1 n_minus1 = result return result Source: Python..

#### Category : math

The random variable Y takes values in {1,2, … , N} and random variable X in {1,2, … , M} as input and the joint distribution of Y and X is given by the following matrix as shown in this Figure . where Pmn is the probability that X = m and Y = n. ..

I am trying to write a function equilateral(x, y): that takes two np.ndarrays of shape (N,) , where x and y are natural numbers and returns a point z an np.ndarray of shape (N,) such that (x, y, z) are are the vertices of an equilateral triangle. Any one please suggest. Source: Python..

I have a code for Simpsons rule for definite integrals that I created myself. For some reason, this code is not outputting the correct value. My current function is y = x^3, the value of N is 4, the value of a is 0 and the value of b is 2. According to Simpsons rule, ..

There is a set of points x,y. It is necessary to approximate and extrapolate the curve connecting these points in python 3.10. Please tell me which library is more convenient to use for this, where is this functionality? Source: Python..

How can I add math expressions in python projects (For example the root symbol or the integral symbol)? Please help i’ve tried some sites and videos but i can’t achive it Source: Python..

So I have the following pandas dataframe Start time | End time | Value| which each line represents a part of the line plot where X axis is time and Y axis is value. e.g: start time: 0 End time: 5, there will be a linearized line from 0 til 5. The problem is that ..

I want to calculate powerset of 1-dim array using numpy, sckit-learn of whatever is the fastest approach. By fast approach i mean, something that will take less that 9 seconds, even when the length of the input is 200000. This code below does the trick. But it is too slow. from itertools import chain, combinations ..

Recently,for my project,I made a Calculator using eval(). Then I realized how much of a security threat could it really be knowing that it directly runs the commands. I wanted to know is there any Eval like functions in math library which Only gives the answer of a string like this(and not a security threat ..

I am plotting a map that shows the number of tweets by country. The countries with high number of tweets are supposed to be in dark color, while the low in light color. I am scaling the data based max_count of tweets value through conditional log scale (code below) in order to have a good ..

## Recent Comments