Contents:
How is the iiccur. Description; Conduct tha exper i merit of Elippmq ]0 fair coins luO tunes? How does the frequency distribution obtained compare to the expected values for such a frequency distribution? Would you expect the normal approximation to ho botLar It the coins were not fair? Explain- 3- Would you expect the normal approximation to tm bettor if you were measuring the number of hands in 2U flips?
Try modifications suggested by quostiono 2 and 3 in your program. Do they yield the oxpactu. The purpose of this oxporiment is to allow the student to gain experience in the use of the random number generator and to learn some ways it is applied. Use the random number generator RAII to generate and print random numbers- use tilSTl to construct a histogram with 10 frequency classes.
Then convert those random numbers into random integers between 0 ,ind 99 inclusive. Exercise 26 43 Questions: What- dues Lho hisr. Does title surprise you? How would yon modify your program lo do this? How would you modify your program to do this? Siri nuti on i'urMBe: This exercise is Lo qivo the student fej periance in obtaining ft random sample on the computer. In order to do this we col Act a freshman with probability 0. If each Interviewer is to Interview 10 students, write a program which will determine, tor each interviewer, how many of hie 10 interviews should cotno from oach of the four classes.
Repeat tins five times; that is, generate five sots of samples ot size 10 and calculate the moan. OuLDUti The output should consist of a list of the classes of the ten students chosen you may print 1 for freshman, 2 tor sophomore, etc and the mean of the ten values. DO the calculated means agree closely? What ia the median fil. What is the modal claso? I- were any values chosen more than once in the fifty choices? Does this make your random sample invalid? How might you correct this? Punch Lhe mean tor sample number: Your output should consist of the value of nf the mean of the sample means, the standard rievirit-.
What would you expoct tho standard deviation of the cample means to approach as n acts largo? Do your results verify your oxpoctationnV explain- Extra things Zii 1. Repeat the experiment above, only obtain your samples fron a population which in normal with moan 50 and variance Compare and contrast your results with thoco obtained above.
The purpose of this exercise is to intuitively motivate the use of the unbiased estimate of the variance by experimentation and to emphasize the distinction between sample statistics and population parameters. Obtain random samples oi size 'j from a popula- tion which is normal with maun 50 and variance using HORM1 described in Part 2 ot this manual- For each cample of hi lie 5P compute the biased estimate of the Vcir j annta by Output: Your output should consist of tha four computed values for each of the suinple-E of aiva 5 and a final lino containing the 4 means of the previously printed values- Questions: Punch the means the unbiased estimate of the variance of the valutas: A Statistical Subroutine Purpose: Write a subroutine subprogram which accepts.
The subroutine is to compute tho mean and standard doviittion ot the set of data values and return them an output Arguments. State what advantages you feol using a subroutine like tho one written above gives to soineono who wichos to compute the moan and standard deviation. What disadvantages can you think of to using such a subroutine? If someone wishes to use this subroutine, he must have instruction in its use- Write a description of your subprogram which is completo enough that anyone knowing as much FORTRAN as you would be able to use il after reading your instructions.
Do all of your values agree with those in the textbook tables? Which table do you think 1b correct?
The constant is just the number of trading days in a year. On Gorgias' Defense of Palamedes. Infix set and array operators now have precedence between relational expressions and additive expressions. The transcript command has been updated to append the output of each subsequent command to a file. Both sides simply face each other and slug it out until one or both sides has no troops left an absorption state. In a future version, we will implement an MCMC method for dealing with large nets.
What do you think causes this difference? How could you go about making them agree? Tho purpose ot this exercise is to give the student experience in character manipulation and non-numeric frequency distributions. It then reads N t,-ardsr each of which contains a portion of a written text. Your program is to print a copy of the text and wake fi frequency distribution which lists the number of occurrences of each letter m the text.
Your output should consist of the text and a relative i frequency distribution of the lettcrn printed in any form you find convenient- 1. It Repeat Che above, but add to the set of characters the digits and specie! The purpose of this exercise is to give The student practice in designing printouts. Place a heading on your listing describing the nature of the values. Punch thH number of inturvali containing tho mean for: What is the expected number of intervals containing the moan? How would you go about making your confidence intervals narrower? Do you coom to mnko any kutiouo errors by ucing e in placo of o?
La Repeat the above experiment for samples of size Is the result what you expected? Student' b t Distribution Purpose: The purpose of this exercise is to illustrate the advantage of using Student's t distribution for small sample tHStE- Description: Write a program similar to r. Output will consist of two sots of SO confidence intervals, all provided by subprogram cqhin. What is the ratiaon?
Ji what ifi tha ottsct of increasing n on ths validity ot the Large sample tost? When the confidence Interval is found to bo of length loss than T. Your output should consist of T, the cample kizu H for which this tolerance was reached, the sample mean and standard deviation for your aamplo of si2e N and the endpoints of the confidence interval, all proporly labelled. Is the truo population moan in the determined confidence interval? How would your program be different if o were known? Would it be simpler? If you completely recompute x and s after each value is added to the sampler see if you can't find some way of saving computer effort here.
How would a larger population standard deviation affect the sample size N needed? How would a larger value of T affect the sample size N needed? You may use the computer to do this if you wish- 2. The purposo of this exorcise is to introduce the student to testing a hypothesis about a sample mean and to illustrate type I and type II errors. Exercise 38 61 nution: This in the value to be returned for the function- write i calling program which calls with the following values for its parameters.
In columns; Punch the number of "accepts when JiillJ is: Testing Hypotheses for Live D. The purpO'c of thic cxcicibp if r. It is well Known that the scores on the SAT are scaled so that the mean ccoro over the entire population toiited tu while the standard deviation is The oxerciue is to choose ono ot the two SAT exams math or verbal: You may wish to pertorm several toots. Discuss tho results ot your tests and tell what decision you have reached on U.
Discuss your reasons for performing the tests you did- 2. Did you assume that o - or that o is unknown? What aro your concl unions? Tasting ilie Hifferwncc af, two Asians PjimiiE: Tht- purpostH of this exercise 1a to illustrate tha test for the difference at two mtuinfi by an application to s. Sampla trom tha population described in computer exorcise N for each score- The program is to read a value of the lavel of iurjni fi. You may assume the population standard deviation id LUG.
Exercise 41 65 3. How would you change your program if you were to test against a one—sided flj. It Rewrite your program for the above exercise assuming a unknown and comment on your results. Testing a Proportion EjiifiCSfi! The purpoue or thin experiment is to give the student a bettor understanding of the technique involved in testing hypotheses about proportions.
Write a program which will test this hypothesis on a sample. The program is to cause the computer to read u text of any length from a cot of data cnrdB. The output of your program should consist of an exact copy of the text under examinetion, the pruporr. Explain how you would go about that. Can you modify your program so that it works tor Idrflor texts?
The purpose of thi k exercise 15 to illustrate the relation between a pair of variabilis by j tscatt-ergram. Description; Use the computer and subprogram SCAT described in Part 2 of this manual la construct a scattergrdm of The pair of variables which was assigned to you from the live data. Choose a sample ot SO pairs trom the population- Computer uxercj se , Can you taxplain this from what you knew about the source of the Variables?
The purpose of this exerci se is to allow the students Lo examine scattergrams of various distributions so that they uucfbt have some feel for the meaning of a correlation coefficient. Run your program Eor N - 50 and RO - , Oi eigni f i co. Is the value ot r which you obtain significant at the 0. Contral kuauJ; Theorem purpose: Wrtfce a program which chooses M samples of size N from your live data set and computes the mean for each sample.
It is to construct a frequency distribution for the sample means with six frequency cLiaeea. What is the effect of increasing N on yout test? What is the effect on your test of increasing u? Whut Jira you Able to da better now? The purpose of this exercise is to illustrate the use of contingency tables to test the relation of two variables.
Exercise 4 3 Ojjtpat: Kour output shoulo consist of a labelled printout of the contingency table, the chi-square value computet! OS significance levelH Interpret your answer. Could it be used in this situation? Prij'iL, tor each test you perform, the level of signiflcance, one- or two-sided test, the sample size and whether or not you accept the hypothesis thar the median is 74 Exercise 4 9 Questions: Elow is thin pertinent to our choice oE taste? The description portion describes what the Gubprogram does, The notes specify any other information of wbxch the user o.
I is an integer expression which specifies the number ot succeBsaa. Xi-iean is a real expression which specifies tho mean of X. XVAR in a real expression which specifies the variance of X- ymean is a real expression which specifies the mean of y. HO is a real expression which contains tho valuo of tho correlation coefficient. JOW wiLl teatf N cardur each containing t. C0N1U prints 50 interval a who fit? Krtpn must ho subscripted to at least This function subprogram returns to DF the value of the distribution function for the cbi-square distrioution with JJUF degrees of freedom.
NDFN in an integer expression giving the numerator degrees of freedom. NDFD is an integer expreflfiion giving the denominator degrees of freedom. X is a real expression whohh value in the point at which the F distribution function la evaluated. FF requires subprogram ft'. El is a real expression which is the? Tiiic function subprogram returns to ulSr the value of the distribution function Cor the standard normal distrihutionj N[utI , evaluated at X.
ALN is a real expreimon which specifies the width pt ooch frequency clacs. NTOT is an integer expression spocifyinq the number of frequency classen. The user must take care that ail of his data points are withjn the frequency classes he has defined. NTOT must be no Larger than X inuet be subscripted for flt least [J valuta. X 15 any real expression. U is an integer expression which specifies tho number of observations to bo generated f.
X is a roal subscripted variable in which the random sample is stpred. PEHrt genera Lee a sequence ot all permutations of the first N integers. PRCH1 computes and returns a number C such th. C is a real vari. J will be provided by your instructor. A 10 a real subscripted variable which contains the II values of the population. H ib an integer expression Hpocifylng the size oE the dosired random sumple taken from a.
D lo a real subscripted variable into which tho random sample is returned. Tho random cample is returned in H. A muot be subscripted to at least XHXM is a real expression which specifies the Lower limit on the x axis. KMAX is a rool expression which specifies the uppor limit on the x axis. YMAX ifl a roal expression which specifies tho upper limit on the y axis- H ic an integer expression which specifies the number ot pairs of observations to be plotted. X is a real subscripted variaole which contains the N observations of X. Y ic a real subscripted variablo which contains the N corresponding observations of If.
The mean, unniasud variance and maximum likclinuod variance are calculated for the observations of X and Cor the observations ot Y. X must bo subscripted to at leant N. X ie a real subscripted variable containing the values of the h. XI1AX in a real variable which specifics the upper limit, on the x nxis.
X iii a real aubscriptoiJ variable containing the M observations. XrtU is a real nxprnuuion which specifies thu mean of the normal distribution. SIGrtA is a roal expression which spectfios the standard deviation of tho normal distribution. The histogram contains 10 classes. X must oe subscripted to at least M. In order to do this ouch data seta must he accessible on your computor. Right now, Palamedes' Bayes net model only supports binary random variables, e.
In a future version, random variables will be able to take arbitrary values, e. Probabilities are input or queried into the system via statements of the form Pr Conjunction1 of random variables Conjunction2 of random variables. The bar meaning "given" and the second conjunction are optional. Here are a few examples:. Exact and approximate methods exist for inferring unobserved variables in Bayesian networks. Common exact methods include exponential enumeration and variable elimination. Approximate methods include importance sampling, belief propagation, and stochastic MCMC simulation.
It uses pattern matching to match user inputs against mathematical rules for making deductions until the current goal is achieved. The rules are simply what you would find in any probability and statistics textbook about conditional probabilities:. To see a table of all of the deductions made by the system, use the command bayes. These deductions are memoized. If you need to clear them because you've added new info or changed values, simply pass an argument to the bayes function, e.
This implementation is inspired by Ivan Bratko's interpreter for belief networks, figure It has comparable performance to variable elimination. So approximate methods are needed to deal with large belief networks. In a future version, we will implement an MCMC method for dealing with large nets. The following example of legal reasoning in a court case example comes from the paper Teaching an Application of Bayes' Rule for Legal Decision-Making: Measuring the Strength of Evidence , pp.
The following example comes from Figure In order to see the deductions made by the system in Example 2 , use the bayes command. You'll see the following table:. Added the variables colwidth default 35 and colgap default 5 which govern the output of the first column in a table. To see the first column of the table displayed by the bayes command above, I first had to do colwidth gets There is a function called js that allow you to execute arbitrary JavaScript.
It is currently commented-out on line 62 of AST. The logger variable introduced in the last release now defaults to false. The logger is a way to display info and warnings to the user. It's useful for development and debugging but may not make it to a beta release. Started coding support for conditional probabilities and Bayesian reasoning. Still at a very early stage. Given some input, the system will attempt to infer output based on Bayes' Rule , the Complement Rule for conditional probabilities, and the Law of total probability.
The system doesn't yet know the Chain Rule for conditional probabilities or rules such as Fienberg and Schervish , or Lindley Only the simplest cases work! Note that the system tells you how it's making its inferences. You can turn this behavior off by setting the variable logger to false as shown above. Raising a matrix to the power of T now performs matrix transpose. This is more cosmetically appealing alternative to the trans function:. The diag function now takes an array and constructs a matrix with it on the diagonal, everything else zeroed out:.
This would be a good place to compile all the ways we have so far of creating a 3x3 identy matrix:. Added a juxtaposition operator , which operates on space-separated numerals, variables or arrays when no operator is given. It works on 2 inputs at a time, but automatically folds left over more than two inputs. The juxtaposition operator is useful when you just want to add a bunch of numbers together and don't want to type in a bunch of plus signs.
The output is ugly, since Palamedes explains how its interpreting your input. By default the juxtaposition operator is set to plus. Change it to any 2-argument-or-greater function name e. You can use variables or arrays with the juxtaposition operator too. Here we use the last variable to continue a sum:. If the first variable is the same as a function name it applies the function instead! First we add 1 to N. The variable N is initially 0. But switching the order of N and 1 applies the normal random function to 1, returning a variate with mean 1 and variance Beware of precedence rulesThe juxtaposition operator is assumed where no operator is specified, and it takes precedence over other operators, but not other functions.
Juxtaposition folds to the left. Using a function to the left is OK, but using a function on the right produces an error. Using plus as the default juxtaposition operator behaves "correctly" with negative values:.
Palamedes doesn't have any builtin functions for computing covariances or correlations. That's because its matrix capabilities are so good, it's rather trivial just to apply the definitions. See the following links containing background info on these calculations:. So here is the same example redone in Palamedes including the conversion from a covariance matrix to correlation matrix:. If you apply var or sd to an array or matrix, it computes the sample standard deviation. So if you need the population statistics, you must use a correction factor.
For example, if you wanted to convert the Correlation matrix back to the population Variance-Covariance matrix, do this:. The whitespace space around the minus sign in N - 1 is needed. It's needed here because N does double duty as a random variate function, so N-1 would actually compute N -1,1. If we had used lowercase n , which isn't a function name, then we could write n-1 but this would then implicitly call the juxtaposition operator. If it were the default value of plus that wouldn't be a problem in this case. The reason for all this complexity is that without preceding space, the minus sign is part of the number: There is an example of computing stats for a simplified version of Chainmail combat using two completely different methods:.
Both sides simply face each other and slug it out until one or both sides has no troops left an absorption state. Both methods compute the expected number of turns to absorption, variance on the number of turns to absorption, and other information. But the Absorbing Markov chain model computes exact results. The Monte Carlo approximation agrees with these exact results:.
Added tensor expr,q,m,n tensor constructor to create m-by-n-by-p tensor. It varies p flor "planes" over The expression expr should be written in terms of the variables p, r and c. The values in these variables will not be permanently effectedthey are saved and later restored. Added matrix expr,m,n matrix constructor to create an m-by-n matrix. It varies r for "rows" over The expression expr should be written in terms of the variables r and c. Another way to create a 3-by-3 identity matrix Added array expr,m matrix constructor to create an array of length m.
It varies i for "index" over The expression expr should be written in terms of the variables i. The values in this variable will not be permanently effectedit is saved and later restored. Added update T,value,p,r,c , update M,value,r,c and update A,value,i functions. Updates the given object tensor, matrix or array with the given value at the given point, e. But update returns a new objectthe old value of the object T, M or A is not effected. Note that this doesn't really change the value of I unless you use an assignment, e. Added I n function to create an n-by-n identity matrix.
Another way to create a 3-by-3 identity matrix:. Added diag M function to create an diagonal matrix from M. Off-diagonal elements are zeroed out. The Original matrix M is uneffected. Modified Tokenizer so that Unicode subscripts and superscripts are valid chracaters in identifiers, e. By themselves d, f, k, x, z are not valid variable names -- they are dice operators. I'm not sure if I will keep this behavior or simply rewrite all the discrete probability distribution operators NB , geom , pois and so on as functions , in which case I would always need to use outer parens around the arg list: In short, this behavior is experimental and perhaps temporary.
This behavior will be stabilized when the code moves from the alpha to the beta stage. Fixed a bug in prob max a,b and prob min a,b that could result in bogus results when arguments a,b not iid. Calling mean[d6,d10,d20] returns a scalar with the mean of the array containing elements sampled randomly from the d6, d10, and d20 dice distributions, so you'll get a different result each time.
But mean d6,d10,d20 returns an array with the means of the d6, d10 and d20 dice distributions respectively. Arrays are first class citizens in the Palamedes language. But tuples are just part of the grammar for function calls, only understood by the parser. Additionally, mean[prob d6 ,prob d10 ,prob d20 ] returns an array of means. And mean [[1, 2, 3], [1, 3, 5], [0, 10, 20]] returns an array with the means of each row in the given matrix. These tricks only works with the functions mean , sd and var functions so far.
Added pair function to turn a pair of arrays into an array of pairs. Previously, min and max functions only computed probabilities for samples of iid random variables. Now they work on tuples or arrays of independent rv's, even if they're not identical, e.
Added var function to compute variance. Note that var [ Added var to the list of descriptive statistics returned by stats. But that only works with numeric literals: Added percent function to format output as percentage; an optional precision may be specified. If the random variable S is distributed as NB r, p: S is the number of successes before r failures.
NB r, p generates a random variate from this distribution. You can further format this expression with rat or human or percent , and then display it in a table with table. Again, you can further format this expression with rat or human or percent , and then display it in a table with table. What is the chance of n successes before 5 failures? We can make a table of probabilities, expressed as percents, as follows:.
The table contains additional 0. They are actually greater than zero, however, the percent formatting function rounded them down to zero. The average number of homes sold by the Acme Realty company is 2 homes per day. What is the probability that exactly 3 homes will be sold tomorrow? Annuity-immediate functions for present value and future value: See Annuities and Perpetuities for more details. If instead you want to see a 3x3 matrix with all possible matchups of the three terms with the three rates, use the outer product function as follows.
That's because at present the first argument to outer must be a function rather than an expression. In the output matrix, years are rows and rates are columns:. Note that using I and i for interest rates will overwrite their definitions for complex numbers and matrices. You can save the old values to temporary variables by doing oldi set i; oldI set I and restore them by doing the inverse.
Remember x means exploding die roll and z means zero-biased die roll, so do not use x or z as variable names!!! Don't use d , f or k either, because they're part of dice roll syntax also.
Buy 99 Percentile SAT Math - Probability, Perm/Comb, Numbers, Statistics & Sequence/Series: Read 2 Kindle Store Reviews - www.farmersmarketmusic.com Find helpful customer reviews and review ratings for 99 Percentile SAT Math - Probability, Perm/Comb, Numbers, Statistics & Sequence/Series at www.farmersmarketmusic.com
We use a 9-point numerical technique to approximate the derivative. For a description of how this is done, read the articles on Numerical differentiation and Finite difference coefficient. The Newton—Raphson method is used. This in turn uses the deriv function just mentioned. At most, one solution close to the starting guess will be foundthis function will not find all solutions. Then compare this appromination to JavaScript's value of Math. Here is a node. Start with a guess of 3 years However, it turned out unreliable and produced incorrect results in many cases, e. It has one optimization: This has been fixed.
Added ellipses to ends of lines in multi-line matrix output, to make it easier to copy and paste them back in as inputs. Note that cstr implicitly calls human to format numbers. Added polar notation operator for complex numbers: Added cpolar function to ouput a complex number in polar notation.
Note that cpolar implicitly calls human to format numbers. In the meantime, call the cexp function. Therefore, you must specify k as the second parameter. This can be very useful when you want to focus on an important calculation the expression in this case , and push the formatting the function in this case out of the way. The forward pipe operator has two restrictions:. In the following example, we compute the probability mass function of rolling 3d6. This normally returns a JSON object in which the values are floating-point decimals.
So we use the forward pipe operator first with the rat function to convert the decimals to rationals and second with the table function to convert the JSON object to a tabular format. Since matrix math is already implemented, we decided to implement complex math via 2x2 rotation matrix representations The convenience functions c and cstr allow for re-writing pairs of numbers as matrix reps of complex numbers and for re-writing a matrix rep of a complex number in terms of I and i:.
The functions Re real part , Im imaginary part , mag magnitude AKA modulus or absolute value , arg argument , and conj conjugate are implemented:. And also to divide via multiplication by a matrix inverse. These functions may not work consistently across browsers, because date-parsing algorithms are implementation-dependent. Unless stated otherwise, the following date functions may take arguments in the following formats: Or an array of such strings. Note that this is an array of arrays, so as not to be confused with an array of milliseconds since the epoch.
The following thee functions compute differences between two input days. They are not compatible with the [[year1,month1,day1],[year2,month2,day2]] or JSON object input format. You can pass in: In this case, the differences are computed pairwise. The addmonths date,months function adds the given number of months to the given date. The addyears date,years function adds the given number of years to the given date. The date argument to these functions must be a string or number representing ms since the epoch or an array of strings or number.
JSON objects and dates in the array format [year1,month1,day1] are not supported. Simple interval arithmetic has been implemented:. Predefined the following constants for convenience; you may overwrite them: It works on array inputs to produce a matrix. Here's another way to produce a 2x2 identity matrix:.
The following operators have been converted to functions: This means, among other things, their names are now case sensitive and they may be used with the forward pipe operator:. Check that the vectors in ortho1 u are indeed orthogonal to u via matrix multiplication cross. The arguments to cross must have compatible dimensions.