logarithm Questions
7
Solved
I'm trying to implement a multiclass logistic regression classifier that distinguishes between k different classes.
This is my code.
import numpy as np
from scipy.special import expit
def cost(...
Rodriques asked 30/6, 2016 at 13:57
7
I want to plot a graph with one logarithmic axis using matplotlib.
Sample program:
import matplotlib.pyplot as plt
a = [pow(10, i) for i in range(10)] # exponential
fig = plt.figure()
ax = fig.add_...
Leia asked 21/4, 2009 at 18:0
2
Solved
I am plotting my data (x,y) and want to show the x-axis in logscale. Because there are some negative values in x, the log10 can not be computed for all. This results in nans which are simply omitte...
Terror asked 12/10, 2023 at 3:49
1
I am aware I can use log2 from cmath in C++, but I wanted to implement an efficient way for learning purposes.
I have seen a bunch of questions that are relevant, but none of them gives a fast impl...
3
Solved
This earlier question addresses some of the factors that might cause an algorithm to have O(log n) complexity.
What would cause an algorithm to have time complexity O(log log n)?
Papaw asked 9/5, 2013 at 22:13
7
Solved
Today I needed a cheap log10() function, of which I only used the int part. Assuming the result is floored, so the log10() of 999 would be 2. Would it be beneficial writing a function myself? And i...
Yamashita asked 17/9, 2014 at 13:59
7
Solved
This is my first course in data structures and every lecture / TA lecture , we talk about O(log(n)) . This is probably a dumb question but I'd appreciate if someone can explain to me exactly what d...
Dispirited asked 29/4, 2012 at 3:57
2
Solved
I am using heatmap from Plotly. I want to use a logarithmic scale for the color but cannot find how to do so. Here is a MWE:
import plotly.graph_objects as go
import numpy as np
z = [[1e-4,1e-3,1e...
Conifer asked 13/7, 2021 at 20:5
6
Solved
In python, how can you check if a number n is an exact power of base b?
Note: it needs to be generalized to any base which is given as a parameter.
Here is what I got:
Assume n and base are inte...
6
Solved
It seems that the set_xticks is not working in log scale:
from matplotlib import pyplot as plt
fig1, ax1 = plt.subplots()
ax1.plot([10, 100, 1000], [1,2,3])
ax1.set_xscale('log')
ax1.set_xticks([2...
Tadpole asked 25/1, 2013 at 20:46
4
Solved
I need to compute the log base 2 of a number in C but I cannot use the math library. The answer doesn't need to be exact, just to the closest int. I've thought about it and I know I could just use ...
Hyehyena asked 8/2, 2013 at 6:57
4
Solved
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
dat...
Robison asked 30/7, 2013 at 16:18
3
Solved
If you were reading news about developments in graphics in the 1990s, you might have followed Jim Blinn's column in IEEE Computer Graphics & Applications, "Jim Blinn's corner." In the...
Haase asked 17/3, 2023 at 21:26
2
Solved
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
How...
8
Solved
We find various tricks to replace std::sqrt (Timing Square Root) and some for std::exp (Using Faster Exponential Approximation) , but I find nothing to replace std::log.
It's part of loops in my pr...
Primo asked 2/10, 2016 at 20:27
4
Solved
I am trying to calculate the length of an Integer in Haskell, using the fact that the length is equal to truncate (log10(x)+1).
Using Integers I created:
len :: Integer -> Integer
len i = toIn...
Columbous asked 10/11, 2014 at 12:43
3
Solved
I am generating 2D arrays on log-spaced axes (for instance, the x pixel coordinates are generated using logspace(log10(0.95), log10(2.08), n).
I want to display the image using a plain old imshow,...
Johen asked 15/7, 2012 at 1:56
4
Solved
I have a short program here:
Given any n:
i = 0;
while (i < n) {
k = 2;
while (k < n) {
sum += a[j] * b[k]
k = k * k;
}
i++;
}
The asymptotic running time of this is O(n log log n). ...
1
I need to accurately calculate where a and b
are both integers. If I simply use typical change of base formula with floating point math functions I wind up with errors due to rounding error.
3
Solved
I'm dealing with the BigInteger class with numbers in the order of 2 raised to the power 10,000,000.
The BigInteger Log function is now the most expensive function in my algorithm and I am despera...
Cuttlebone asked 17/8, 2012 at 10:4
6
Solved
Is there a way to get the logarithm of a BigInt in JavaScript?
With normal numbers, you would use this code:
const largeNumber = 1000;
const result = Math.log(largeNumber);
However, I need to work...
Orban asked 16/12, 2021 at 16:16
10
Solved
How should I compute log to the base two in python. Eg. I have this equation where I am using log base 2
import math
e = -(t/T)* math.log((t/T)[, 2])
6
Solved
How can I compute a base 2 logarithm without using the built-in math functions in C#?
I use Math.Log and BigInteger.Log repeatedly in an application millions of times and it becomes painfully slow...
6
Solved
I have a slider with values ranging from 0 to 100.
I want to map them to a range from 100 to 10,000,000.
I've seen some functions scattered around the net but they're all in C++.
I need it in Ja...
Unlimber asked 10/5, 2009 at 22:16
5
Solved
Is there any logarithm function implemented in the GMP library?
1 Next >
© 2022 - 2024 — McMap. All rights reserved.