calculate empirical distribution function and interpolation

조회 수: 1 (최근 30일)
alpedhuez
alpedhuez 2020년 6월 2일
댓글: alpedhuez 2020년 6월 4일
I have a data of
column 1 = temperature at 55F, 57F, 60F,...
column 2 = sales of sunglasses at these temperatures
I want to calculate the empirical distribution of sales of sunglasses over time and then use this empirical distribution to estimate the sales of sunglasses when the temperature is 56.6F, etc.
I tried to use polyfit but told that polynomial is badly conditioned.

답변 (1개)

Jeff Miller
Jeff Miller 2020년 6월 3일
You want to use the regress function, something like this:
X = [ones(size(temp) temp)]; % temp is a column vector of temperatures
b = regress(sales,X); % sales is a column vector of sales
SalesAt56pt6 = b(1) + b(2)*56.6;
empirical distribution functions and polyfit are both used in different types of situations than you are describing.
hth
  댓글 수: 3
Jeff Miller
Jeff Miller 2020년 6월 4일
You can add some nonlinear terms like this:
X = [ones(size(temp)) temp temp.^2 temp.^3]; % temp is a column vector of temperatures
b = regress(sales,X); % sales is a column vector of sales
SalesAt56pt6 = b(1) + b(2)*56.6 + b(3)*56.6^2 + b(4)*56.6^3;
This technique will fit a polynomial of any order you want
alpedhuez
alpedhuez 2020년 6월 4일
Thank you. How does it differ from polyfit?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Regression에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by