logarithm

Logarithms in sympy

Logarithms in sympy Question: Please tell me how you can change log(e) to 1. And in general is there a way in sympy to get a float-type answer? For example, instead of log(2), get 0.69314718056 from math import * from sympy import * x1=symbols(‘x1’) x2=symbols(‘x2’) Func = e**(2*x1)*(x1+x2**2+2*x2) print(Func.diff(x2)) Here I already get log(e). In …

Total answers: 1

Is there a way to generate a lognormal distribution from a pre-defined normal distribution?

Is there a way to generate a lognormal distribution from a pre-defined normal distribution? Question: I have the code which generates a normal distribution as a pdf, centered at the mean 400, with st import numpy as np import matplotlib.pyplot as plt import scipy.stats muPrev, sigmaPrev = 400, 40. a = np.random.normal(muPrev, sigmaPrev, 100000) count, …

Total answers: 3

Artificial Inteligent

Artificial Inteligent Question: Can the advancement of Artificial Intelligence (AI) technology endanger human survival? Why? Asked By: Roberth || Source Answers: Biased data also widens the gap because there is a bias towards certain parameters such as gender, education, environment, family. Why don’t you get a chance to work maybe because the automation system that …

Total answers: 1

Python – Linear to Logarthmic Scale Conversion

Python – Linear to Logarthmic Scale Conversion Question: Is there a way to convert number ranges? I need to convert a linear range (0-1) to a logarithmic one (100*10^-12 – 1) so I can put a put a moveable horizontal line on a plotly plot (https://plotly.com/python/horizontal-vertical-shapes/#horizontal-and-vertical-lines-in-dash). As far as I’m aware I can’t make my …

Total answers: 1

Converting numbers to Excel column headers

Converting numbers to Excel column headers Question: This is a problem on LeetCode and it’s classified as "easy." I’ve been at this for hours, even called in a colleague. I can’t figure out the fault in my logic. I’m not looking for a completely different solution to the problem. I’d just be grateful if someone …

Total answers: 3

Custom ticks label in scientific notation while using log scale

Custom ticks label in scientific notation while using log scale Question: I’m having trouble with matplotlib (version 3.1.3) : I would like to add custom ticks and tick labels on a log scale axis while preserving scientific notation. To say it otherwise: I want to add custom ticks on a log scale axis and label …

Total answers: 2

NumPy: Logarithm with base n

NumPy: Logarithm with base n Question: From the numpy documentation on logarithms, I have found functions to take the logarithm with base e, 2, and 10: import numpy as np np.log(np.e**3) #3.0 np.log2(2**3) #3.0 np.log10(10**3) #3.0 However, how do I take the logarithm with base n (e.g. 42) in numpy? Asked By: dwitvliet || Source …

Total answers: 2

numerically stable way to multiply log probability matrices in numpy

numerically stable way to multiply log probability matrices in numpy Question: I need to take the matrix product of two NumPy matrices (or other 2d arrays) containing log probabilities. The naive way np.log(np.dot(np.exp(a), np.exp(b))) is not preferred for obvious reasons. Using from scipy.misc import logsumexp res = np.zeros((a.shape[0], b.shape[1])) for n in range(b.shape[1]): # broadcast …

Total answers: 4

python: scatter plot logarithmic scale

scatter plot logarithmic scale Question: In my code, I take the logarithm of two data series and plot them. I would like to change each tick value of the x-axis by raising it to the power of e (anti-log of natural logarithm). In other words. I want to graph the logarithms of both series but …

Total answers: 2

Logarithmic y-axis bins in python

Logarithmic y-axis bins in python Question: I’m trying to create a histogram of a data column and plot it logarithmically (y-axis) and I’m not sure why the following code does not work: import numpy as np import matplotlib.pyplot as plt data = np.loadtxt(‘foo.bar’) fig = plt.figure() ax = fig.add_subplot(111) plt.hist(data, bins=(23.0, 23.5,24.0,24.5,25.0,25.5,26.0,26.5,27.0,27.5,28.0)) ax.set_xlim(23.5, 28) ax.set_ylim(0, …

Total answers: 3