calculate empirical distribution function and interpolation
3 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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
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
参考
カテゴリ
Help Center および File Exchange で Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!