curve-fitting

ggplot2 stat_function with calculated argument for different data subset inside a facet_grid

帅比萌擦擦* 提交于 2019-12-09 06:59:47
问题 I have a follow up question to how to pass fitdistr calculated args to stat_function (see here for context). My data frame is like that (see below for full data set): > str(small_data) 'data.frame': 1032 obs. of 3 variables: $ Exp: Factor w/ 6 levels "1L","2L","3L",..: 1 1 1 1 1 1 1 1 1 1 ... $ t : num 0 0 0 0 0 0 0 0 0 0 ... $ int: num 75.7 86.1 76.3 82.3 98.3 ... I would like to plot a facet_grid grouped by Exp and t showing the density histogram of int as well as plot the fitted log-normal

Fitting binned lognormal data in Python

北慕城南 提交于 2019-12-09 01:47:27
问题 I have a range of particle size distribution data arranged by percentage volume fraction, like so:; size % 6.68 0.05 9.92 1.15 etc. I need to fit this data to a lognormal distribution, which I planned to do using python's stats.lognorm.fit function, but this seems to expect the input as an array of variates rather than binned data, judging by what I've read. I was planning to use a for loop to iterate through the data and .extend each size entry to a placeholder array the required number of

Is there a GNU Octave equivalent for the Matlab function “fit”?

天涯浪子 提交于 2019-12-08 19:49:48
问题 My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me headaches. [c8,g8]=fit(time, sin_4_harmonic,’fourier8’) I cannot find the function "fit" in GNU Octave, which is referenced for Matlab at the following url http://www.mathworks.se/help/curvefit/fit.html Does anyone knows which package should I load, or if

What are the weight values to use in numpy polyfit and what is the error of the fit

狂风中的少年 提交于 2019-12-08 17:18:34
问题 I'm trying to do a linear fit to some data in numpy. Ex (where w is the number of samples I have for that value, i.e. for the point (x=0, y=0) I only have 1 measurement and the value of that measurement is 2.2 , but for the point (1,1) I have 2 measurements with a value of 3.5 . x = np.array([0, 1, 2, 3]) y = np.array([2.2, 3.5, 4.6, 5.2]) w = np.array([1, 2, 2, 1]) z = np.polyfit(x, y, 1, w = w) So, now the question is: is it correct to use w=w in polyfit for these cases or should I use w =

Scipy curve_fit bounds and conditions

拟墨画扇 提交于 2019-12-08 12:24:59
问题 I am trying to use curve_fit to fit some data. it is working great, I would just like to improve the fit with additional parameters to match assumptions (such as mechanical efficiency cannot be greater than 100% etc) y_data = [0.90 0.90 0.90 0.90 0.90 0.90 0.90 1.30 1.30 1.30 1.30 1.20 1.65 1.65 1.65 1.65 1.65 1.65 1.80 1.80 1.80 1.80 1.80 1.80 1.80 1.80 1.80 3.50 6.60 6.60 6.70 6.70 6.70 6.70 6.70 8.50 12.70] # I am aware this does not have commas x_data = [0.38 0.38 0.38 0.38 0.38 0.38 0.38

Set parameter expression that contains the independent variable in python lmfit

坚强是说给别人听的谎言 提交于 2019-12-08 09:34:59
问题 I have dictionary of parameters with unknown number of those parameters (comes from other function), I looped through the dictionary to add its components to an lmfit models as follows: from lmfit import Parameters fit_params = Parameters() for params_name in dict.keys(): current_param = dict[param_name] fit_params.add(param_name) I wanted to add expression to each parameter with fit_params[param_name].set(expr = 'some_expression_in_function_of_x') where x is my independent variable, when

Selecting Percentile curves using gamlss::lms in R

自作多情 提交于 2019-12-08 08:39:17
问题 I am using example code from gamlss package to draw percentile curves: library(gamlss) data(abdom) lms(y,x , data=abdom, n.cyc=30) It is drawing its own set of percentile curves. How can I choose to draw only 10th, 50th and 90th percentile curves? Also I want to avoid plotting of points so that only curves are drawn. Thanks for your help. 回答1: It's always a good idea to read the help pages: > centiles(h,xvar=abdom$x, cent=c(10,50,90), points=FALSE) % of cases below 10 centile is 8.688525 % of

how to find 50% point after curve fitting using numpy

浪子不回头ぞ 提交于 2019-12-08 08:30:28
问题 I have used numpy in python to fit my data to a sigmoidal curve. How can I find the vaue for X at y=50% point in the curve after the data is fit to the curve enter code here`import numpy as np enter code here`import pylab from scipy.optimize import curve_fit def sigmoid(x, x0, k): y = 1 / (1 + np.exp(-k*(x-x0))) return y xdata = np.array([0.0, 1.0, 3.0, 4.3, 7.0, 8.0, 8.5, 10.0, 12.0]) ydata = np.array([0.01, 0.02, 0.04, 0.11, 0.43, 0.7, 0.89, 0.95, 0.99]) popt, pcov = curve_fit(sigmoid,

Fit poisson distribution to data

旧巷老猫 提交于 2019-12-08 07:42:34
问题 I have plotted a histogram and would like to fit a poisson distribution to the histogram. To do this, I have passed the x and y histogram coordinate vector to the poissfit() function to estimate lambda. For example, here is what I've done: expecteddata = cat(2,x,y) [l,lci] = poissfit(expecteddata) My output looks like so: l = 44.3766 0.0130 lci = 42.8887 0.0003 45.8645 0.0724 I'm assuming the the lambda I'm interested in for plotting would be 0.013 (I think my lambda is so small because my

Fit a logarithmic curve to data points and extrapolate out in numpy

只谈情不闲聊 提交于 2019-12-08 07:35:39
问题 I have a set of data points (x and y in the code). I would like to plot these points, and fit a curve to them that shows what value of x would be required to make y = 100.0 (y values are percentages). Here is what I have tried, but my curve is a polynomial of degree 3 (which I know is wrong). To me, the data looks logarithmic, but I do now know how to polyfit a logarithmic curve to my data. import numpy as np import matplotlib.pyplot as plt x = np.array([4,8,15,29,58,116,231,462,924,1848]) y