<< Statistics`Master`
<< Graphics`ImplicitPlot`

cond[a_, n_] := 
      Module[{na, na1}, 
        na = Max[
            Table[Sum[Abs[a[[i, j]]], {j, n}], {i, 
                n}]];  
a1 = Inverse[a];  
        na1 = Max[
            Table[Sum[Abs[a1[[i, j]]], {j, n}], {i, 
                n}]];  
na na1 // N]

Sustav linearnih jednadzbi

n = 2;
a = {{1, -1}, {-1, 2}};  
    b = {-1. , 2}; 
  
x = LinearSolve[a, b];
Print[MatrixForm[a], "x = " MatrixForm[b], "  cond[a] = ", 
      cond[a, n]]
sl0 = 
        ImplicitPlot[{a[[1, 1]] u + a[[1, 2]] v == b[[1]], 
            a[[2, 1]] u + a[[2, 2]] v == 
              b[[2]]}, {u, -3, 3}, 
          PlotLabel -> "Graficki prikaz sustava", 
          DisplayFunction -> 
            Identity];

  
m = 500;  var =  .1;   SeedRandom[1];
podb = podx = Table[{0, 0}, {i, m}];
f = LinearSolve[a];
Do[
        db = {Random[NormalDistribution[0, var]], 
            Random[NormalDistribution[0, var]]}; 
b1 = 
          b + db; 
x1 = 
          f[b1]; 
podb[[i]] = b1;  
        podx[[i]] = x1, {i, m}];
sl1 = 
        ListPlot[podb, PlotLabel -> "Distribucija vektora b", 
          PlotStyle -> {AbsolutePointSize[2]}, 
          AspectRatio ->  Automatic, 
          PlotRange -> {{-1.5, 0.5}, {0, 2.3}}, 
          DisplayFunction -> Identity];
sl2 = 
        ListPlot[podx, PlotLabel -> "Distribucija vektora x", 
          PlotStyle -> {AbsolutePointSize[2]}, 
          AspectRatio ->  Automatic, PlotRange -> {0, 1.3}, 
          DisplayFunction -> Identity];
Show[GraphicsArray[{sl0, sl1, sl2}], 
        DisplayFunction -> $DisplayFunction];

Generiranje tocaka u krugu

Zadatak 1

Generirajte uniformno distribuirane tocke u jedinicnom krugu sa sredistem u ishodistu te ih u obje koordinate pokvarite s normalno distribuiranom pogreskom N(0,0.02).

n = 1000; 
    pod = Table[{Random[Real, {-1, 1}], Random[Real, {-1, 1}]}, {i, 
          n}];
sl1 = 
        ListPlot[pod, PlotStyle ->  {AbsolutePointSize[4], Hue[1]}, 
          AspectRatio -> 1, 
          DisplayFunction ->  Identity];
Do[
        If[pod[[i, 1]]^2 + pod[[i, 2]]^2 > 1, 
          pod[[i]] = {c, c}], {i, n}];
pod = DeleteCases[pod, {c, c}];
sl2 = 
        ListPlot[pod, PlotStyle ->  {AbsolutePointSize[4], Hue[0.8]}, 
          AspectRatio -> 1, 
          DisplayFunction ->  Identity];
pod = 
        pod + Table[{Random[NormalDistribution[0, 0.2]], 
              Random[NormalDistribution[0, 0.2]]}, {i, 
              Length[pod]}];
sl3 = 
        ListPlot[pod, PlotStyle ->  {AbsolutePointSize[4], Hue[0.2]}, 
          AspectRatio -> 1, 
          DisplayFunction ->  Identity];
sl4 = 
        Show[sl1, sl2, sl3, 
          DisplayFunction ->  Identity];
sl5 = 
        Show[sl2, sl3, 
          DisplayFunction ->  Identity];
Show[GraphicsArray[{sl4, sl5}], 
        DisplayFunction ->  $DisplayFunction];