1,050 questions
3
votes
2
answers
234
views
C treating variable declared to be a double as an int
I am trying to solve a problem posed in this question which asks that a program be written that calculates logarithms of numbers without including <math.h>.
I wrote the following program:
#...
-4
votes
1
answer
101
views
Adding pre-existing log equation to plot
I have a dataset in R that I've already plotted and fitted a logarithmic model to. I'd like to add an additional line on the graph comparing the logarithmic model to a different log equation that I ...
0
votes
1
answer
113
views
PyPlot's ylim and yticks change for no reason
I am following some online code to add major yticks to a bar chart. However, I'm finding that the major yticks and the ylim changes for no reason, even though I don't add new major yticks:
import ...
3
votes
2
answers
130
views
Log-shift transformation does not squish the data
When I plot a density using geom_spatraster, there's a particularly prominent peak that's 'bright' in the visualization. This spike skews the color scale, compressing the representation of other data ...
0
votes
2
answers
156
views
how to approximate 2^x and log2(x) where x is an FP number [closed]
I have 2 approximations for both functions, however the log2(x) takes in an FP number, and outputs a fixed point number; and the 2^x takes in an integer, and outputs a floating point number.
the ...
2
votes
1
answer
72
views
Fitting a function to exponentially decreasing numbers: Ensuring equal weight for each data point
So this question is based on a biochemical experiment. For those who know a bit about biochemistry it is an enzyme kinetics experiment. I have a dilution series of an activator (a or x) and am ...
0
votes
1
answer
34
views
Matplotlib does not consistently transform plotted elements with plt.xscale('log')
When plotting data, vertical line gets incorrectly transformed by matplotlib. With linear x axis, my curve and the vertical line pointing to a specific location on the curve match perfectly.
After ...
0
votes
2
answers
91
views
How to avoid inaccuracies in logarithms? [duplicate]
I will show you my problem with the help of this code:
from math import log
print(log(1000000, 10))
The result is:
5.999999999999999
I perfectly know that the problem occurs because computers use ...
2
votes
2
answers
189
views
Approximating logarithm using harmonic mean
Here is a function to approximate log10(x+1) for (x+1) < ~1.2:
a = 1.097
b = 0.085
c = 2.31
ans = 1 / (a - b*x + c/x)
It should look like that:
It works by adjusting harmonic mean to match log10,...
1
vote
1
answer
93
views
How would i write a function similiar to np.logspace but with a given first interval and a flexible base?
I am trying to write a function that returns an array that has in the first section linearly increasing elements and in the second section ever increasing distances between the elements. As inputs, I ...
0
votes
0
answers
99
views
Cartopy add-geometries with log-normal values shows too light colours
I am trying to plot data (.csv) per municipality (.shp) on a map from Scandinavia using contourf. This data has a big range in values (see list all the way at the bottom), for which I use a log-scale ...
1
vote
2
answers
205
views
Show '1' (10^0) on a ggplot2 histogram having a log10-transformed y axis
I am trying to plot a histogram using ggplot2, in which the counts can span a very large range. So, I decided to try to transform the y axis to log10 scale. This is working well, except for values of ...
1
vote
1
answer
51
views
The means from stats_summary on my bar plot with a y-axis in log scale are incorrect
I am wanting to make a bar plot, with error bars representing standard deviations and an overlay of a scatter plot to show individual data points. The data is microbial count data and there are 2 ...
0
votes
1
answer
161
views
Map linear data points to logarithmic data points
How can I map linear data points to logarithmic data points?
This is different from Map a linear scale to a logarithmic one with both scales having variable min/max and Convert Linear scale to ...
1
vote
0
answers
82
views
KDE for a logarithmic data in plotly
I'm trying to use plotly violin plot for a logarithmic data set with positive values only.
when I use the regular violin aka:
fig= go.Figure()
fig.add_trace(go.Violin(x=last_value, line_color=color, ...
0
votes
0
answers
391
views
Customizing Y-axis Major Ticks on Symlog Scale
I am working on a boxplot in Python using Seaborn and Matplotlib where the Y-axis is set to a symmetrical logarithmic scale. I'm attempting to place major ticks at specific intervals using a custom ...
-1
votes
3
answers
242
views
Summation of log time complexities
What is O(logn) + O(2log(n/2)) + O(4log(n/4)) ... + O(nlog1) ?
I think it is O(nlogn) . Please clarify if I am correct or not.
The recurrence relation I am trying to solve here is T(n)=2T(n/2)+ log(n),...
0
votes
0
answers
46
views
what is wrong with this logarithm code? (new to coding) [duplicate]
int starting ;
int ending ;
float x;
do
{ starting = get_int (" Starting population of llamas? "); }
while (starting < 12);
do
{ ending = get_int (" Ending population of llamas? &...
1
vote
1
answer
124
views
fitting a log curve using lmfit and scipy.curve_fit - not working! (Dataset: The Ultimate Film Statistics Dataset - for ML)
this dataset is great! However I am stuck… there seems to be a logarithmic relationship between number of Votes (x axis) and Approval Index(y axis), but I tried using both scipy.curve_fit as well as ...
1
vote
1
answer
107
views
Some minor tick labels do not show on log axis
I'm trying to customize major and minor tick labels on a log y axis where all labels are in %g format.
When the minor 2s and 5s are labeled, and both major and minor grid lines are showing and the ...
0
votes
1
answer
24
views
How to bin into the degree in a logarithm scale in a Pandas dataframe?
I want to bin as efficiently as possible numbers of a Pandas dataframe column into the degree in a logarithm scale.
By logarithm scale, I mean the way to display numbers over a power(unit, degree) ...
0
votes
2
answers
634
views
Python Fitting polynomial to natural log, then reversing the transformation back into non-log space?
I'm trying to create a smooth function to represent some data I am working with. Trouble is the data is pretty noisy, and simply using the least squares method to create a polynomial line of best fit ...
1
vote
1
answer
239
views
Mismatch between Matlab log and Numpy np.log
While rewriting an old Matlab code to NumPy, I noticed differences in logarithmic calculation.
In NumPy, I use np.log, Matlab uses log function.
b = [1 1 2 3 5 1 1];
p = b ./ sum(b);
sprintf('log(%....
2
votes
1
answer
104
views
Logarithm of a positive number result in minus infinity python
I have this image:
HI00008918.png
I want to apply a logarithmic function (f(x) = (1/a)*log(x + 1), where a = 0.01) on the image...
So this is the code:
import numpy as np
import matplotlib.pyplot as ...
1
vote
2
answers
110
views
Intersection of two lines in semi-logarithmic plot
Two points:
df.x <- c(0.0014, 0.0027)
df.y <- c(17.38, 22.49)
I want to know y at x==0.002.
Linear interpolation gives 19.74.
A linear plot shows the intersection:
plot(df.x, df.y, type="b&...
-2
votes
2
answers
286
views
Can one emulate bitwise arithmetic "and" or "or" using only non-bitwise operations?
Imagine we are tasked with using an idealized scientific calculator which has the following properties:
no direct support for bitwise operations, or for base conversions (eg cannot simply "...
0
votes
0
answers
378
views
Calculating a Logarithmic Equation in Excel
How do I use excel formulas to calculate a log equation I can use to project figures?
Here are the following data points:
Datapoints for LN
I have been using =LINEST(Y,X,1,1) for C and 1,2 for B with ...
0
votes
2
answers
150
views
How to auto-update ylim for nans in x due to xscale(log)
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 omitted ...
0
votes
0
answers
42
views
Save previous iteration value for comparison with next iteration
I don't know if this is the right place (at most they will close the post). Anyway, I am trying to implement the Matrix Rotation Count Algorithm explained in
this paper (in particular pages 11-12).
In ...
0
votes
1
answer
186
views
semilogy plot does not proper color y-ticks
Issue is with semilogy, not with twinx. From next code
import numpy as np
import matplotlib.pyplot as plt
def plot_me(x):
fig, ax1 = plt.subplots()
ax1.semilogy(x, color="blue")
...
2
votes
1
answer
796
views
Finding the log base 2 rounded up to integer the same as rounding up to power of two and finding the highest set bit?
Similarly, value rounded down to power of two and finding the rightmost set bit is equivalent to log base 2 rounded down to integer. Is that correct?
I thought that that would work, for any number ...
1
vote
2
answers
397
views
logarithmic axis major and minor ticks
In python's matplotlib, how can I make the logarithm x-axis ticks as the attached picture shows (i.e., major ticks with labels at every 0.5 spacing from 1 to 4.5; minor ticks without labels at every 0....
3
votes
1
answer
727
views
C++ log2 implementation for double using bit-hacking?
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 ...
0
votes
2
answers
2k
views
Logarithm to base 3 in python
I am trying to find the logarithm of a number to base 3 using python.
Here is the problem :
https://leetcode.com/problems/power-of-three/description/
I am using this code:
import math
math.log(k,3)
...
2
votes
2
answers
491
views
In R, how to impute right-censored missing data to follow the assumed distribution?
Earlier on, random imputation of left-censored data to follow the assumed distribution has been explained here in Stack Overflow. Than can be easily achieved with the censlm package.
But what if I ...
1
vote
1
answer
860
views
How to display all major and minor tick labels with log scale [duplicate]
I am trying to plot an xy-graph whose x-axis is logarithmic. I did that using this command:
import matplotlib as plt
plt.plot(X,Y)
plt.xscale('log')
The x-axis is logarithmic, but only values which ...
1
vote
2
answers
277
views
How can I get log value of a negative value?
I have a function of the following table.
input: e
output: 1 << e
0
1
1
2
...
...
31
-2147483648
static int value(int exponent) {
return 1 << exponent;
}
Now, how can I get the ...
1
vote
1
answer
46
views
calculate intersection on for logarithmic x axis with R
Hey everyone I am trying to show the intersection of a geom_line on a logarithmic x axis. However, I always miss the geom line. Here's what I do:
library(data.table)
library(ggplot2)
x <- c(0.1, 0....
0
votes
0
answers
241
views
How to create a logarithmic scale for the x and y axis of a heat map with Python
Im having some issues creating a heatmap using plt.imshow() with specific axes that I want to display in a logarithmic scale. I tried different methods, but the image doesn't seem to work when i try ...
0
votes
1
answer
256
views
How can I convert a data table to its logarithm (+1, base 2) form in R while ignoring non-numeric values?
I'm trying to convert the values of a data table to its log(a)+1 (base 2) into a transformed data table in R. But the first two columns of the data tables are not numbers so I need to exclude them ...
3
votes
1
answer
1k
views
How to implement vectorize "exp" and "log" base-2 functions using AVX-512
For a game that I'm working on - need the ability to run million of "exp" calls on vectors. Basically
void vector_exp(const double *x, const double *result, int n)
{
for (int i=0 ; i<...
0
votes
1
answer
86
views
Score models based on log, quadratic, or linear fit on a 0-1 scale
I am looking for a way to score model fits of x,y data on a scale from 0 to 1, depending on which model the data best fit.
If data fit a linear model best, the score would come out close to 1. Log ...
0
votes
1
answer
194
views
scatterplot skips major ticks with log scale even with manual spacing [duplicate]
I'm plotting points on a log-log scatterplot with matplotlib. The x coordinate of these points rises twice as fast (exponentially speaking) than the y coordinate, which means that the x axis is twice ...
-2
votes
1
answer
149
views
Calculating log to the base 2 in java gives inaccurate results [duplicate]
Consider this program to determine if a given number is a power of 2.
class Solution{
// Function to check if given number n is a power of two.
public static boolean isPowerofTwo(long n){
...
1
vote
0
answers
39
views
How to plot a function that contain logarithm
I am a beginner, I try to plot the absolute square of a function that contain logarithm first I had an error saying:
Only size-1 arrays can be converted to Python scalars.
Then I tried to fix it by ...
0
votes
1
answer
741
views
Logarithms in sympy
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 ...
0
votes
1
answer
323
views
How to plot a dashed line when plotting on a logarithmic scale in R
I am plotting a dataset in R, and have set the y-axis to a log-scale.
My data splits into to trends which I have modelled, and added as trendlines to the chart. When using the simple lines() command, ...
23
votes
3
answers
14k
views
Why does the integer representation of a floating point number offer a piecewise linear approximation to the logarithm?
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 ...
1
vote
0
answers
391
views
Plotting Polar Plots with logarithmic R-Scale using matplotlib
I need to plot antenna radiation pattern. For this i need a logarithmic polar plot.
The Problem is, that matplotlib doesn't support the log polar plot properly.
The data for the radiation pattern is ...
0
votes
1
answer
785
views
How to evenly space the grid on a matplotlib log scale
How can I set the scale of a log-scaled axis in matplotlib to show values less than base^1 and space them evenly?
Example:
I have a scale that looks like this:
But I want a scale that looks like this:...