this is a prebuilt version of the

application so if we go ahead and run it now suppose we are in this sample space

Omega and we have items that have different colors and they are either

striped or not striped and they have different shapes so the probability of

Omega is 1 and the probability of the items with blue colors event is 5 over a

12 so we have 5 items that have a blue color out of 12 items in the sample

space and this is the marginal probability so it is the same as this so stripes

can be anything and shape can be anything and a marginal probability is

when a subset of variables is specified and a joint probability is where all the

variables are specified and we can calculate this conditional probability so given that stripes is true then we

want the probability where the color is blue so it’s 2 out of 6 which is 1 out

of 3 the probability of both the color being blue and stripes is

true so those two so 2 out of 12 which simplifies to 1 over 6 over the

probability where stripes is true so 6 out of 12 which simplifies to 1 over 2

so we end up with 1/3 so let’s try this so given the color is blue

what’s the probability of the color being blue 1 so 5 over 12 divided by 5

over 12 so the intersection of color is blue and

color is blue which ends up being color is blue / color is blue probability of

that so we get 1 and if we do the probability of the sample space Omega

given that the color is blue it ends up also being 1 so what we are saying

here is given that we have this color is blue what’s the probability of the

sample space Omega so it’s always in omega so when we have and we have intersection

and when we have or we have union so we want the probability of the color

being blue or stripes being true so this is color being blue or stripes is

true so we have 9 out of 12 items which simplifies to 3 over 4 the

probability of color is blue + the probability of stripes is true minus the

probability of color is blue and Stripes is true and if we have

disjoint events than the intersection ends up being 0 so we end up with those two

and the reason we subtract this intersection is because when we add

those two we have the intersection 2 times we are counting it two times so we

subtract one of the times now before moving to the code let’s go over a few

items so the sample space Omega is the set of all possible outcomes of an

experiment and an event E is a subset of that sample space and we have three

probability axioms the probability of the event E is between 0 and 1 and the

probability of the sample space Omega is equal to 1 and the probability of the

unions of events E1 E2 etc is equal to the probability of event E1 plus

probability of event E2 etc where E1 E2 is a sequence of disjoint events and it

follows from that that we have that the probability of two events E1 union

E2 is equal to the probability of E1 plus the probability of E2 minus the

probability of the intersection of events E1 and E2 where E1 and E2 can

be non disjoint events and if they are disjoint then this would be 0

so we come back to what we had here and a sample space consists of any

equally likely single element events and the probability of any event a is given

by the probability of A is equal to the number of elements of A divided by n and

this is the definition of conditional probability the probability of A given B

is equal to the probability of the intersection of A and B divided by the

probability of B I will start by creating a new project and we need this jar from here to do

fractions so we go to properties and Java

build path and here we will have four classes this one will be driving the application

so it will have a main method and this one will represent an event which

is a subset of the sample space and this one will contain the probability logic and this one will represent an item in

the sample space now an item will contain a hashMap of

features and a get method for that and this will be initialized in the constructor

and example of features are the color the shape or if that item is striped

or not and this will be the data that we will be using here so this row

represents the heading and we will have our sample space here and will populate it with the data here and this method does the display of the

items in that sample space and this method will pick up user input from the

command line and we will call those two methods from here and an Event represents a subset of items

in the sample space so it has this items ArrayList and a get method for that and this static method creates and returns a new

event from a passed in ArrayList of items and this method handles intersecting the

items in this event with the passed in event and it returns a new event

containing the intersection items and this method creates and returns a new

event containing items selected based on user input and this method does entry validation so

we make sure that we’re trying to get the probability of one of the headings

here either color or stripe or shape or Omega and

this method will prepare and return a new event based on user input and this method handles one of the sides when we have a

union so it creates a new event containing the event features that were

specified by the user and then determines the number of items in that

event and creates a fraction out of that with the length of the sample space

so this over this and we will end up calling it the from here and it makes use of the probability of

an intersection and this method handles the probability

when we have givens so givens values and values and finally this method takes input from

the user and calculates and returns various probabilities and to do that it

calls handle or entry and calculate probability and let’s go ahead and test run the

application so the probability that color is green and stripes is false is 3

out of 12 so this simplifies to 1 over 4 and the probability that

color is green and stripes is false given that shape is square ends up

being 1 over six since we have six items where shape is squares and out of

those six we have one where color is green and stripes is false or we

can calculate it this way by the intersection of all three divided by

the probability of shape is Square and we can calculate this probability so it

ends up being 1 so this is where shape is triangle

and in both cases color is green and stripes is false and if we do shape is round then we end

up with 0 since shape is round here and here and color is green and stripes is false

is here and if we do the probability of stripes is true or shape is square we

end up with 2/3 so we have those items actually those items so 8 out of 12 and it simplifies to 2

over 3

Introduction to Linear Algebra 01 – A Python NumPy Tutorial @ https://youtu.be/1YI977vmkAw

Intro to Linear Algebra 02 – A JAVA 8 Tutorial @ https://youtu.be/4m8JWAZecBo

Intro to Probability w/ JAVA (tutorial 02) – Independence & Conditional Independence @ https://youtu.be/XZ2nJWC2l84

Intro. to Probability With JAVA (tutorial 01) @ https://youtu.be/vnI6X_IZbzA