curve-fitting

Plot digitization - scraping sample values from an image of a graph

十年热恋 提交于 2019-12-03 12:58:50
This isn't really "OCR", since it's not recognizing characters, but it's the same idea applied to curves. Anyone know of an image-processing library or established algorithm for retrieving the values from a (raster) plot image? For instance, in this graph, it's hard for me to read exact values with my eyes because there's such gaps between gridlines: I can use a straight edge or whatever, but it's still going to be error-prone. It would be great if there were software that could just take a screenshot of any old graph and automatically convert it into a table of values or a function that could

Stretching out an array

左心房为你撑大大i 提交于 2019-12-03 12:56:24
I've got a vector of samples that form a curve. Let's imagine there are 1000 points in it. If I want to stretch it to fill 1500 points, what is the simplest algorithm that gives decent results? I'm looking for something that is just a few lines of C/C++. I'll always want to increase the size of the vector, and the new vector can be anywhere from 1.1x to 50x the size of the current vector. Thanks! Here's C++ for linear and quadratic interpolation. interp1( 5.3, a, n ) is a[5] + .3 * (a[6] - a[5]), .3 of the way from a[5] to a[6]; interp1array( a, 1000, b, 1500 ) would stretch a to b . interp2(

Pass tuple as input argument for scipy.optimize.curve_fit

与世无争的帅哥 提交于 2019-12-03 12:42:24
I have the following code: import numpy as np from scipy.optimize import curve_fit def func(x, p): return p[0] + p[1] + x popt, pcov = curve_fit(func, np.arange(10), np.arange(10), p0=(0, 0)) It will raise TypeError: func() takes exactly 2 arguments (3 given) . Well, that sounds fair - curve_fit unpact the (0, 0) to be two scalar inputs. So I tried this: popt, pcov = curve_fit(func, np.arange(10), np.arange(10), p0=((0, 0),)) Again, it said: ValueError: object too deep for desired array If I left it as default (not specifying p0): popt, pcov = curve_fit(func, np.arange(10), np.arange(10)) It

How can I fit a gaussian curve in python?

本秂侑毒 提交于 2019-12-03 12:00:56
问题 I'm given an array and when I plot it I get a gaussian shape with some noise. I want to fit the gaussian. This is what I already have but when I plot this I do not get a fitted gaussian, instead I just get a straight line. I've tried this many different ways and I just can't figure it out. random_sample=norm.rvs(h) parameters = norm.fit(h) fitted_pdf = norm.pdf(f, loc = parameters[0], scale = parameters[1]) normal_pdf = norm.pdf(f) plt.plot(f,fitted_pdf,"green") plt.plot(f, normal_pdf, "red")

Find bezier control-points for curve passing through N points

前提是你 提交于 2019-12-03 11:45:02
问题 Considering the following nice solution for finding cubic Bézier control points for a curve passing through 4 points: How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA Cubic Bezier 4-point Interpolation I wonder, if there is a straightforward extension to this for making the Bézier curve pass through N points, for N > 2 and maybe N ≤ 20? 回答1: This is a really old question, but I'm leaving this here for people who have the same question in the

Looking for C/C++ library calculating max of Gaussian curve using discrete values

假如想象 提交于 2019-12-03 10:08:14
I have some discrete values and assumption, that these values lie on a Gaussian curve. There should be an algorithm for max-calculation using only 3 discrete values. Do you know any library or code in C/C++ implementing this calculation? Thank you! P.S.: The original task is auto-focus implementation. I move a (microscope) camera and capture the pictures in different positions. The position having most different colors should have best focus. EDIT This was long time ago :-( I'just wanted to remove this question, but left it respecting the good answer. Matteo Italia You have three points that

Curve Fitting 3D data set

余生长醉 提交于 2019-12-03 10:03:08
问题 The curve-fitting problem for 2D data is well known (LOWESS, etc.) but given a set of 3D data points, how do I fit a 3D curve (eg. a smoothing/regression spline) to this data? MORE: I'm trying to find a curve, fitting the data provided by vectors X,Y,Z which have no known relation. Essentially, I have a 3D point cloud, and need to find a 3D trendline. MORE: I apologize for the ambiguity. I tried several approaches (I still haven't tried modifying the linear fit) and a random NN seems to work

Python-load data and do multi Gaussian fit

北战南征 提交于 2019-12-03 09:45:21
问题 I've been looking for a way to do multiple Gaussian fitting to my data. Most of the examples I've found so far use a normal distribution to make random numbers. But I am interested in looking at the plot of my data and checking if there are 1-3 peaks. I can do this for one peak, but I don't know how to do it for more. For example, I have this data: http://www.filedropper.com/data_11 I have tried using lmfit, and of course scipy, but with no nice results. Thanks for any help! 回答1: Simply make

Fitting sigmoid to data

天涯浪子 提交于 2019-12-03 09:34:58
问题 There are many curve fitting and interpolation tools like polyfit (or even this nice logfit toolbox I found here), but I can't seem to find anything that will fit a sigmoid function to my x-y data. Does such a tool exist or do I need to make my own? 回答1: If you have the Statistics Toolbox installed, you can use nonlinear regression with nlinfit: sigfunc = @(A, x)(A(1) ./ (A(2) + exp(-x))); A0 = ones(size(A)); %// Initial values fed into the iterative algorithm A_fit = nlinfit(x, y, sigfunc,

How to estimate the best fitting function to a scatter plot in R?

ε祈祈猫儿з 提交于 2019-12-03 08:47:13
I have scatterplot of two variables, for instance this: x<-c(0.108,0.111,0.113,0.116,0.118,0.121,0.123,0.126,0.128,0.131,0.133,0.136) y<-c(-6.908,-6.620,-5.681,-5.165,-4.690,-4.646,-3.979,-3.755,-3.564,-3.558,-3.272,-3.073) and I would like to find the function that better fits the relation between these two variables. to be precise I would like to compare the fitting of three models: linear , exponential and logarithmic . I was thinking about fitting each function to my values, calculate the likelihoods in each case and compare the AIC values. But I don't really know how or where to start.