Endil

Untitled

Dec 30th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. CreateDocument[{
  2.   SetDirectory[NotebookDirectory[]];
  3.   DynamicModule[
  4.    {x = 100, dist = 1, path, data},
  5.    Column@{
  6.      Grid[
  7.       {{TextCell@"Choose Distribution:",
  8.         PopupMenu[
  9.          Dynamic@dist, {1 -> "Normal", 2 -> "Poission",
  10.           3 -> "Binomial", 4 -> "Maxwell", 5 -> "Uniform"}]
  11.         },
  12.        {TextCell@"Number of samples:",
  13.         InputField[Dynamic[x], Number, ImageSize -> 100]}
  14.        }
  15.       ],
  16.      Button["Generate & Plot",
  17.       Which[
  18.        dist == 1,
  19.        CreatePalette@Histogram[RandomVariate[NormalDistribution[], x]],
  20.        dist == 2,
  21.        CreatePalette@
  22.         Histogram[RandomVariate[PoissonDistribution[1], x]],
  23.        dist == 3,
  24.        CreatePalette@
  25.         Histogram[RandomVariate[BinomialDistribution[40, 0.5], x]],
  26.        dist == 4,
  27.        CreatePalette@
  28.         Histogram[RandomVariate[MaxwellDistribution[0.5], x]],
  29.        dist == 5,
  30.        CreatePalette@
  31.         Histogram[RandomVariate[UniformDistribution[], x]],
  32.        True,
  33.        CreatePalette@
  34.         Histogram[RandomVariate[NormalDistribution[1, 3], x]]]
  35.       ],
  36.      Row@{
  37.        FileNameSetter[Dynamic@path];
  38.        Button["Plot", {
  39.          Dynamic@data = Import[Dynamic@path],
  40.          FindDistribution[Dynamic@data],
  41.           CreatePalette@Histogram[{data}]
  42.          }
  43.         ]
  44.        }
  45.      }
  46.    ]
  47.   }
  48.  ]
Advertisement
Add Comment
Please, Sign In to add comment