Chi-Squared test for discrete outcomes

How to test if the distribution of outcomes is different from null hypothesis?

http://www.socscistatistics.com/tests/goodnessoffit/Default2.aspx

http://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/BS704_HypothesisTesting-ChiSquare/BS704_HypothesisTesting-ChiSquare2.html

see https://github.com/dagdpz/testsim/blob/master/testsim_chi_square.m