Advanced Curve Fitting Webinar

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay welcome all to this webinar on advanced curve fitting in origin my name is ishwar iyer today i'm also joined by my colleagues zheng shah and jennifer swift they are panelists so during the webinar feel free to type questions in the q a window to ask specific technical questions or use the chat window for general comments please don't send a private chat to the host that is to me i may not notice it in time so please send the chat to everyone to the panelists so my colleagues can help as well i will try monitor your questions as well as we go along and try to answer them this gets asked often we will share this project and we will share the recording you may already know that on origin lab website if we go to originlab.com under support there is a link to webinars and if i click that link it will take me to a page where you can see a list of upcoming webinars so today's webinar there is another one at 2pm on advanced peak analysis by my colleague james chen and next friday importing data and batch plotting but there's lots more if you click you will see that we have the schedule for up to end of august and we'll soon be adding webinars for september as well if i go back to this page you will see in the second section on the left here you'll see a link for all recorded webinars so here you'll see recordings from all of our past webinars just recently we also put up many of the webinars on youtube so one of the benefits of that let me just quickly show you for example user defined fitting functions how to define a user defined fitting function if i click on the youtube link it goes to the youtube page and i'm gonna just pause it uh what i wanted to show was if you click more you'll see that we have broken up the video into sections so if you come to any of these recordings that are on youtube and you just want to see how to perform function with integration you can just click on that timestamp and the video will skip to that section so you don't have to wait to see where does function with integration start so my colleague jennifer swix spent a lot of time doing this on youtube so much appreciated so this would be very useful for all of you i hope in this webinar i am assuming that you are fairly familiar with curve fitting in origin if you are new to origin i would recommend that you go back to the recorded webinars and find one of the old previous recordings on curve fitting so if i scroll down here i can find many recordings here you can search through there is advanced curve fitting that we have done before okay there is curve fitting basics so here's the one this is not on youtube yet but you can preview this later if you are new to curve fitting and we will be sharing this recording as well so you may want to go back and review the basic curve fitting and then view the recording of this webinar okay and towards the end i'll also show you what's coming up in version 2021 i'm using version 2020b which is our current released version which was released in april and 2021 will be coming end of october and in that version we are making significant improvements to python embedded python in origin i'll talk about that later when we get to it and that really opens doors for performing curve fitting beyond what's available in origin and origin pro okay one other note that some of the features i show here are available only in pro the difference between origin standard and origin pro is that the professional version has more advanced analysis features and all of that the differentiation is available on our website for you to look at okay so today's agenda i am going to work through multiple exercises of some wants fitting tasks and for that i'm going to use tools that are available in origin but i'm also going to use apps that are freely available for download okay so as you may already know on the right side of origin we have this apps bar okay if it's not visible you can go to the view menu and turn it on if you click on the add apps icon it opens what we call the app center and from this app center you can search for function new apps you can look what are new and popular you can look for apps that you have already downloaded but are in need of an update because we published the new version and such so if i click here i have a correlation plot and image scale app which have been updated since i installed so i can click and update the apps if i want to let me focus on search tab so if i go to search i can type keywords here so for example i can type fitting and do a search and you will see that we have several free apps available for fitting i will show some of them today okay and these are all each app has a minimum version requirement just based on the nature of when they were developed and published so for instance cyclic voltammetry app 2017 sr0 fit with composite functions 2019 sr0 and such so these are all available if you have the latest version then they're all available to you of course some of them require pro just because the code is running um a code base that's in the professional version so feel free to explore this and install the apps and use them and once you install an app you can right click and place it in another tab you can create a tab yourself by right clicking and say new tab so i have put together several of the fitting apps curve fitting apps that i will be using today in a separate tab called curve fitting this just lets you organize the app so that you have quick access to it yourself and you can decide what tabs you want okay with that with that intro let's jump into some exercises i'm going to first start with fitting multiple data sets okay so in this worksheet i have four peak data and i have created a couple of graphs they are just duplicate graphs i just want to show you different ways of fitting this data so let me double click and pop up this graph okay as you know a graph can be a floating window or it can be embedded in a workday just like you can do it in excel there are several nice webinars on graphing that you may want to explore to see how multi-layer graphs can be managed very efficiently in origin how to set formatting and such so here i have a four panel graph so from this graph i'm going to open the non-linear curve fitter for most of the exercises today i'm going to focus on just a non-linear curve fitter okay open dialog note that there is a shortcut ctrl y to quickly bring it up so you don't have to go to the menu okay so the first thing you do in the curve fitter is choose a function i'm going to fit these data sets with the gauss function okay so under origin basic function category itself there is an entry gauss or you can choose the peak functions category which will show you all of the available peak functions in origin you can add your own functions as well so let me choose gauss and what happened if you look at the graph is that origin put an initialized curve only on one layer my layer 3 happened to be the active layer so for many operations origin typically goes to the active layer and the active data plot in my case i have only one data plot and just assumes that's what you want to fit but you can overwrite that so let's go to data selection section and here i want to show you the input data branch and if i expand that you will see there is only one range range and origin is a group of cells for example x and a y is an x y range which is typically what fitting is used for so i can click this fly out button at the input data level and say no no i want to fit all plots in the active page every plot and every layer of the page if i choose that origin then we'll go examine my graph find all the layers find all the plots and add all the ranges okay then you can drill down into the individual range and just wanted to let you know you can restrict the fitting by the row index such as from row 10 to row 50 or by x by typing an actual x value okay if you have some spectra and you want to fit only a certain part of the data there are examples of this in the basic curve fitting webinar so i'm not going to go into that at length today so now that i have chosen all of my data data and chosen my function at this point i can simply hit fit and origin will go through and fit them okay and as you know with any operation such as curve fitting or statistics or anova or whatever um you origin creates a detailed report so if i go back to my book here is the report and let's look at that report so here is a parameter table for peaks one two three and four okay let me collapse that and this is statistics table so you'll see that origin reported a separate statement for each data set so what just happened is that origin took each curve and fitted it separately fitted curve one then moved to color two then curve three then curve four that so they have all been fitted independently okay we call this independent mode but consolidated report all the report got put together in one sheet but each was fitted separately so if you then go look at the summary you will see that each value is unique nothing was shared okay so that's one mode of fitting but what if you wanted to take this data and perform a global fitting where you want to share some parameter let's say in this case i want to share the width parameter i want to force all of the fifth bits to have the same width i may know a priori from my measurement that they should all be the same width more or less so let's take this graph i'm going to which is just a copy of the previous graph and i'm going to hit ctrl y to bring up the dialog again and this time i'll again choose the same gauss function and i'll go to data selection and i'm going to again choose all active plots on my page so it picks up all the ranges and the initial guest curve has been placed but this time i'm going to take a look at this drop down multi data fit mode i ignored it last time the default is independent fit consolidated report as you saw but if i click here i have a global fit option so let me choose that if i choose that what happens is in the parameters tab an additional column appears for sharing so this means i can share parameters so you see for each peak there is a center width and area offset center width and area so i can go here and say i want all the widths to be the same so you see immediately the width parameter from peak 2 peak 3 and peak 4 disappear there is only one bit parameter so now origin is going to take all of the data together and then do a fit a global fit by sharing parameters so it's not going to fit individually it's going to fit it's going to jiggle all the parameters while fitting all the data sets simultaneously okay so if i click fit it'll again create a report okay just wait for a minute for the fit to go through okay now if i go back to my book there is a second report here if i now look at this report if i look at the statistics you will see that there is only one global statistic on the number of points degrees of freedom reduce chi squared and such because all the data was treated as one single data set and if you look at the summary you'll see all the width values are exactly the same because we forced the parameter to be shared across data sets so this is global fitting maybe some of your data sets it might apply to you okay questions please feel free to type in the q a in chat window let's move on to another example a pharmacology example where sometimes when you make a measurement a dose versus response you may have replicate measurement so i have three different measurements from the same experiment so one can of course take these three columns and make a mean and standard deviation there are ways to do that using for example descriptive statistics stats on rows but sometimes users want to fit the raw data not create a mean and standard deviation so let's see how to do that so i'm going to do i'm going to select all these three columns and fire up the fitter control y okay and i need to choose a function let me go to growth sigmoidal category and choose the dose response function and now you'll see there's a preview down here origin is still treating each curve independently so it's drawing three preview curves i don't want to treat it like that so let me go to the selection and this time remember because entered all the columns before bringing up the originals i want to fit out of them so it populated all three ranges i don't need to go here and select but there are options here for selecting from the worksheet selecting some dialogue and many such options so that you can add data sets so my intent right now is to do a concatenate field we call it concut next fit what that does is it takes all the data sets adds them all together as an individual data set and then it's going to fit a single data set so you'll see here that the preview already changed it's still showing the raw data okay i can overwrite that i can go to fitted curves and i can say fit the raw data but when you present the results please show to me as mean plus standard deviation so it is fitting the consolidated combined data but just representing the result as a mean and standard deviation data set and the fit curve so if i go ahead and do a fit now it's going to run through and do that concatenate fit and generate the report for me okay so if i go look at the report if i double click here you will see what we saw in the preview but now of course with the final optimize parameter okay just wanted to point out that if you are into those response fitting we have a nice assets template in the worksheet dialog new worksheet dialog so if i go to file new workbook there is a dialogue called new workbook which has many templates one of them is an assays template these are pre-configured templates that you can open and start using right away so this one has buttons for configuring your data set selecting the function executing the fit and provide a fitting graph and such i'm not going to go into the details of this but it basically can do replicate fitting we also have an enzyme kinematics fitting app if you are interested for doing uh curve fitting for farm type data okay okay somebody is asking is your project file available somewhere so i can have a hands-on practice we suggest you don't try to um run origin and follow us the same exact time we are present in the webinar that's not very productive because you will be distracted and we will have to wait for each one of you to finish step one step doesn't work well which is why we give you the project and the recording later and we always are there to help you tech support is there to help you can say i attended yada yada webinar i'm still confused about this particular tool here's my data help me okay all right moving on next example i have here data from a pharma type measurement where i was using the customer was using rather well plates and there are 96 data sets okay i want to fit them all individually one by one not a global fit just a run through fit and i don't want to create a complicated complex report with many tables and such i just want a simple table and i want the fit to happen quickly and i don't want to go into the enfit dialogue and use settings so for that purpose we co we created an app called speedy fit okay so with the workbook active let me click on that app to launch it and what it does it assumes that you're fitting all the data in the active worksheet okay that's the assumption and i have a choice of linear versus polynomial versus non-linear in my case i need a non-linear function and i need an exponential function and there are many exponential function choices asymptotic one is the default the first one alphabetic so that happens to be the appropriate function for my data that's what the customer told us so if i then click fit it will fit the first data set and it shows that did it converge then i can click the next data set button examine the next one and click fit did not converge just the nature of the data that happened to be a bad well in the plate next data okay click fit so this way i can explore my data quickly look through to see how my data is varying from one column to another and try a few fits if i need to fix some parameter or put a bound i can do all that to adjust everything then i can decide what reports do i want do i want the lower confidence level do i want the upper confidence level on the parameters do i want t value all that and once i choose that i can simply click ok origin will just zip through all the 96 columns and create a simple report for me so if i look at this report it here's the data set in the first column and here are all the values for a parameter a value standard error 95 percent lower confidence upper confidence and such also it creates another sheet where there is an embedded graph if i double click that you can see let me just move this table out of the way this table can be customized to show only the parameters that you really want to show i'm just going to put it a little bit to the side let me make the graph a little smaller okay and this graph is a template with some buttons so i can click the button here and flip through all of my data sets to see what was the final result okay not just look at the table i can interactively examine my data so this is a really cool app many customers liked it so if you have a large number of data sets that you routinely fit with the same function you might want to look at this okay moving on bounds and constraints okay sometimes when you perform fits the fit may not converge given the data and the model and you may want to go in and massage the fit by putting in certain bounds and constraints on your fit other times you may do that to keep the parameters within sensible range from your measurement and your field and what it is that you're studying you may a priori know what are valid parameters the fitting process is an iterative process it doesn't know what your data is it just tries to jiggle all the parameters to every possible value to find an optimal solution so it's the user's responsibility to go in and put bounds and constraints when the parameters don't make sense and when you want to limit the range of the parameter values so let me run through some examples here so i have exponentially decaying data i want to fit this with a two-term exponential function okay let me hit ctrl y to bring up the fitter and over here i'm going to choose exponential category and my data doesn't have any offset to it it starts at zero so i'm going to choose the simple exponential dk 2 x decay 2 function the fitter can show you the formula and the sample curves down here there are tabs for that so this just has an offset parameter no offset in the x okay so let me just fit with this there are buttons and defector fitter for various tasks such as computing chi squared single iteration multiple iteration and such let me go to the parameters tab and i'm going to click this to fit until converge so if you look at the messages tab it clearly says eight iterations were performed fit has converged the tolerance value was satisfied for the chi squared minimization everything looks good okay i have a very good r squared 0.99 okay and i have the parameters here so i have two time constants okay there's an exponential dk remember with two terms time constant one time constant two but what if i really wanted the first time constant to be the longer time constant and the second one to be the shorter and you notice one of them amplitude is larger and the other amplitude is smaller so how do i rearrange them one way to do that is i can put bounce so i can come here and say my t2 so this is the bound stamp this is a parameter stamp here is a bound step so i go to the bounds and say i want to force t1 to be greater than 5 i know it has to be greater than 5 i want to force t2 to be less than one okay i can double click through here to cycle my choices less than one okay and i can double click here again to force it to be greater than five now if i do the fill you will notice that it will flip the parameters so now the first one is the longer time constant and the second one is the shorter time constant i just wanted this order and i was able to achieve it by just putting bounce okay just a simple example of bounce what if i now want to constrain it further i know from a measurement that the second decay should be equal in amplitude of the first decay and the second time constant should be one tenth of the first time constant okay let's see how to force that so to do that i can't do that with bounce because multiple parameters are involved then i go to the code tab and i go to constraints okay so here i want to put a constraint saying a2 less than a1 times 0.5 or t2 less than t1 times 0.1 okay so let me put that in so i go here and say a2 let's let me quickly look at that a2 less than a 1 star 0.5 semicolon next line t2 less than t1 star 0.1 semicolon okay and one important thing when you do these constraints you have to enable them this check box lets you flip the on off status so you can study the effect so now if i go to the parameters and click the fit these values are closer to each other 48 and 96 right almost equal okay 0.50 and 5.05 i can go back to the code and instead of less than i can force it okay to be equal okay and now if i click fit and go look at the parameters you'll see it's exactly one half 96.13 or 48.06 5.0575 0.50 okay so just to show you the possibilities of using bounds and constraints to limit the range of parameters for your data and also for controlling the parameter values to sensible physical values that you may a priori know as appropriate okay there is an app for performing such fitting across multiple um data sets with mixed functions and such there are many such apps so i would recommend that you check out the apps and find the ones that are most appropriate for your needs okay let me see questions okay uh question is about connecting points with smooth lines that's more about a graphing task it's not really a fitting task so i suggest you review graphing tutorials okay and graphing uh webinars now let's go through some examples of forcing a data set through a certain data point this comes up often enough in tech support that we thought we will show you a few examples okay somebody's asking is there a way to fit multiple data sets with some common parameters some varying ones that's exactly what i showed in global fitting so please go back and review the recording and if that wasn't clear send your data over to tech support and we can help okay so here i'm i'm going to go through a couple of simple examples here i have a linear fit i have already performed and my data point at x equal to 0 happens to be exactly y equal to 100 and i want to force this line to go through that point with linear regression it's simple enough i can click here and do change parameters to bring back the dialog you may already be familiar with origin having these operational logs whenever you take an input and create an output that's related by an operation such as curve fitting there is a log that ties the two together i can click on the lock and bring back the dialog with the exact settings i used at the time of my analysis then i can make changes so i can go to fit control here and i can say i want the intercept fixed and i want it to go through exactly intercept of point y equal to 100 and click ok okay then you will see the fit update and the point goes through exactly 100. if i go look at my report you will see my intercept is 100 and my standard error is the missing value because i force my intercept to be fixed okay when a parameter is fixed there is no standard error okay that's a simple enough case but what if my function doesn't lend itself to a parameter that can force the curve to go through a data point so here i have a parabola fits to some data and for whatever reason i want the parabola to be to go exactly through this fifth point there isn't such a parameter in my function so what do i do so for that you can apply weighting okay you can weigh each point differently so let me add a column here to this worksheet and i am going to enter a value one for all of the uh points but the fifth point i'm going to give it some extra weight by entering say ten thousand okay so i'm saying this point is particularly important give it more weight than fitting okay nothing changed in the graph because i haven't told origin about the rating yet so let me click on the lock and do change parameters and here what i need to do is i need to go to my input okay and in my input i have the x and y chosen but i also have a y error i'm going to choose the column c that i just added as the y error then if i go to fit control it will let me decide how to treat that error do i use it as an instrumental error do i use it as direct weighting so in my case i am using direct weighting each error value is directly applicable to the data not one over square root square of the error okay so let me choose direct weighting and click ok and now the fit will update and will force that curve to go through that data point that prop appropriate to do yes or no that's your decision often customers ask for this okay so now the non-linear curve fitter also has this option and with the non-linear curve fitter there are many other chop options for error weighting inverse weighting direct weighting and such so i recommend that you look that up if you have weight waiting involved with your data and then you want to apply that weighting so in this context i just wanted to force the curve to go through a particular data point and i used weighting as a trick to do that all right moving on here i'm going to show you how to perform fit and find new x and y values okay so rather than starting from the scratch i wanted to show you this learning center dialog and this dialog can be opened from the help menu okay or by pressing the f11 key as a shortcut and this dialog comes with many examples so if you're new to origin or you just upgraded from an older version of origin to a more recent version of origin this dialog is really useful you have a tab for graph samples you can go here and review what type of plots are available for example we added parallel alluvial sankey diagrams and recent versions you can go choose all plot types and you can go here and type a keyword such as 2020b and do a search it will show you all the plot variations and new plot types that were introduced in the latest version and you can anyone open any one of them and try the same plot with your data my focus is on the analysis samples so here you have many different categories again batch plotting batch processing signal processing peak analysis my colleague james chen will be doing the peak analysis webinar at 2 pm don't miss that if you are into peak fitting so i would stay with curve fitting here and i am going to choose calibration curve and unknown samples and open that so this is a pre-configured sample and in this sample we have taken some data set and already performed a fit to show you what's possible so what i have in my raw data is some concentration of some chemical and the absorbance peak for that particular concentration value so these are all known samples i know the concentration is 0.25 i pop that into the spectrometer i did a peak analysis and my peak was 0.28 i changed my concentration to 1 i got 0.39 change to 1.5 i got 0.546 and so forth so these are all known samples so here i have already done a linear regression the green points are the data points and the red line is the regression line and then in the regression let me bring up the dialog in the linear fit dialog there is a tab called find x fine y the purpose of this tab is to let you find new x values or new y values from your data find y from x is trivial if you have a new x value how to find the y value just use the fit line and the parameters origin will do that for you i haven't checked that more interesting is find the y x value for a given new y value so in the context of this measurement let's say somebody walked up to me and gave me an unknown sample they don't know the concentration of that sample i pop that into the spectrometer i measured the peak i got the peak value which is my y but i don't know the x so and i want to know the x and i want to know it with a 95 confidence interval so when you check this box and do the analysis in origin and by the way this tab find x find y is available in the non-linear fitter as well what origin does is origin creates an additional sheet in the book called find x from y or y from x depending on what i chose so i have already put some values here okay so now let's say my colleague walks up to me and gives me a new sample and i put that in the spectrometer and my value turned out to be 0.7234 from the measurement so then origin will immediately calculate the x value and tell me that the x value is 2.5 the lower confidence level is 1.9 the upper confidence level is 3.07 so that's a very useful thing to have when you are measuring an unknown sample and this graph has just been configured to plot this exact data into the graph as blue points how to configure the graph i'm not going to go into details of that that's more of a graphing webinar okay just wanted to focus on this find x y sheet capability so that once the fitting is done you can put in new y values and calculate x values from the y values using the fifth equation as the guide okay let me know if i'm going too fast there are quite a few examples i'm running through here okay and the idea here is to give you a flavor of what's possible okay so you can then explore these features and then look at what's suitable for your data please do not chat privately with me as the host i may not be able to see it okay i recommend that you put it in the q and a window or the chat window okay all right now i am going to go move on there is i was thinking of showing you user defined fitting functions but i'm going to skip that today because that has already been done by my colleague and there is an excellent recording of that so let me just click this link to open um the web page or rather i can just go to the webpage here and just recently there was a recording a webinar on um let me find it user defined fitting functions it's already on youtube broken up by the topics and such so i recommend you go review that um i would rather focus on some other topics for the rest of the webinar today okay so let's move on and go to ranking models and this comes up often okay we get asked the question i have done a fit how do i know if this is a good fit or not and the honest answer to that is if you take one data set and fit with one function you should not really be asking the question is this a good fit there is no good statistical answer to that the more valid question is i take one data set and fit with two or more functions then i can ask the question which model is statistically more suitable for my data comparing the results so here what i have done is i have taken some exponential data and i've fitted it with a single term exponential decay the red line and a two term exponential decay the green line and you can clearly see visually that the red line did not portray my data well whereas the green line did a much better fit and you can see the r squared value improved from the red line to the green line so then the question is do i keep adding more terms what about three term exponential decay what about a four term exponential dk so to answer that question you can do a rank model okay so let's go back to the data here and there's a rank models app so let me fire that up okay and this app is free shipped with origin it's already under the fitting menu i just launched it from the app bar so the idea here is you take the input data and then you select your functions okay there are many categories here to select from i can click and select a particular category so in my case i want exponential functions and then all the exponential functions are shown i can come here and decide do i want one term two term three term do i want one term with an offset do you want to term with an offset i can choose as many as i want here then what origin does once i decide what output should be there are videos on this particular app so you can play the videos to learn more i'm quickly showing you if i click the apply button what origin is going to do is it's going to take that data set and fit it with all the functions that you asked for and then it's going to compare okay and the way to compare the best way to compare is a statistical entity quantity called bayesian information criterion okay this tool reports two criteria aic and bic a kaike information criteria and then bayesian information criteria the idea is the lower the value of bic or aic the more appropriate is the model okay so what this analysis just told us is that x dec 2 a two term exponential decay with no x offset is the best model the next best model is a two term exponential decay with an x offset a three term exponential decay is the third choice okay and the three term with an offset as well as a fourth and such so looking at this if you're not sure which of these models to use the statistical test is telling you go with x dec 2. so i just wanted to make clear that you cannot ask again make clear you cannot ask the question fitting one data set with one function is it a good thread comparing models to a single data set is the more appropriate question to ask okay all right moving on let's go to some examples of advanced fitting in pro some of the features i showed you earlier such as rank models is available only in pro this is implicit fitting surface fitting these are also available only in pro i'm going to show you quickly these examples so let's say you have a data set that has both x and y errors and you want to fit with the function that's not of the form y equal to f of x rather it's of the functional form f equal to function of x and y so for example an ellipse in many versions ago origin only had the least square minimization method level markwood method where the minimization is done in the y direction only okay some versions back we added orthogonal distance regression what this lets you do is minimize the perpendicular distance from the data point onto the fit curve so this takes into account variations in both x and y in other words it can account for errors in both x and y okay so that's why we are using in this case the orthogonal distance regression for computing the fitting for the ellipse so i'm going to go to the analysis menu and choose fitting and under fitting you will see there is a non-linear implicit curve fit it's essentially the same tool but with a function category that's only available for implicit fitting and the iterative algorithm is frozen to orthogonal distance regression just a point of node you can use the odr algorithm with regular functions of the form y equal to f of x if you have error values in x as well using the regular fitter that's available as well okay in this case i need to use both x and y and my function is the form f equal to function of x and y on the right side okay so then i can simply click fed and i can get an ellipse fit to my data okay let's move on to surface fitting uh we have a few tools for that this one came from an engineering customer they have three columns of data x y and z and they wanted to fit different orders of polynomials in x and y and find out which is the best fit so we created a tool for that called polynomial surface fit and i'm going to open that and there are several options here i can consider up to four terms in x and four terms in y and i can say rank using the base and information criteria and click ok and then origin will do all the fits and then give me a report sheet where it rates them all again using the same bic criteria and it has marked the best value the lowest value so it's telling me a polynomial with order 3 in x and order 3 in y is the best fit for this data set okay again the question to ask is not take a single polynomial instead but do multiple polynomial fits and rank them okay and this is an example of p fitting i'm going to skip this because my colleague james chen will be doing peak fitting and he may do a 2d peak fitting example okay it's possible to fit two um 2d uh peaks such as a gaussian 2d a lawrence 2d and such an origin pro as well okay let me move on and show a couple of other popular fitting questions that come up often okay oneness what if i have some data there's some transition it's linear for a certain part of the data and then it decays maybe i i'm using a catalyst or some something that controls my reaction and the behavior change there's a phase one and a phase two in origin you can freeze the data set you can chop up the data set and fit them separately but then the fitted line may not go through that point may not meet at that point so for that purpose we created a piecewise fit app which will take care of that issue okay so if i go to the piecewise fit app this app lets you choose up to three segments in your data i have only two segments now i can use the same function for all of the segments such as say a linear fit but with different slopes but in my case my first segment is polynomial line and second segment is exponential exponential decay a single term and then origin finds the x value at the intersection of the two segments automatically if you a priori know the value you can fix it or you can leave it flow and you can click fit and you know that it did a nice fit here the r squared value is very low sorry very high the chi squared value is very low uh in three in five iterations it found the fit and if i click ok it give me a nice graph and it gives you this point where the two curves meet okay and then you will get a report okay okay here's a report sheet that clearly shows which was the intersection point and what was the equation used for the first part and the second okay another question that comes up often is fitting with convolution okay so let me take a few moments to explain that when you perform a measurement with an instrument the instruments response function can distort what you are measuring so in my case i am supposed to be measuring an exponentially decaying phenomenon but my instrument happens to have a broad gaussian response it's not an imp it's a broad function with the significant width so what happens in my measurement is because of that my measured signal is distorted rather than a pure exponential i have something that looks like a peak at the beginning and then decays so essentially my measurement got convoluted with the instrument's response function how do i separate it out one way is to do deconvolution origin has a tool for that but it's not a mathematically safe thing to do because when you do deconvolution you are essentially taking fft of the signal fft of the response and doing a division and division with small numbers in the fft can blow up creating noisy results so what instead is to perform the convolution while you're fitting so you fit with an exponential function while the iterative process is going on at each step origin takes the response function and force it into the fitting process so that the fitting takes into account the response function so here is my response that a priori i know maybe the instrument maker gave it to you or you did some blank measurement or whatever to generate the response function and here is my measured signal so with this worksheet let me fire up the fit convolution app and this app assumes that my first column is x second column is the measured y and third column is my instrument response then here i can type in my function in this case i have an exponential function so i'm going to type in a star exp of minus x star tau tau for the time parameter and click outside the box then origin automatically looks at the data already has some guess values and you can see an initial curve here i can go ahead and click the fit and then it perform the fit successfully in the process of fitting convoluting the response into the fitting process okay then i can click the fit report and get my result okay of course this assumes that you have a known instrument response function this has come up often many of us for you had to code this an urgency so we decided to make that into a friendly app okay so if you go to the report sheet again you will get a standard report here's my final fit result with my parameters and my graph so here the decay constant that origin is reporting is the true exponential decay which does not um get biased by the response of the instrument because the response has already been taken into account during the fitting process all right so now i'm going to choose to fit in with python and version 2021 quickly show you what's new what's coming down the line and to end we'll come back and do a quick polling um and that's very important for us to get your feedback so we can understand from you if these webinars are useful and what webinar would you like to see in the future um so before we get into polling let me fire up 2021 and quickly show you what's coming up in october with 2021. so in origin even in the current version and a few versions before we introduced the concept of embedded python so what that means is you do not even need to go out and get python installed origin automatically installs python it's an option during the installation you can turn it off it's on by default origin installs python along with origin so python is available to use immediately what we are doing in 2021 is make the embedded python work much better by adding a package a new package for accessing origin from python for exchanging data data frames string data and all that everything much easier we are also adding capability for debugging python code managing python packages everything will be much smoother compared to what is possible in the current released version so with that said i want to show two examples one is bayesian regression okay so here i have some data i do not want to fit it with a particular function in my case i may not even know physically what the function is instead i want to use bayesian ridge model okay you can learn more about it by googling or going to the scikit learn page so what we are doing here is using a package called scikit learn from python to do the computation first let me run the code then i will show you the code so i click run it did the fit so here is a predicted value and the predicted band of the plus minus confidence values so if i click show code it's going to open code builder which is our coding environment and in this project there is a file called blr.pi that's attached which did all the work okay so this required numpy it required pandas it required scikit-learn and there is also this new package origin pro that's the package we are introducing in 2021 this is a package for interacting with origin software from python so all of the code here the fit lines are essentially these three lines that's it okay so you're raising essentially setting up a bayesian linear fit model calling the fit and calling the prediction function to get new y values for the x values the rest is all just exchanging data using data frames using pandas between origin and python to put in the data and get the data back after the effect so the coding will be much simpler it's in a more friendly platform of python that most of you may be familiar with already plus there are many many examples of python packages and python functions out there you can grab a code bring it into origin just add the interaction part of exchanging data with origin and you're good to go and we are always there to help you okay another example that my colleague james chen put together just a couple of weeks ago somebody asked how to perform a summation fit so uh it was not fitting using one of the standard functions but fitting using a summation of series so here they have a particular series and they had some specific uh constant values for the e1 e2 e3 and beginning values for g1 g2 g3 in this series and then how to fit with that so here there are some initial parameters here there are some constant parameters and the code in this case is just in the set column value so if i click on this log and do change parameters in the previous example i showed that the code was attached to the project python code can even be attached to the worksheet inside a column so we are introducing a new python function tab in the sitcom values dialog all of the code is right here this is the specific function that the user had all of their summation terms and it's simply using scipy optimize using the minimize module and scipy to do the optimization to do the computation and then just put it back into origin and it's a single line of call from origin pi dot run fit run fit as a function and it's passing column a b c and d and returning the values into column e and f for the fifth result okay so just want to give a shout out about what's coming up in 2021 if any of you are into python and you want to play with this already we have a beta release just email us and we will set you up with the beta version okay so with that said let me ask my colleague jen to bring up the polling so you can please give us your feedback um your feedback is important for us to know what topics we should cover in future um webinars okay we appreciate you taking the time to join us today this project and the recording will be available to you um early next week okay i'll leave the chat and q a open you can still ask questions and put comments in here and please answer the poll questions thank you i just wanted to give a shout out to my colleagues in tech support they are an excellent team they are there to help so when you run into a challenge with your curve fitting and you are willing to share your data and details we are more than happy to look at we also have an excellent r d team who helped to put together these apps so we are there to help you don't be shy to contact us to ask for help you
Info
Channel: OriginLab Corp.
Views: 5,821
Rating: 5 out of 5
Keywords: OriginLab, OriginPro, origin, Curve Fitting, Curve fitting in Origin, Webinar, Advanced Curve fiting, Fitting multiple datasets, rank models, surface fitting, implicit fitting, Force fit line through a point
Id: xYXqAiszC1U
Channel Id: undefined
Length: 58min 58sec (3538 seconds)
Published: Mon Aug 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.