logarithm

Fitting logarithmic curve in R

余生长醉 提交于 2021-02-07 06:57:48
问题 If I have a set of points in R that are linear I can do the following to plot the points, fit a line to them, then display the line: x=c(61,610,1037,2074,3050,4087,5002,6100,7015) y=c(0.401244, 0.844381, 1.18922, 1.93864, 2.76673, 3.52449, 4.21855, 5.04368, 5.80071) plot(x,y) Estimate = lm(y ~ x) abline(Estimate) Now, if I have a set of points that looks like a logarithmic curve fit is more appropriate such as the following: x=c(61,610,1037,2074,3050,4087,5002,6100,7015) y=c(0.974206,1.16716

Aspect ratio in semi-log plot with Matplotlib

≡放荡痞女 提交于 2021-02-04 18:55:51
问题 When I plot a function in matplotlib, the plot is framed by a rectangle. I want the ratio of the length and height of this rectangle to be given by the golden mean ,i.e., dx/dy=1.618033... If the x and y scale are linear I found this solution using google import numpy as np import matplotlib.pyplot as pl golden_mean = (np.sqrt(5)-1.0)/2.0 dy=pl.gca().get_ylim()[1]-pl.gca().get_ylim()[0] dx=pl.gca().get_xlim()[1]-pl.gca().get_xlim()[0] pl.gca().set_aspect((dx/dy)*golden_mean,adjustable='box')

How to scale the x and y axis equally by log in Seaborn?

人走茶凉 提交于 2021-02-04 07:53:01
问题 I want to create a regplot with a linear regression in Seaborn and scale both axes equally by log, such that the regression stays a straight line. An example: import matplotlib.pyplot as plt import seaborn as sns some_x=[0,1,2,3,4,5,6,7] some_y=[3,5,4,7,7,9,9,10] ax = sns.regplot(x=some_x, y=some_y, order=1) plt.ylim(0, 12) plt.xlim(0, 12) plt.show() What I get: If I scale the x and y axis by log, I would expect the regression to stay a straight line. What I tried: import matplotlib.pyplot as

Using ggplot geo_geom_histogram() with y-log-scale with zero bins

て烟熏妆下的殇ゞ 提交于 2021-01-28 00:55:55
问题 I've got a set with >10000 integers attaining values between 1 and 500. I want to plot the values in form of a histogram, however, since only a few integers attain values greater than 200, I want to use a logarithmic scale for the y-axis. A problem emerges, when one bin has a count of zero, since the logarithmic value goes to -infinity. To avoid this, I want to add a pseudocount of 1 to each bin. In a standard hist()-plot I can do this like follows: hist.data = hist(data, plot=F, breaks=30)

Ignoring negative values when using np.log(array)

帅比萌擦擦* 提交于 2021-01-21 09:18:23
问题 When taking the log of a specific column within a numpy array, i.e., logSFROIIdC = np.log(data_dC[:, 9]) the compiler returns the error: -c:13: RuntimeWarning: divide by zero encountered in log. Now, I know why this happens, i.e., log(-1) = Math Error. However, I want to be able to call something or write some code which then skips any value in the array which would cause this error, then ignoring that row altogether. Allowing that data column to be usable again. I have tried various methods

Does R have a function for the logarithm that deals with negative numeric values?

给你一囗甜甜゛ 提交于 2020-12-15 06:41:41
问题 In mathematics, the exponential and logarithm functions can be generalised from the real numbers to the complex numbers. The exponential function is generalised using Euler's formula and the logarithm is generalised to the complex logarithm. The latter allows inputs that are complex numbers or negative real numbers. Thankfully, the exponential and logarithmic function in R accommodate complex inputs. Both functions can take complex inputs and produce the appropriate exponential or logarithm

Logarithmic colorbar?

谁说胖子不能爱 提交于 2020-08-11 02:14:47
问题 I have a colormap that I have successfully modified to have the colors logarithmic, creating the dramatic changes I was seeking. However, my colorbar is still stuck correlating the wrong colors to the wrong values. Here is a picture to help As you can see, the colormap is logarithmic, but the colorbar isn't. How do I get the colorbar to be logarithmic? Code: plt.figure(dpi=plotResoulution) # resolution self._data = self.rmsArray[:, :, plotTimeStep] plt.pcolor(self._data, norm = colors.LogNorm

Very fast approximate Logarithm (natural log) function in C++?

痞子三分冷 提交于 2020-07-05 02:52:07
问题 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 program and its called multiple times and while exp and sqrt were optimized, Intel VTune now suggest me to optimize std::log , after that it seems that only my design choices will be limiting. For now I use a 3rd order taylor approximation of ln(1+x) with x between -0.5 and +0.5 (90% of the case for

Logarithm Algorithm

折月煮酒 提交于 2020-05-09 18:17:47
问题 I need to evaluate a logarithm of any base, it does not matter, to some precision. Is there an algorithm for this? I program in Java, so I'm fine with Java code. How to find a binary logarithm very fast? (O(1) at best) might be able to answer my question, but I don't understand it. Can it be clarified? 回答1: Use this identity: log b (n) = log e (n) / log e (b) Where log can be a logarithm function in any base, n is the number and b is the base. For example, in Java this will find the base-2