[SOLVED] CSC22100-Exercise 3

20.99 $

Category:

Description

Rate this product
  1. Implement a Java class MyPieChart that displays a pie chart of the probabilities of the n most frequent occurrences of an event to be specified in part 4 of the exercise. The probability of event is given by the equation:

 

πΉπ‘Ÿπ‘’π‘žπ‘’π‘’π‘›π‘π‘¦π‘œπ‘“π‘’π‘£π‘’π‘›π‘‘

π‘ƒπ‘Ÿπ‘œπ‘π‘Žπ‘π‘–π‘™π‘–π‘‘π‘¦π‘œπ‘“π‘’π‘£π‘’π‘›π‘‘ =

βˆ‘ πΉπ‘Ÿπ‘’π‘žπ‘’π‘’π‘›π‘π‘–π‘’π‘ π‘œπ‘“π‘Žπ‘™π‘™π‘’π‘£π‘’π‘›π‘‘π‘ 

 

In the pie chart:

 

  1. The area of each segment is proportional to the probability of the corresponding event:

 

πΆπ‘’π‘›π‘‘π‘Ÿπ‘Žπ‘™π‘Žπ‘›π‘”π‘™π‘’π‘œπ‘“π‘ π‘’π‘”π‘šπ‘’π‘›π‘‘

π‘ƒπ‘Ÿπ‘œπ‘π‘Žπ‘π‘–π‘™π‘–π‘‘π‘¦π‘œπ‘“π‘’π‘£π‘’π‘›π‘‘ =

2πœ‹

 

  1. Each segment has a different color;
  • Each segment has a legend showing the corresponding event and its

probability;

  1. The segments are displayed in order of decreasing or increasing probability;
  2. The last segment represents β€œAll Other Events” and their cumulative probability. As an example, in the graph below where the event is the occurrence of a letter in a text:n = 3, and the probability of All Other Events is one minus the sum of the probabilities of eventse, s, and i;

 

 

 

 

  1. The MyPieChart class includes appropriate constructors and a method draw that draws the pie chart. The drawing canvas should include appropriate GUI components to input the number of events, n, and display the pie chart together with the events and their corresponding probabilities.

 

  1. The MyPieChart class may inherit or otherwise utilize the MyShape class hierarchy in previous exercises, but in any case you may only use JavaFX graphics and your own classes and methods for the operations included.

 

  1. Implement a Java class HistogramAlphaBet that calculates the n most frequent alphabet characters in β€œAlice’s Adventures in Wonderland” by Lewis Carroll (file Alice in Wonderland.txt) and their probabilities. The HistogramAlphaBet class utilizes a map collection for statistical calculations and the drawing canvas above to draw a pie chart of the probabilities.