A textbook of Computer Based Numerical and Statiscal Techniques part 57 pps

10 221 0
A textbook of Computer Based Numerical and Statiscal Techniques part 57 pps

Đang tải... (xem toàn văn)

Thông tin tài liệu

546 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Under the null hypothesis H 0 , (i) σ x 2 = σ y 2 = σ 2 i.e., the population variances are equal or (ii) two independent estimates of the population variances are homogeneous, then the statistic F is given by F = S S x y 2 2 where S x 2 = 1 1 1 n – xx i i n – di 2 1 1 = ∑ S y 2 = 1 1 2 n – yy i j n – di 2 1 2 = ∑ It follows Snedecor’s F-distribution with d.f. ν 1 = n 1 –1 and ν 2 = n 2 –1. Also greater of two variances S x 2 and S y 2 is to be taken in the numerator and n 1 corresponds to the greater variance. The critical values of F for left tail test H 0 : σ 1 2 = σ 2 2 against H 1 : σ 1 2 < σ 2 2 are given by F < F n 1 –1, n 2 –1 (1–α) and for the two tailed test, H 0 : σ 1 2 = σ 2 2 against H 1 : σ 1 2 ≠ σ 2 2 are given by FF nn < −− F H I K 12 12 2 , α and FF nn < −− − F H I K 12 12 1 2 , α . 12.7.4 Fisher’s Z-test To test the significance of an observed sample correlation coefficient from an uncorrelated bivariate normal population, t-test is used. But in random sample of size n i from a normal bivariate population in which P ≠ 0 it is proved that the distribution of ‘r’ is by no means normal and in the neighbourhood of ρ = ± 1, its probability curve is extremely skewed even for large n. If ρ ≠ 0 Fisher’s suggested the transformation. Z = 1 2 log e 1 1 + r r– = tanh –1 r and proved that for small samples, the distribution of Z is approximately normal with mean ζ n = 1 2 log e 1 1 +ρ ρ– = tanh –1 ρ and variance 1/(n – 3) and for large values of n, (n > 50) the approximation is very good. Example 21. Two independent sample of sizes 7 and 6 had the following values: SampleA28303233312934 SampleB293030242728 Examine whether the samples have been drawn from normal populations having the same variance. Sol. H 0 : The variance are equal. i.e., σ 2 1 = σ 2 2 . i.e., the samples have been drawn from normal populations with same variance. H 1 : σ 1 2 ≠σ 2 2 TESTING OF HYPOTHESIS 547 Under null hypothesis, the test statistic F = s 1 2 s 2 2 (s 1 2 > s 2 2 ) Computations for s 1 2 and s 2 2 X 1 XX– 1 XX 1 1 2 – di X 2 XX 2 2 – XX 2 2 2 – di 28 – 3 9 29 1 1 30 – 1 1 30 2 4 32 1 1 30 2 4 33 2 4 24 – 4 16 31 0 0 27 – 1 1 29 – 2 4 28 0 0 34 3 9 28 26 X 1 = 31, n 1 = 7; Σ XX 1 1 2 – di = 28 X 2 = 28, n 2 = 6; Σ XX 2 2 2 – di = 26 s 1 2 = Σ XX n 1 1 2 1 1 – – di = 28 6 = 4.666; s 2 2 = Σ XX n 2 2 2 2 1 – – di = 26 5 = 5.2 F = s s 2 2 1 2 = 52 4666. = 1.1158. (3 s 2 2 > s 1 2 ) Conclusion: The tabulated value of F at ν 1 = 6 –1 and ν 2 = 7 –1 d.f. for 5% level of significance is 4.39. Since the tabulated value of F is less than the calculated value, H 0 is accepted i.e., there is no significant difference between the variance i.e., the samples have been drawn from the normal population with same variance. Example 22. The two random samples reveal the following data: Sample Size Mean Variance no. I 16 440 40 II 25 460 42 Test whether the samples come from the same normal population. Sol. A normal population has two parameters namely the mean µ and the variance σ 2 . To test whether the two independent samples have been drawn from the same normal population, we have to test (i) the equality of means (ii) the equality of variance. Since the t-test assumes that the sample variance are equal, we first apply F-test. F-test: Null hypothesis: σ 1 2 = σ 2 2 The population variance do not differ significantly. 548 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES Alternative hypothesis: σ 1 2 ≠ σ 2 2 Under the null hypothesis, the test statistic is given by F = s s 1 2 2 2 , (s 1 2 > s 2 2 ) Given: n 1 = 16, n 2 = 25; s 1 2 = 40, s 2 2 = 42 ∴ F = s s 1 2 2 2 = ns n ns n 11 2 1 22 2 2 1 1 – – = 16 40 15 × × 24 25 42× = 0.9752. Conclusion: The calculated value of F is 0.9752. The tabulated value of F at 16 –1, 25 –1 d.f. for 5% level of significance is 2.11. Since the calculated value is less than that of the tabulated value, H 0 is accepted, i.e., the population variance are equal. t-test: Null hypothesis: H 0 ; µ 1 = µ 2 i.e., the population means are equal. Alternative hypothesis: H 1 : µ 1 ≠ µ 2 Given: n 1 = 16, n 2 = 25, X 1 = 440, X 2 = 460 s 2 = ns ns nn 11 2 22 2 12 2 + + – = 16 40 25 42 16 25 2 ×+× + – = 43.333. ∴ s = 6.582 t = XX s nn 12 12 11 – + = 440 460 6582 1 16 1 25 – . + = – 9.490 for (n 1 + n 2 – 2) d.f. Conclusion: The calculated value of t is 9.490. The tabulated value of t at 39 d.f. for 5% level of significance is 1.96. Since the calculated value is greater than the tabulated value, H 0 is rejected. i.e., there is significant difference between means, i.e., µ 1 ≠ µ 2 . Since there is significant difference between means, and no significant difference between variance, we conclude that the samples do not come from the same normal population. PROBLEM SET 12.2 1. The following table gives the number of accidents that took place in an industry during various days of the week. Test if accidents are uniformly distributed over the week. Day Mon Tue Wed Thu Fri Sat No. of accidents 14 18 12 11 15 14 [Ans. H 0 is accepted] TESTING OF HYPOTHESIS 549 2. Verify whether Poisson distribution can be assumed from the data given below: No of defects Frequency .012345 61313843 [Ans. H 0 is accepted; Poisson distribution provides a good fit to the given data] 3. A survey of 320 families with 5 children shows the following distribution. No of boys Total No of girls Families . . 54 3 210 01 2 345 18 56 110 88 40 8 320 Given that values of χ 2 of 5 d.f. are 11.1 and 15.1 at 0.05 and 0.01 significance level respectively, test the hypothesis that male and female births are equally probable. [Ans. H 0 is accepted at 1% level of significance and rejected at 5% level of significance] 4. The following table gives the frequency of occupance of the digits 0, 1, , 9 in the last place in four logarithm of numbers 10-99. Examine if there is any peculiarity. Digits Frequency 0123456789 616151012123295 [Ans. No] 5. The sales in a supermarket during a week are given below. Test the hypothesis that the sales do not depend on the day of the week, using a significant level of 0.05. Days : Mon Tues Wed Thurs Fri Sat Sales (in 1000 Rs.):655460567184 [Ans. Accepted at 0.05 significant level] 6. A die is thrown 90 times with the following results: Face : 1 2 3 4 5 6 Total Frequency :10121614182090 Use χ 2 -test to test whether these data are consistent with the hypothesis that die is unbiased. Given χ 2 0.05 = 11.07 for 5 degrees of freedom. [Ans. Accepted at 0.05 significant level] 7. 4 coins were tossed at a time and this operation is repeated 160 times. It is found that 4 heads occur 6 times, 3 heads occur 43 times, 2 heads occur 69 times, one head occur 34 times. Discuss whether the coin may be regarded as unbiased. [Ans. Unbiased] 8. A sample analysis of examination results of 500 students, it was found that 280 students have failed, 170 have secured a third class, 90 have secured a second class and the rest, a first class. Do these figures support the general belief that above categories are in the ratio 4 : 3 : 2 : 1 respectively? [Ans. Yes, these figures support] 550 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 9. In the accounting department of bank, 100 accounts are selected at random and estimated for errors. The following results were obtained: No. of errors :0123456 No. of accounts :3540192022 Does this information verify that the errors are distributed according to the Poisson probability law? [Ans. May be] 10. Fit a Poisson distribution to the following data and best the goodness of fit: x :0 1 2 3 4 f : 109 65 22 3 1 [Ans. Poisson lawfits the data] 11. What are the expected frequencies of 2 × 2 contigency tables given below (i) ab cd (ii) 210 66 Ans. (i) acab bdab abcd abcd accd bdcd abcd abcd ++ ++ +++ +++ ++ ++ +++ +++ bgbg bgbg bgbg bgbg (ii) 48 48 12. In a locality 100 persons were randomly selected and asked about their educational achievements. The results are given below: Education Middle High school College Sex Male 10 15 25 Female 25 10 15 Based on this information can you say the education depends on sex. [Ans. Yes] TESTING OF HYPOTHESIS 551 13. The following data is collected on two characters: Smokers Non smokers Literature 83 57 Illiterate 45 68 Based on this information can you say that there is no relation between habit of smoking and literacy. [Ans. No] 14. In an experiment on the immunisation of goats from anthrax, the following results were obtained. Derive your inferences on the efficiency of the vaccine. Died anthrax Survived Inoculated with vaccine 210 Not inoculated 66 [Ans. No] 15. The lifetime of electric bulbs for a random sample of 10 from a large consignment gave the following data: Item 12345678910 42 46 39 41 52 38 39 43 44 56Life in ‘000’ hrs. Can we accept the hypothesis that the average lifetime of bulb is 4000 hrs ? [Ans. Accepted] 16. A sample of 20 items has mean 42 units and S.D. 5 units. Test the hypothesis that it is a random sample from a normal population with mean 45 units. [Ans. H 0 is rejected] 17. The following values gives the lengths of 12 samples of Egyptian cotton taken from a consignment: 48, 46, 49, 46, 52, 45, 43, 47, 47, 46, 45, 50. Test if the mean length of the consignment can be taken as 46. [Ans. Accepted] 18. A sample of 18 items has a mean 24 units and standard deviation 3 units. Test the hypothesis that it is a random sample from a normal population with mean 27 units. [Ans. Rejected] 19. A filling machine is expected to fill 5 kg of powder into bags. A sample of 10 bags gave the following weights: 4.7, 4.9, 5.0, 5.1, 5.4, 5.2, 4.6, 5.1, 4.6 and 4.7. Test whether the machine is working properly. [Ans. Accepted] 20. Memory capacity of 9 students was tested before and after a course of meditation for a month. State whether the course was effective or not from the data given below. Before After 10 15 9 3 7 12 16 17 4 12178561118203 [Ans. H 0 is accepted] 552 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 21. A certain stimulus administered to each of 12 patients resulted in the following increase of blood pressure: 5, 2, 8, – 1, 3, 0, – 2, 1, 5, 0, 4, 6. Can it be concluded that the stimulus will in general be accompanied by an increase in blood pressure? [Ans. H 0 is rejected] 22. The mean life of 10 electric motors was found to be 1450 hrs with S.D. of 423 hrs. A second sample of 17 motors chosen from a different batch showed a mean life of 1280 hrs with a S.D. of 398 hrs. Is there a significant difference between means of the two samples? [Ans. Accepted] 23. The height of 6 randomly chosen sailors in inches are 63, 65, 68, 69, 71 and 72. Those of 9 randomly chosen soldiers are 61, 62, 65, 66, 69, 70, 71, 72 and 73. Test whether the sailors are on the average taller than soldiers. [Ans. H 0 is accepted] GGG Computer ProgrammingComputer Programming Computer ProgrammingComputer Programming Computer Programming in ‘C’ Languagein ‘C’ Language in ‘C’ Languagein ‘C’ Language in ‘C’ Language 13.1 INTRODUCTION At its most basic level, programming a computer simply means telling it what to do, and this vapid-sounding definition is not even a joke. There are no other truly fundamental aspects of computer programming; everything else we talk about will simply be the details of a particular, usually artificial, mechanism for telling a computer what to do. Sometimes these mechanisms are chosen because they have been found to be convenient for programmers (people) to use; other times they have been chosen because they’re easy for the computer to understand. The first hard thing about programming is to learn, become comfortable with, and accept these artificial mechanisms, whether they make ‘sense’ to you or not. Many computer programming mechanisms are quite arbitrary, and were chosen not because of any theoretical motivation but simply because we needed an unambiguous way to say something to a computer. C is sometimes referred to as a “high-level assembly language”. Elements of Real Programming Languages There are several elements which programming languages, and programs written in them, typically contain. These elements are found in all languages, not just C. 1. There are variables or objects, in which you can store the pieces of data that a program is working on. Variables are the way we talk about memory locations (data). Variables may be global (that is, accessible anywhere in a program) or local (that is, private to certain parts of a program). 2. There are expressions, which compute new values from old ones. 3. There are assignments which store values (of expressions, or other variables) into variables. 4. There are conditionals which can be used to determine whether some condition is true, such as whether one number is greater than another. In some languages, including C, conditionals are actually expressions which compare two values and compute a ‘true’ or ‘false’ value. 5. Variables and expressions may have types, indicating the nature of the expected values. 6. There are statements which contain instructions describing what a program actually does. Statements may compute expressions, perform assignments, or call functions. 7. There are control flow constructs which determine what order statements are performed in. A certain statement might be performed only if a condition is true. A sequence of several statements might be repeated over and over, until some condition is met; this is called a loop. CHAPTER 13 553 554 COMPUTER BASED NUMERICAL AND STATISTICAL TECHNIQUES 8. An entire set of statements, declarations, and control flow constructs can be lumped together into a function (also called routine, subroutine, or procedure) which another piece of code can then call as a unit. 9. A set of functions, global variables, and other elements makes up a program. 10. In the process of specifying a program in a form suitable for a compiler, there are usually a few logistical details to keep track of. These details may involve the specification of compiler parameters or interdependencies between different functions and other parts of the program. Computer Representation of Numbers Most computers represent integers as binary numbers with a certain number of bits. A computer with 16-bit integers can represent integers from 0 to 65,535 or if it chooses to make half of them negative, from –32,767 to 32,767. A 32-bit integer can represent values from 0 to 4,294,967,295, or + –2,147,483,647. Most of today’s computers represent real (i.e., fractional) numbers using exponential notation. The advantage of using exponential notation for real numbers is that it lets you trade off the range and precision of values in a useful way. Since there’s an infinitely large number of real numbers, it will never be possible to represent. Characters, Strings, and Numbers One fundamental component of a computer’s handling of alphanumeric data is its character set. A character set is, not surprisingly, the set of all the characters that the computer can process and display. (Each character generally has a key on the keyboard to enter it and a bitmap on the screen which displays it.) A character set consists of letters, numbers, and punctuation. A character is, well, a single character. If we have a variable which contains a character value, it might contain the letter ‘A’, or the digit ‘2’, or the symbol ‘&’. A string is a set of zero or more characters. For example, the string “and” consists of the characters ‘a’, ‘n’, and ‘d’. Compiler Terminology C is a compiled language. This means that the programs we write are translated, by a program called a compiler, into executable machine-language programs which we can actually run. Executable machine-language programs are self-contained and run very quickly. A compiler is a special kind of progam: it is a program that builds other programs. The main alternative to a compiled computer language or program is an interpreted one, such as BASIC . In other words, for each statement that you write, a compiler translates into a sequence of machine language instructions which does the same thing, while an interpreter simply does it. Example Program to print “hello, world” or display a simple string, and exit. # include < stdio.h> main() { printf (“Hello, word!\n”); return 0; } COMPUTER PROGRAMMING IN ‘C’ LANGUAGE 555 Printf is a library function which prints formatted output. The parentheses surround printf’s argument list: the information which is handed to it which it should act on. The semicolon at the end of the line terminates the statement. The second line in the main function is return 0; In general, a function may return a value to its caller, and main is no exception. When main returns (that is, reaches its end and stops functioning), the program is at its end, and the return value from main tells the operating system whether it succeeded or not. By convention, a return value of 0 indicates success. Basic Data Types and Operators The type of a variable determines what kinds of values it may take on. An operator computes new values out of old ones. An expression consists of variables, constants, and operators combined to perform some useful computation. There are only a few basic data types in C. l char a character l int an integer, in the range – 32,767 to 32,767 l long int a larger integer (up to +–2,147,483,647) l float a floating-point number double a floating-point number, with more precision and perhaps greater range than float. Constant: A constant is just an immediate, absolute value found in an expression. The simplest constants are decimal integers e.g., 0, 1, 2, 123. Occasionally it is useful to specify con- stants in base 8 or base 16 (octal or hexadecimal). A constant can be forced to be of type long int by suffixing it with the letter L. A constant that contains a decimal point or the letter e (or both) is a floating-point constant: 3. 14, .01, 123e4, 123.456e7. The e indicates multiplication by a power of 10; 123.456e7 is 123.456 times 10 to the 7th, or 1,234, 560,000. A character constant is simply a single character between single quotes: ‘A’, ‘.’, ‘%’. The numeric value of a character constant is, naturally enough, that character’s value in the machine’s character set. Characters enclosed in double quotes: “apple”, “hello, world”, “this is a test”. Within character and string constants, the backslash character \ is special, and is used to represent characters not easily typed on the keyboard or for various reasons not easily typed in constants. The most common of these “character escapes” are: \n a “newline” character \b a backspace \r a carriage return (without a line feed) \‘ a single quote (e.g., in a character constant) \” a double quote (e.g., in a string constant) \\ a single backslash Declarations: Informally, a variable (also called an object) is a place where computer can store a value. So that they can refer to it unambiguously, a variable needs a name. A declaration tells the compiler the name and type of a variable we’ll be using in our program. In its simplest form, a declaration consists of the type, the name of the variable, and a terminating semicolon: . set of all the characters that the computer can process and display. (Each character generally has a key on the keyboard to enter it and a bitmap on the screen which displays it.) A character. programs we write are translated, by a program called a compiler, into executable machine-language programs which we can actually run. Executable machine-language programs are self-contained and. the mean length of the consignment can be taken as 46. [Ans. Accepted] 18. A sample of 18 items has a mean 24 units and standard deviation 3 units. Test the hypothesis that it is a random sample

Ngày đăng: 04/07/2014, 15:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan