{"id":7105,"date":"2016-10-28T11:13:25","date_gmt":"2016-10-28T15:13:25","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=7105"},"modified":"2018-12-06T21:41:44","modified_gmt":"2018-12-07T02:41:44","slug":"use-initial-formula-to-better-guess-fitting-parameter-values-from-data","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/use-initial-formula-to-better-guess-fitting-parameter-values-from-data","title":{"rendered":"Use Initial Formula to Better Guess Fitting Parameter Values from Data"},"content":{"rendered":"<p>Good parameter initialization results in fast and reliable model\/data convergence. Before Origin 2017, you can write lengthy LabTalk functions or Origin C functions to intialize parameter values based on your data but\u00a0it is still not easy for new users.<\/p>\n<p>Origin 2017 added the following ways to initialize parameter values without the need to learn\u00a0coding.<\/p>\n<ul>\n<li>Use Data\u00a0Information, such as\u00a0XMin, XMax, YMin, YMax, XatY50, Peak, Center, etc.<\/li>\n<li>Use metadata, such as column long name, comments, etc. and values extracted during import<\/li>\n<\/ul>\n<p>You can also write simple math expressions with the above values.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7130\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/intro1-300x199.png\" alt=\"intro1\" width=\"778\" height=\"516\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/intro1-300x199.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/intro1-768x508.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/intro1-1024x678.png 1024w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/intro1.png 1148w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>This blog shows\u00a0a simple example of extracting metadata during import and then using it to initialize fitting parameters. Then an analysis template is setup to batch fit multiple such data files.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 1. Extract Temperature Value during Import<\/strong><\/p>\n<ol>\n<li>Open Origin\u00a0and\u00a0start a new worksheet. \u00a0Click Import wizard button (or <b>File:Import:Import Wizard<\/b> or press <b>Ctrl+3<\/b>) to open the <strong>Import Wizard<\/strong>. In the <strong>Data Source<\/strong>, select the file <strong>\\sample\\Curve Fitting\\UptakeCurve_343.txt<\/strong>. \u00a0In Import Mode, select <strong>Replace Existing Data.<\/strong> Click <strong>Next.<\/strong><br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7108\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import1-300x286.png\" alt=\"data_import1\" width=\"584\" height=\"557\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import1-300x286.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import1.png 626w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><\/li>\n<li>In the <strong>Header Lines<\/strong> page, \u00a0set\u00a0<strong>Long Names, Units, Comments<\/strong> as <strong>3, 4,<\/strong>\u00a0\u3001\u00a0<strong>1 to 1, <\/strong>respectively. Click <strong>Next.<\/strong><br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7109\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import2-300x285.png\" alt=\"data_import2\" width=\"586\" height=\"557\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import2-300x285.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import2.png 627w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/a><\/li>\n<li>In the <strong>Variable Extraction<\/strong> page, Check <strong>Specify location of variable names and values using character positions<\/strong> \u3001 <strong>Add variable to page info. <\/strong>Click Next.<br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7110\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import3-300x285.png\" alt=\"data_import3\" width=\"588\" height=\"559\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import3-300x285.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import3.png 628w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/a><\/li>\n<li>In the\u00a0<strong>Variable\u00a0Extraction by Position<\/strong> page, Under<strong> Variable<\/strong>, select H001\u00a0right to\u00a0Line and set <strong>Start<\/strong> \u3001 <strong>End<\/strong> to 13 and 15 to extract the temperature value from the header line. \u00a0Click the radio button\u00a0<strong>Extract variable name from file,<\/strong> select<strong> H001 <\/strong>besides<strong> line<\/strong>, set<strong> Start <\/strong>\u3001<strong> End<\/strong> to 1 and 12 to create the user parameter with name <strong>Temperature. \u00a0<\/strong>Click<strong> Add <\/strong>to create it. Then click Next.<br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7111\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import4-300x287.png\" alt=\"data_import4\" width=\"593\" height=\"567\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import4-300x287.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import4.png 626w\" sizes=\"auto, (max-width: 593px) 100vw, 593px\" \/><\/a>\n<\/li>\n<li>Keep Clicking <strong>Next<\/strong> until the last page. Check <strong>Save filter<\/strong> checkbox. Select <strong>In the Window. <\/strong>Click<strong>\u00a0Finish<\/strong> to import the data.\u00a0<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7112\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import5-300x287.png\" alt=\"data_import5\" width=\"597\" height=\"571\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import5-300x287.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/data_import5.png 628w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/a><\/li>\n<li>In the worksheet, A user parameter\u00a0line with name<strong> Temperature<\/strong> is added. In the next\u00a0step, we are going to\u00a0\u00a0generate a fitting function with parameters initialized by the <strong>Temperature<\/strong> value.<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/worksheet1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7116\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/worksheet1-257x300.png\" alt=\"worksheet1\" width=\"407\" height=\"474\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/worksheet1-257x300.png 257w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/worksheet1.png 407w\" sizes=\"auto, (max-width: 407px) 100vw, 407px\" \/><\/a><\/li>\n<\/ol>\n<p><strong>Step 2. Define a Fitting Function with Parameter Initialized with Temperature Value<\/strong><\/p>\n<ol>\n<li>Select <b>Tools:Fitting Function Builder\u00a0<\/b>(or press <b>F8<\/b>) to open the <b>Fitting Function Builder<\/b>, in the <b>Goal<\/b> page, select <b>Create a New Function<\/b> and click\u00a0<b>Next<\/b>.<\/li>\n<li>In the <b>Name and Type<\/b> page, make sure the function is created under the <b>User Defined<\/b> category, name the function <b>UptakeCurveFit<\/b>, keep the <b>Function Model<\/b> as <b>Explicit<\/b>, and select <b>Origin C<\/b> for <b>Function Type<\/b>. Click the <b>Next<\/b> button.<\/li>\n<li>In the <b>Variables and Parameters<\/b> page, keep the <b>Independent Variables<\/b> \u3001 <b>Dependent Variables<\/b> as the default <b>x<\/b> \u3001 <b>y<\/b>, respectively. Set the\u00a0<b>Parameters<\/b> to <b>T<\/b> and click <b>Next<\/b>.<\/li>\n<li>In the <b>Origin C Fitting Function<\/b> page, type in the following equation in the <b>Function Body<\/b> edit box, and then click <b>Next<\/b>.\n<pre class=\"lang:default decode:true\">y = 1 - 6\/(pi^2)*exp(-(pi^2\/T)*x)<\/pre>\n<\/li>\n<li>In the <strong>Parameter Initialization Code<\/strong> page, select <strong>Use Variable or Metadata.<\/strong> In the table, click the triangular button right to\u00a0<strong>Param T<\/strong> and then go to\u00a0<strong>Metadata from Columns:User-defined Parameters:X D1<\/strong>. Thus the\u00a0Temperature value in the worksheet user parameter\u00a0is assigned\u00a0to <strong>XD1<\/strong>, Edit\u00a0the initial Formula to <strong>25000-58*XD1<\/strong>.\u00a0\u00a0Click Finish.<br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7118\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1-300x196.png\" alt=\"fittingfunction1\" width=\"819\" height=\"534\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1-300x196.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1-768x501.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1-1024x668.png 1024w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/FittingFunction1-1.png 1227w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/a><\/li>\n<\/ol>\n<p><strong>Step 3. Fit the Data with the User Defined Function<\/strong><\/p>\n<ol>\n<li>Highlight column B and select <b>Analysis:Fitting:Nonlinear Curve Fit<\/b> (or press <b>Ctrl<\/b>+<b>Y<\/b>) to open the <b>NLFit<\/b> dialog, select <b>User Defined<\/b> for <b>Category<\/b> \u3001\u00a0<b>UptakeCurveFit(User)<\/b> as <b>Function<\/b>.<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7119\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting1-1-300x256.png\" alt=\"fitting1\" width=\"664\" height=\"567\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting1-1-300x256.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting1-1-768x655.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting1-1.png 977w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/a><\/li>\n<li>Go to the <b>Parameters<\/b> tab, see that the initial parameter T is set to 5106. The <strong>Initial Formula<\/strong> check box is turned on\u00a0and is set to <strong>25000-58*XD1<\/strong>.\u00a0This indicates the parameter initialization is successfully\u00a0applied. Click <strong>Fit<\/strong> to carry out the fit. Note:\u00a0in this dialog, you can also update\u00a0the initial formula and click <strong>P<\/strong> button again to reinitialize parameter.<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7120\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting2-1-300x256.png\" alt=\"fitting2\" width=\"666\" height=\"568\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting2-1-300x256.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting2-1-768x656.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting2-1.png 973w\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" \/><\/a><\/li>\n<\/ol>\n<p><strong>Step 4.\u00a0Create an Analysis Template and Do Batch Processing<\/strong><\/p>\n<ol>\n<li>Go to the report sheet <b>FitNL1<\/b> which is generated from previous steps, click the triangle button right to the <b>Summary<\/b> table and choose <b>Create Copy as New Sheet<\/b>. A new sheet will be created, delete column A in the new sheet and rename it as <b>Result<\/b>.\u00a0\u00a0<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7121\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template1-300x294.png\" alt=\"template1\" width=\"583\" height=\"571\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template1-300x294.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template1-768x752.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template1.png 838w\" sizes=\"auto, (max-width: 583px) 100vw, 583px\" \/><\/a>\u00a0<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7122\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template2-300x104.png\" alt=\"template2\" width=\"497\" height=\"172\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template2-300x104.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template2.png 640w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/a><strong><br \/>\n<\/strong><\/li>\n<li>Keep the workbook active and select <b>File:Save Workbook as Analysis Template<\/b> to save this workbook as <b>MyUptakeFit.ogw<\/b>.<\/li>\n<li>Create a new Origin project and select <b>File:Batch Processing<\/b> to open the <b>batchProcess<\/b> dialog.<\/li>\n<li>Load the analysis template <b>MyUptakeFit.ogw<\/b>, select the files <b>UptakeCurve_343K.txt<\/b>, <b>UptakeCurve_373K.txt<\/b>, and <b>UptakeCurve_403K.txt<\/b> under the\u00a0<i>&lt;Origin Folder&gt;\\Samples\\Curve Fitting\\<\/i>, choose <b>File Name<\/b> for <b>Dataset Identifier<\/b> and make sure the other settings are the same according to the image below:\u00a0\u00a0<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template3-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7127\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template3-1-300x288.png\" alt=\"template3\" width=\"605\" height=\"581\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template3-1-300x288.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template3-1.png 673w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/li>\n<li>Click <strong>OK<\/strong> to run the\u00a0batch processing. For each run, the temperature value in the header line\u00a0is first extracted during importing and then used to initialize the parameter T for the curve fitting. The final analysis result is shown below:<strong><br \/>\n<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7124\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template4-300x154.png\" alt=\"template4\" width=\"573\" height=\"294\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template4-300x154.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/template4.png 648w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>To see another example of initialize parameter values with min, max, mean, etc of data itself, you can unzip this file (<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/CDF_fitting.zip\">cdf_fitting<\/a>) which contains a\u00a0CDF (Cumulative distribution function) function of a normal distribution. Along with it is\u00a0a .ogw file with the data to be fitted. Go to the <strong>Parameter<\/strong> tab of the curve fitting dialog. All four fitting parameters are initialized using\u00a0the data info as\u00a0shown below:<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting_data_info.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7142\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting_data_info-300x136.png\" alt=\"fitting_data_info\" width=\"605\" height=\"274\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting_data_info-300x136.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting_data_info-768x347.png 768w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/fitting_data_info.png 852w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Good parameter initialization results in fast and reliable model\/data convergence. &hellip; <\/p>","protected":false},"author":875,"featured_media":7258,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4],"tags":[],"class_list":["post-7105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-analysis"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7DvU2-1QB","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2016\/10\/featurePicFittingInit-2.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/7105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/users\/875"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=7105"}],"version-history":[{"count":39,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/7105\/revisions"}],"predecessor-version":[{"id":10203,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/7105\/revisions\/10203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/7258"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=7105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=7105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=7105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}