In this Promblem you are should graphically obtain the pdf (probability distribu
ID: 3691771 • Letter: I
Question
In this Promblem you are should graphically obtain the pdf (probability distribution function) of 3 discrete distributions by repeating the random experiment multiple times and normalizing the results. Using Met lab, java or c. The program have to perform a random experiment to obtain the fallowing.
a) User should select one of the following distribution from the initial menu:
- Uniform
- Binomial
- Geometric
b) After selecting a distribution from the list, the user should be given the option of assigning values to its parameters:
-Uniform: initial value ‘a’ and the final value ‘b’.
-Binomial: the probability of success ‘p’ and the total number of Bernoulli experiments ‘n’.
-Geometric: the probability of success‘p’
c) In each case the user selects the total number of repetitions for each case ‘R’. This value should be set to 10, 1000 and 10000 in your results.
Explanation / Answer
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class MenuIteams extends Frame implements ActionListener
{
TextArea ta;
public MenuIteams()
{
MenuBar mBar = new MenuBar();
setMenuBar(mBar);
Menu uniform = new Menu("Uniform ");
Menu binomial = new Menu("Binomial");
Menu geometric = new Menu("Geometric");
ta = new TextArea(10, 40);
ta.setBackground(Color.green);
mBar.add(uniform);
mBar.add(binomial);
mBar.add(geometric);
MenuItem mi1 = new MenuItem("MENUPage.java");
binomial.add(new MenuItem("a,b"));
geometric.add(new MenuItem("p"));
uniform.add(new MenuItem("n"))
add(ta, "Center");
setTitle("Menu Practice");
setSize(400, 400);
setVisible(true);
setSize(10, 100);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String str = e.getActionCommand();
if(str.equals("a,b"))
{
System.uniform(0);
}
else if(str.equals("p"))
{
ta.setText("Geometric: " y);
}
else
{
try
{
FileReader uniform = new FileReader(str);
ta.setText("Folloiwing menu contents: ");
int temp;
while( (temp = uniform.read()) != -1)
{
char ch = (char) temp;
String s1 = String.valueOf(ch);
ta.append(s1);
}
uniform.close();
}
catch(IOException e1)
{
ta.setText("Exception: " + e1);
}
}
}
public static void main(String args[])
{
new MenuIteams();
}
}