Hi there. I need someone to help me run the following code and produce a wolfram mathematica. I need the file in as .nb. Many thanks.
CreateDistribution[] := DynamicModule[{savepts = {{-1, -1}}},
Dynamic[
EventHandler[
ListPlot[pts, AxesOrigin -> {0, 0},
PlotRange -> {{0, 7}, {0, 5}}],
"MouseDown" :> (savepts =
pts = DeleteCases[
Append[pts, MousePosition["Graphics"]], {-1, -1}])],
Initialization :> (pts = savepts)]]
CreateDistribution[]
lm = LinearModelFit[Sort@pts, a, a]; r2 = lm["RSquared"];
Show[Plot[lm[x], {x, 0, 7}], ListPlot[pts], AxesOrigin -> {0, 0},
PlotRange -> {{0, 7}, {0, 5}},
PlotLabel ->
"The correlation is " <>
If[D[lm["BestFit"], a] < 0, "negative", "positive"],
Epilog ->
Inset[Style[
"\!\(\*SuperscriptBox[\"R\", \"2\"]\) = " <> ToString[r2],
11], {1.5, 4.5}]]
lm = LinearModelFit[Sort@pts, {1, x (*, x^2 *)}, x];
{bands68[x_], bands95[x_], bands99[x_]} =
Table[lm["SinglePredictionBands",
ConfidenceLevel -> cl], {cl, {0.6827, 0.9545, 0.9973}}];
Show[ListPlot[Sort@pts],
Plot[{lm[x], bands68[x], bands95[x], bands99[x]}, {x, -0.15, 7.2},
Filling -> {2 -> {1}, 3 -> {2}, 4 -> {3}}], AxesOrigin -> {0, 0},
PlotRange -> {{0, 7}, {0, 5}}, ImageSize -> 480, Frame -> True]