<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>بایگانی‌های رگرسیون غیر خطی - ايران متلب</title>
	<atom:link href="https://matlab1.ir/tag/%D8%B1%DA%AF%D8%B1%D8%B3%DB%8C%D9%88%D9%86-%D8%BA%DB%8C%D8%B1-%D8%AE%D8%B7%DB%8C/feed/" rel="self" type="application/rss+xml" />
	<link>https://matlab1.ir/tag/رگرسیون-غیر-خطی/</link>
	<description>مرجع فیلم های آموزشی فارسی دانشگاهی و مهندسی</description>
	<lastBuildDate>Thu, 08 Aug 2019 06:58:27 +0000</lastBuildDate>
	<language>fa-IR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://matlab1.ir/wp-content/uploads/2017/08/ref_a2-150x150.png</url>
	<title>بایگانی‌های رگرسیون غیر خطی - ايران متلب</title>
	<link>https://matlab1.ir/tag/رگرسیون-غیر-خطی/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>برازش منحنی مبتنی بر داده در متلب</title>
		<link>https://matlab1.ir/%d8%a8%d8%b1%d8%a7%d8%b2%d8%b4-%d9%85%d9%86%d8%ad%d9%86%db%8c-%d9%85%d8%a8%d8%aa%d9%86%db%8c-%d8%a8%d8%b1-%d8%af%d8%a7%d8%af%d9%87-%d8%af%d8%b1-%d9%85%d8%aa%d9%84%d8%a8/</link>
					<comments>https://matlab1.ir/%d8%a8%d8%b1%d8%a7%d8%b2%d8%b4-%d9%85%d9%86%d8%ad%d9%86%db%8c-%d9%85%d8%a8%d8%aa%d9%86%db%8c-%d8%a8%d8%b1-%d8%af%d8%a7%d8%af%d9%87-%d8%af%d8%b1-%d9%85%d8%aa%d9%84%d8%a8/#comments</comments>
		
		<dc:creator><![CDATA[ایران متلب]]></dc:creator>
		<pubDate>Thu, 31 Jul 2014 10:23:31 +0000</pubDate>
				<category><![CDATA[آموزش]]></category>
		<category><![CDATA[آموزش متلب]]></category>
		<category><![CDATA[Curve Fitting]]></category>
		<category><![CDATA[Curve Fitting Toolbox]]></category>
		<category><![CDATA[برازش منحنی]]></category>
		<category><![CDATA[ترفند]]></category>
		<category><![CDATA[ترفند متلب]]></category>
		<category><![CDATA[ترفندهای متلب]]></category>
		<category><![CDATA[جعبه ابزار برازش منحنی]]></category>
		<category><![CDATA[رگرسیون غیر خطی]]></category>
		<category><![CDATA[روش های عدد]]></category>
		<category><![CDATA[محاسبات عددی]]></category>
		<category><![CDATA[مدل سازی]]></category>
		<guid isPermaLink="false">http://am19.siteground.biz/~matlab18/matlab1.ir/?p=773</guid>

					<description><![CDATA[<p>یکی از سئوالاتی که غالبا در میان ایمیلهای ارسالی می بینم ، و در کلاس های آموزشی نیز به کرات مطرح می شوند، چگونگی برازش منحنی در متلب بر اساس داده است. فرض کنید: شما یک دیتا ست دارید که متشکل از دو متغیر است، که آن ها را در این پست با نام X [&#8230;]</p>
<p>نوشته <a href="https://matlab1.ir/%d8%a8%d8%b1%d8%a7%d8%b2%d8%b4-%d9%85%d9%86%d8%ad%d9%86%db%8c-%d9%85%d8%a8%d8%aa%d9%86%db%8c-%d8%a8%d8%b1-%d8%af%d8%a7%d8%af%d9%87-%d8%af%d8%b1-%d9%85%d8%aa%d9%84%d8%a8/">برازش منحنی مبتنی بر داده در متلب</a> اولین بار در <a href="https://matlab1.ir">ايران متلب</a>. پدیدار شد.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="http://iran-matlab.ir/?product=%D9%81%DB%8C%D9%84%D9%85-%D8%A2%D9%85%D9%88%D8%B2%D8%B4-%D9%81%D8%A7%D8%B1%D8%B3%DB%8C-%D8%AC%D8%B9%D8%A8%D9%87-%D8%A7%D8%A8%D8%B2%D8%A7%D8%B1-%D8%A8%D8%B1%D8%A7%D8%B2%D8%B4-%D9%85%D9%86%D8%AD%D9%86" target="_blank" rel="noopener noreferrer"><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-5831" src="https://matlab1.ir/wp-content/uploads/2017/06/curve-fitting-MATLAB-training-video.png" alt="" width="400" height="400" srcset="https://matlab1.ir/wp-content/uploads/2017/06/curve-fitting-MATLAB-training-video.png 400w, https://matlab1.ir/wp-content/uploads/2017/06/curve-fitting-MATLAB-training-video-150x150.png 150w, https://matlab1.ir/wp-content/uploads/2017/06/curve-fitting-MATLAB-training-video-300x300.png 300w" sizes="(max-width: 400px) 100vw, 400px" /></a></p>
<p style="color: #666666;">یکی از سئوالاتی که غالبا در میان ایمیلهای ارسالی می بینم ، و در کلاس های آموزشی نیز به کرات مطرح می شوند، چگونگی برازش منحنی در متلب بر اساس داده است. فرض کنید:</p>
<ul style="color: #666666;">
<li style="font-weight: inherit; font-style: inherit;">شما یک دیتا ست دارید که متشکل از دو متغیر است، که آن ها را در این پست با نام X و Y نشان خواهیم داد؛</li>
<li style="font-weight: inherit; font-style: inherit;">شما نیازمند مدلی (تابعی) هستید که ارتباط میان این دو متغیر را به صورت ریاضی توصیف نماید؛</li>
<li style="font-weight: inherit; font-style: inherit;">و هیچ دانش اولیه ای در مورد چگونگی معادلات ریاضی توصیف کننده این ارتباط ندارید و فقط می بایست با استفاده از داده ای که در دست دارید، این مسأله را حل نمایید.</li>
</ul>
<p style="color: #666666;"><span style="font-style: inherit; color: #719430;">سئوال اصلی:</span> چگونه می توان بهترین منحنی توصیف کننده ارتباط X و Y را به دست آورد؟</p>
<p style="color: #666666;">برای حل این مسأله روش های مختلفی عددی ارائه شده اند که می توان از روش های کلاسیک مبتنی بر چند جمله ای (مثلا <span style="font-style: inherit;">روش لاگرانژ</span>)، سیستم های فازی و شبکه های عصبی مصنوعی نام برد. در این پست، که از سلسله ترفندهای متلب در ایران متلب است، قصد داریم برخی از امکانات جعبه ابزار (تولباکس) برازش منحنی یا Curve Fitting Toolbox را برای حل مسأله برازش منحنی مبتنی بر داده به کار بگیریم. با ما در ادامه مطلب همراه باشید.</p>
<p>یکی از سئوالاتی که غالبا در میان ایمیلهای ارسالی می بینم، و در کلاس های آموزشی نیز به کرات مطرح می شوند، چگونگی برازش منحنی در متلب بر اساس داده است. فرض کنید:</p>
<ul>
<li style="font-weight: inherit; font-style: inherit;">شما یک دیتا ست دارید که متشکل از دو متغیر است، که آن ها را در این پست با نام X و Y نشان خواهیم داد؛</li>
<li style="font-weight: inherit; font-style: inherit;">شما نیازمند مدلی (تابعی) هستید که ارتباط میان این دو متغیر را به صورت ریاضی توصیف نماید؛</li>
<li style="font-weight: inherit; font-style: inherit;">و هیچ دانش اولیه ای در مورد چگونگی معادلات ریاضی توصیف کننده این ارتباط ندارید و فقط می بایست با استفاده از داده ای که در دست دارید، این مسأله را حل نمایید.</li>
</ul>
<p><span style="font-style: inherit; color: #719430;">سئوال اصلی:</span> چگونه می توان بهترین منحنی توصیف کننده ارتباط X و Y را به دست آورد؟</p>
<p>برای حل این مسأله روش های مختلفی عددی ارائه شده اند که می توان از روش های کلاسیک مبتنی بر چند جمله ای (مثلا <span style="font-style: inherit;">روش لاگرانژ</span>)، سیستم های فازی و شبکه های عصبی مصنوعی نام برد. در این پست، که از سلسله ترفندهای متلب در ایران متلب است، قصد داریم برخی از امکانات جعبه ابزار (تولباکس) برازش منحنی یا Curve Fitting Toolbox را برای حل مسأله برازش منحنی مبتنی بر داده به کار بگیریم.</p>
<p><span style="font-weight: inherit; font-style: inherit; color: #993300;"><span style="font-style: inherit; color: #719430;">تولید داده برای انجام برازش منحنی</span></span></p>
<p>هر چند کسی که قصد حل مسأله برازش منحنی را دارد، اصولا بایستی داده های مربوط به مسأله اش را داشته باشد، اما به دلیل این که این پست به منظور استفاده آموزشی نوشته می شود، ترجیح دادم که داده های مورد استفاده را به صورت مصنوعی و توسط خود متلب ایجاد نمایم. قطعا برای کسانی که قصد استفاده از مطالب مندرج در این پست را دارند، انجام مرحله تولید داده الزامی نیست. داده های مورد استفاده در این پست را با استفاده از قطعه کد زیر تولید می کنیم:</p>
<div class="code" dir="ltr" style="color: #666666;"><span style="font-family: 'courier new', courier;">s = RandStream(‘mt19937ar’,&#8217;seed’,1971);</span><br />
<span style="font-family: 'courier new', courier;"> RandStream.setDefaultStream(s);</span></div>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">X = linspace(1,10,100);</span><br />
<span style="font-family: 'courier new', courier;"> X = X’;</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">% Specify the parameters for a second order Fourier series</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">w = .6067;</span><br />
<span style="font-family: 'courier new', courier;"> a0 = 1.6345;</span><br />
<span style="font-family: 'courier new', courier;"> a1 = -.6235;</span><br />
<span style="font-family: 'courier new', courier;"> b1 = -1.3501;</span><br />
<span style="font-family: 'courier new', courier;"> a2 = -1.1622;</span><br />
<span style="font-family: 'courier new', courier;"> b2 = -.9443;</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">% Fourier2 is the true (unknown) relationship between X and Y</span><br />
<span style="font-family: 'courier new', courier;"> Y = a0 + a1*cos(X*w) + b1*sin(X*w) + a2*cos(2*X*w) + b2*sin(2*X*w);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">% Add in a noise vector</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">K = max(Y) – min(Y);</span><br />
<span style="font-family: 'courier new', courier;"> noisy = Y + .2*K*randn(100,1);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">% Generate a scatterplot</span><br />
<span style="font-family: 'courier new', courier;"> scatter(X,noisy,’k&#8217;);</span><br />
<span style="font-family: 'courier new', courier;"> L2 = legend(‘Noisy Data Sample’, 2);</span><br />
<span style="font-family: 'courier new', courier;"> snapnow</span></p>
<p style="color: #666666;">این داده ها در واقع از یک سری فوریه دو جمله ای که با نویز جمع شده است، ایجاد شده اند. نمودار داده های تولید شده به صورتی است که در ادامه مشاهده می کنید:</p>
<p><span style="font-weight: inherit; font-style: inherit; color: #993300;"><span style="font-style: inherit; color: #719430;">رگرسیون غیر خطی</span></span></p>
<p>اگر شما (بر فرض محال) بدانید که داده های فوق از یک قاعده سری فوریه دو جمله ای تبعیت می کنند، با استفاده از رگرسیون غیر خطی می توانید تابعی مانند $$Y=f(X)$$ را بیابید. این کار با استفاده از کد زیر قابل انجام است:</p>
<div class="code" dir="ltr">
<p style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">foo = fit(X, noisy, ‘fourier2′)</span></p>
<p style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">% Plot the results</span></p>
<p style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">hold on</span><br />
<span style="font-family: 'courier new', courier;"> plot(foo)</span><br />
<span style="font-family: 'courier new', courier;"> L3 = legend(‘Noisy Data Sample’,&#8217;Nonlinear Regression’, 2);</span><br />
<span style="font-family: 'courier new', courier;"> hold off</span><br />
<span style="font-family: 'courier new', courier;"> snapnow</span></p>
</div>
<p>نتیجه اجرای این کد، که به صورت متغیر foo است، در ادامه نشان داده شده است. همچنین نموداری که پس از اجرای این قطعه کد نمایش داده می شود، در ادامه آمده است.</p>
<div class="code" dir="ltr"><span style="font-family: 'courier new', courier;">foo =</span><br />
<span style="font-family: 'courier new', courier;"> General model Fourier2:</span><br />
<span style="font-family: 'courier new', courier;"> foo(x) = a0 + a1*cos(x*w) + b1*sin(x*w) +</span><br />
<span style="font-family: 'courier new', courier;"> a2*cos(2*x*w) + b2*sin(2*x*w)</span><br />
<span style="font-family: 'courier new', courier;"> Coefficients (with 95% confidence bounds):</span><br />
<span style="font-family: 'courier new', courier;"> a0 = 1.734 (1.446, 2.021)</span><br />
<span style="font-family: 'courier new', courier;"> a1 = -0.1998 (-1.065, 0.6655)</span><br />
<span style="font-family: 'courier new', courier;"> b1 = -1.413 (-1.68, -1.146)</span><br />
<span style="font-family: 'courier new', courier;"> a2 = -0.7688 (-1.752, 0.2142)</span><br />
<span style="font-family: 'courier new', courier;"> b2 = -1.317 (-1.867, -0.7668)</span><br />
<span style="font-family: 'courier new', courier;"> w = 0.6334 (0.5802, 0.6866)</span></div>
<div class="code" dir="ltr"></div>
<div class="code" dir="ltr"></div>
<div class="code">
<p style="color: #666666;"><span style="font-weight: inherit; font-style: inherit; color: #993300;"><span style="font-style: inherit; color: #719430;">برازش منحنی بدون پارامتر</span></span></p>
<p style="color: #666666;">ظاهرا همه چیز مرتب به نظر می آید. اما در واقع ما تقلب کرده ایم. زیرا در ابتدای همین پست، فرض را بر این گذاشته بودیم که هیچ دانش اولیه ای در خصوص نوع رابطه موجود میان متغیرها نداریم. اما در کدی که در بند پیش نوشته شد، فرض کردیم که رابطه ریاضی موجود میان متغیرها، به صورت یک سری فوریه قابل توصیف است. در نتیجه، اعدادی هم که برای ضرایب به دست آمدند، نزدیک به اعدادی هستند که ما در مرحله تولید داده ها استفاده کرده بودیم.</p>
<p style="color: #666666;">در ادامه کدی را ارائه خواهیم کرد که بدون استفاده از هیچ دانش اضافی، و فقط صرفا با تکیه بر داده های اصلی (و البته با کمی فشار آوردن بر CPU کامپیوتر) مسأله برازش منحنی مبتنی بر داده را حل می کند. برای انجام این کار از الگوریتمی به نام LOWESS استفاده خواهیم کرد. دقت این الگوریتم وابسته به پارامتری است که در این الگوریتم به کار برده شده است و به نام پارامتر هموارسازی یا Smoothing شناخته می شود. ما در این بخش ۹۹ مدل LOWESS ایجاد خواهیم کرد که پارامتر هموارسازی آنها از صفر تا یک تغییر می کنند. از میان ۹۹ مدل ایجاد شده، بهترین مدل را انتخاب خواهیم کرد.</p>
<p style="color: #666666;">این روش منجر به ایجاد مشکل Over-fitting خواهد شد. زیرا الگوریتم LOWESS بخش های زاید داده ها (نویزها) را با همان دقتی تخمین خواهد زد که بخش اصلی داده ها را تخمین زده است. برای پیشگیری از پدیده Over-fitting از تکنیکی به نام اعتبار سنجی متقابل یا Cross Validation استفاده خواهیم کرد. در این روش داده های تولید شده به دو گروه تقسیم می شوند: (الف) داده های آموزش یا Train Data و (ب) داده های آزمایش یا Test Data.</p>
<p style="color: #666666;">الگوریتم LOWESS از داده های آموزش برای ایجاد مدل استفاده خواهد کرد، اما دقت مدل ارائه شده، با توجه به داده های آزمایش (تست) تعیین خواهند شد. معیار مورد استفاده برای ارزیابی مدل نیز، مجموع مربعات خطا در نظر گرفته شده است.</p>
<p style="color: #666666;">کدی که این عملیات را انجام می دهد در ادامه آمده است:</p>
<div class="code" dir="ltr" style="color: #666666;"><span style="font-family: 'courier new', courier; color: #000000;">num = 99;</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> spans = linspace(.01,.99,num);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> sse = zeros(size(spans));</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> cp = cvpartition(100,’k&#8217;,10);</span></div>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">for j=1:length(spans),</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> f = @(train,test) norm(test(:,2) – mylowess(train,test(:,1),spans(j)))^2;</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> sse(j) = sum(crossval(f,[X,noisy],’partition’,cp));</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> end</span></p>
<p dir="ltr"><span style="font-family: 'courier new', courier; color: #000000;">[minsse,minj] = min(sse);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> span = spans(minj);</span></p>
</div>
<p style="color: #666666;">در کد فوق از تابعی به نام mylowess استفاده شده است که می بایست در فایلی به نام mylowess.m ذخیره شود. محتویات این فایل در ادامه آمده است:</p>
<div class="code" dir="ltr" style="color: #666666;"><span style="font-family: 'courier new', courier; color: #000000;">function ys=mylowess(xy,xs,span)</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> %MYLOWESS Lowess smoothing, preserving x values</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % YS=MYLOWESS(XY,XS) returns the smoothed version of the x/y data in the</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % two-column matrix XY, but evaluates the smooth at XS and returns the</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % smoothed values in YS. Any values outside the range of XY are taken to</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % be equal to the closest values.</span></div>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">if nargin&lt;3 || isempty(span)</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> span = .3;</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> end</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">% Sort and get smoothed version of xy data</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> xy = sortrows(xy);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> x1 = xy(:,1);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> y1 = xy(:,2);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> ys1 = smooth(x1,y1,span,’loess’);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">% Remove repeats so we can interpolate</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> t = diff(x1)==0;</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> x1(t)=[]; ys1(t) = [];</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">% Interpolate to evaluate this at the xs values</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> ys = interp1(x1,ys1,xs,’linear’,NaN);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">% Some of the original points may have x values outside the range of the</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % resampled data. Those are now NaN because we could not interpolate them.</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % Replace NaN by the closest smoothed value. This amounts to extending the</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> % smooth curve using a horizontal line.</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> if any(isnan(ys))</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> ys(xsx1(end)) = ys1(end);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> end</span></p>
<p style="color: #666666;"><span style="font-style: inherit; color: #719430;"><span style="font-weight: inherit; font-style: inherit; color: #993300;">مقایسه نتایج به دست آمده</span><br />
</span></p>
<p style="color: #666666;">در ادامه نمودار مربوط به</p>
<ul style="color: #666666;">
<li style="font-weight: inherit; font-style: inherit;">داده های اصلی (که از معادله سری فئریه دو جمله ای تبعیت می کنند)،</li>
<li style="font-weight: inherit; font-style: inherit;">نمونه های نویزی،</li>
<li style="font-weight: inherit; font-style: inherit;">مدل رگرسیون غیر خطی (به دست آمده از تابع fit)،</li>
<li style="font-weight: inherit; font-style: inherit;">و مدل به دست آمده از طریق الگوریتم LOWESS</li>
</ul>
<p style="color: #666666;">را در کنار یکدیگیر و به منظور مقایسه ترسیم می کنیم. کدی که این کار را برای ما انجام می دهد، در ادامه آمده است.</p>
<div class="code" dir="ltr" style="color: #666666;"><span style="font-family: 'courier new', courier; color: #000000;">plot(X,Y, ‘k’);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> hold on</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> scatter(X,noisy, ‘k’);</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> plot(foo, ‘r’)</span></div>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier; color: #000000;">x = linspace(min(X),max(X));</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> line(x,mylowess([X,noisy],x,span),’color’,&#8217;b’,&#8217;linestyle’,&#8217;-’, ‘linewidth’,2)</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> legend(‘Clean Data’, ‘Noisy Sample’, ‘Nonlinear Regression’, ‘LOWESS’, 2)</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> hold off</span><br />
<span style="font-family: 'courier new', courier; color: #000000;"> snapnow</span></p>
<p style="color: #666666;">نمودار به دست آمده پس از اجرای این کد در ادامه نمایش داده شده است:</p>
<p>مشاهده می شود که نمودار مربوط به الگوریتم LOWESS بسیار نزدیک به نمودار اصلی است و توانسته است که به خوبی رفتار داده ها را مدل سازی نماید.</p>
<p><span style="font-weight: inherit; font-style: inherit; color: #993300;"><span style="font-style: inherit; color: #719430;">ترسیم بازه های اطمینان</span></span></p>
<p>با استفاده از قطعه کد زیر می توان بازه اطمینان مربوط به مدل LOWESS به دست آمده را نمایش داد:</p>
<p>&nbsp;</p>
<div class="code" dir="ltr"><span style="font-family: 'courier new', courier;">scatter(X, noisy)</span></div>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">f = @(xy) mylowess(xy,X,span);</span><br />
<span style="font-family: 'courier new', courier;"> yboot2 = bootstrp(1000,f,[X,noisy])’;</span><br />
<span style="font-family: 'courier new', courier;"> meanloess = mean(yboot2,2);</span><br />
<span style="font-family: 'courier new', courier;"> h1 = line(X, meanloess,’color’,&#8217;k’,&#8217;linestyle’,&#8217;-’,&#8217;linewidth’,2);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">stdloess = std(yboot2,0,2);</span><br />
<span style="font-family: 'courier new', courier;"> h2 = line(X, meanloess+2*stdloess,’color’,&#8217;r’,&#8217;linestyle’,&#8217;–’,&#8217;linewidth’,2);</span><br />
<span style="font-family: 'courier new', courier;"> h3 = line(X, meanloess-2*stdloess,’color’,&#8217;r’,&#8217;linestyle’,&#8217;–’,&#8217;linewidth’,2);</span></p>
<p dir="ltr" style="font-weight: inherit; font-style: inherit;"><span style="font-family: 'courier new', courier;">L5 = legend(‘Localized Regression’,&#8217;Confidence Intervals’,2);</span><br />
<span style="font-family: 'courier new', courier;"> snapnow</span></p>
<p>نموداری که پس از اجرای این کد به دست می آید در ادامه نمایش داده شده است:</p>
<p>&nbsp;</p>
<p><span style="color: #666666;">امیدوارم که این مطلب بتواند پاسخگوی نیاز شما و سئوالاتی که در زمینه برازش منحنی داشته اید باشد. لطفا نظرات، سئوالات و پیشنهادهای خود را در بخش نظرات مربوط به همین پست وارد نمایید. منتظر پست های بعدی در زمینه ترفندهای متلب باشید.</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>نوشته <a href="https://matlab1.ir/%d8%a8%d8%b1%d8%a7%d8%b2%d8%b4-%d9%85%d9%86%d8%ad%d9%86%db%8c-%d9%85%d8%a8%d8%aa%d9%86%db%8c-%d8%a8%d8%b1-%d8%af%d8%a7%d8%af%d9%87-%d8%af%d8%b1-%d9%85%d8%aa%d9%84%d8%a8/">برازش منحنی مبتنی بر داده در متلب</a> اولین بار در <a href="https://matlab1.ir">ايران متلب</a>. پدیدار شد.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://matlab1.ir/%d8%a8%d8%b1%d8%a7%d8%b2%d8%b4-%d9%85%d9%86%d8%ad%d9%86%db%8c-%d9%85%d8%a8%d8%aa%d9%86%db%8c-%d8%a8%d8%b1-%d8%af%d8%a7%d8%af%d9%87-%d8%af%d8%b1-%d9%85%d8%aa%d9%84%d8%a8/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
