curve-fitting

scipy curve_fit error: divide by zero encountered

不羁岁月 提交于 2019-12-21 20:28:27
问题 I've been trying to fit a function to some data for a while using scipy.optimize.curve_fit: from __future__ import (print_function, division, unicode_literals, absolute_import) import numpy as np from scipy.optimize import curve_fit import matplotlib.pyplot as mpl x = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) y = np.array([20.8, 20.9, 22.9, 25.2, 26.9, 28.3, 29.5, 30.7, 31.8, 32.9, 34.0, 35.3, 36.4, 37.5, 38.6, 39

Linear curve fitting with errors

霸气de小男生 提交于 2019-12-21 11:54:15
问题 I was looking for a way to perform a linear curve fit in Javascript. I found several libraries, but they don't propagate errors. What I mean is, I have data and associated measurement errors, like: x = [ 1.0 +/- 0.1, 2.0 +/- 0.1, 3.1 +/- 0.2, 4.0 +/- 0.2 ] y = [ 2.1 +/- 0.2, 4.0 +/- 0.1, 5.8 +/- 0.4, 8.0 +/- 0.1 ] Where my notation a +/- b means { value : a, error : b } . I want to fit this into y = mx + b , and find m and b with their propagated errors. I know the Least Square Method

Gaussian fit in C#

怎甘沉沦 提交于 2019-12-21 05:38:12
问题 In a project I'm working on I need to obtain a Gaussian fit from a set of points - needing mean and variance for some processing, and possibly an error degree (or accuracy level) to let me figure out if the set of points really have a normal distribution. I've found this question but it is limited to 3 points only - whereas I need a fit that can work with any number of points. What I need is similar to the labview Gaussian Peak Fit I have looked at mathdotnet and aforge.net (using both in the

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

我与影子孤独终老i 提交于 2019-12-21 04:22:17
问题 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

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

风格不统一 提交于 2019-12-21 02:51:18
问题 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

Sine curve fit using lm and nls in R

♀尐吖头ヾ 提交于 2019-12-20 14:45:12
问题 I am a beginner in curve fitting and several posts on Stackoverflow really helped me. I tried to fit a sine curve to my data using lm and nls but both methods show a strange fit as shown below. Could anyone point out where I went wrong. I would suspect something to do with time but could not get it right. My data can be accessed from here. data <- read.table(file="900days.txt", header=TRUE, sep="") time<-data$time temperature<-data$temperature #lm fitting xc<-cos(2*pi*time/366) xs<-sin(2*pi

shape-preserving piecewise cubic interpolation for 3D curve in python

久未见 提交于 2019-12-20 14:01:40
问题 I have a curve in 3D space. I want to use a shape-preserving piecewise cubic interpolation on it similar to pchip in matlab. I researched functions provided in scipy.interpolate, e.g. interp2d, but the functions work for some curve structures and not the data points I have. Any ideas of how to do it? Here are the data points: x,y,z 0,0,0 0,0,98.43 0,0,196.85 0,0,295.28 0,0,393.7 0,0,492.13 0,0,590.55 0,0,656.17 0,0,688.98 0,0,787.4 0,0,885.83 0,0,984.25 0,0,1082.68 0,0,1181.1 0,0,1227.3 0,0

On the issue of automatic time series fitting using R

人盡茶涼 提交于 2019-12-20 09:45:54
问题 we have to fit about 2000 or odd time series every month, they have very idiosyncratic behavior in particular, some are arma/arima, some are ewma, some are arch/garch with or without seasonality and/or trend (only thing in common is the time series aspect). one can in theory build ensemble model with aic or bic criterion to choose the best fit model but is the community aware of any library which attempts to solve this problem? Google made me aware of the below one by Rob J Hyndman link but

curve fitting estimate parameter - inverse square law

↘锁芯ラ 提交于 2019-12-20 06:32:14
问题 I want to make a plot force vs position (for coulomb's law) and estimate the constant e0. I have the values of charges , q1=1,q2=1. I have for example the position=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1]; force=[0.08,0.015,0.013,0.0062,0.0016,0.00519,-0.00159,0.00118,... 0.0061,0.00155,0.00143]; Coulomb is F= (1/4*pi*e0) * q1*q2/r^2. So, it is in the form: y=ax^-m , where a= (q1*q2/4*pi*e0) I am doing: p=polyfit(-log10(position),log10(force),1); % I am not sure about '1' and minus m=p(1

Fit curve to points when only x-value of y-peak is known

妖精的绣舞 提交于 2019-12-20 05:43:11
问题 I've got a bit of a weird set of conditions I need to fit a curve to. I've tried looking it up elsewhere but I'm not even sure I'm using the right lingo. Any help is much appreciated. I'm trying to fit a polynomial curve to a set of four points. Three of the points are known, but the fourth one is a little tricky. I have the x value for the maximum y value, but I don't know what the maximum y value is. For example, let's say there are known points at (0,0), (1,1), and (4,0). The maximum y