• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jul 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. fun[{data_, p_, n_, min_, max_}] :=
2.  Module[{}, lstplt = LinearModelFit[data, Table[x^i, {i, n}], x];
3.   Print[lstplt[x]]
4.    Print["Fit plotted from min to max temperature in data set range"]
5.    Print[Plot[lstplt[x], {x, min, max}]];
6.   reslist =
7.    Inner[List, {data}[[1, All, 1]], lstplt["FitResiduals"], List];
8.   Print["Fit and data curve"]
9.    Print[Show[ListPlot[data], Plot[lstplt[x], {x, min, max}]]];
10.   Print["Residual Plot"]
11.    Print[ListPlot[reslist]];
12.   bres = Select[reslist, Abs[#[]] > p &];
13.   gres = DeleteCases[reslist, Alternatives @@ bres];
14. gpoints = gres[[All, 1]] [Intersection] reslist[[All, 1]];
15. Print["New data curve excluding points that had poor residual
16. values"]
17.  Print[ListPlot[
18.   dataset13 = Select[data, gpoints~MemberQ~First[#] &]]];
19.   Print["New data set"];
20.   Print["Number of points"];
21.  Print[Length[dataset13]];
22.  Return[dataset13];]
23. data = Table[{x, RandomReal[{-.1, .1}] + x^2}, {x, 0, 15}];
24.
25. fun[fun[data, .04, 2, 0, 15], 1, 3, 0, 15]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top