text: Software verification is often the last defense against disasters caused by faulty software development. ... Testability. I In extreme cases a lack of testability may hinder testing parts of the software or software requirements at all. Everyone thinks that quality will improve if you perform more tests. Review your networking options and choose ... Stay on top of the latest news, analysis and expert advice from this year's re:Invent conference. Separation of concerns is a best practice for software design and implementation, but not for software analysis, which needs a holis-tic view of software. As stated by Binder [6] and Freedman [7] âa Testable Software is one that can be tested easily, systematically and externally at the user interface level without any ad-hoc measureâ. However, one important factor is often overlooked â software testabilityâ¦ This article will give you a list of Software Quality attributes in quality assurance and quality control. In the world of software architecture there are many â-ilitiesâ you must take into consideration with every project. S Developers used to think it was untouchable, but that's not the case. The programs must display the functional, structural, code simplicity so that programs are easier to test. Σ Design for Testability. Software is only testable through the user interface, and there are no tracing systems or logs to identify what went wrong during a failed test. These modules are then integrated to make the final Portability These characteristics are further decomposed into subcharacteristicsas shown in the following table, adapted from Chapter 17 ofSoftware Testing and Quality Assurance: Theory andPracticeby Naik and Tripathy, 2008. Based on this measure, a testability hierarchy has been proposed.[2][3]. ( {\displaystyle O_{k}} Copyright 2019 - 2020, TechTarget Is it easy to check and test the product? High testability means it is easy to find and isolate faults as part of your team's regular testing process. The problem with this assumption is that the emphasis is on selecting input data, and not on determining whether the given program is easily testable or not. ∉ , = But software testability is a tall order, and it can also be an expensive one. In software, testability refers to the degree that any module, requirements, subsystem or other component of your architecture can be verified as satisfactory or not. {\displaystyle F_{S}:I\to O} (IEEE Std 610.12) between software testing and software testability. For example, Google's ReCAPTCHA, without having any metadata about the images is not a testable system. Prioritizing them is necessary because the client will optimistically ask that you do all of them. Given this, it is somewhat surprising that many folks working in Software don't consider the idea of testability. While soft-ware testing aims to assess the quality of software produced, software testability is not concerned with whether the software is producing correct or incorrect results [3]. τ CHARACTERISTICS OF GOOD SOFTWARE While developing any kind of software product, the first question in any ... Testability : Testing the software should be easy. {\displaystyle O_{t}} However, this is incorrect. τ The characteristics of Software Contracts described above are part of the specification of a class, not its implementation. testability research issue should lay more emphasis on the interaction between software and testing criterion. ISO/IEC 9126defines software quality as a structured set of individual quality characteristics. Software testability is a software characteristic that refers to the ease with which some formal or informal testing criteria can be satisfied. -Traceability: the product logs actions at appropriate levels and in usable format. passes, else the system fails the test input. Testing can achieve two main Software functional quality reflects how well it complies with or conforms to a given design, based on functional requirements or specifications. Is it easy to check and test the product? Sign-up now. ) Usually, testing costs on the large scales of 50% during software system development phase. Understandability: The degree to which the component under test is documented or self-explaining. There are varying metrics that can be applied to this measurement. Cookie Preferences Therefore, obviously without algebraic consistency, no such function can be found, and therefore, the specification cease to be termed as testable. Even though testability can not be measured directly (such as software size) it should be considered an intrinsic property of a software artifact because it is highly correlated with other key software qualities such as encapsulation, coupling, cohesion, and redundancy. It seems that testers think that the most important testability issue is to have an API, so they can exercises it in automation scripts. , ISO/IEC 25010 (2011) refines this model with two new top-levelcategories particularly related to internet technoloâ¦ Software testability analysis helps in quantifying testability value. In order to link the testability with the difficulty to find potential faults in a system (if they exist) by testing it, a relevant measure to assess the testability is how many test cases are needed in each case to form a complete test suite (i.e. Therefore, the ideal software generates the tuple , Remarkably, ISO 9126 does not provide a consensual set of measures for estimating maintainability on the basis of a systemâs source code. Granted, not all companies are on board, but since software is now a key competitive differentiator, you're either on the testability train or you're on the tracks. From the domain of distributed real-time systems we know that the architecture (high-level design) of a software system can be a main factor of testability. Voas But testing problems need not be inevitable. A proliferation of software reliability models have emerged as people try to understand the characteristics of how and why software fails, and try to quantify software reliability. This aids in testability because the method itself can be the only transformation for a given input into a specific output. It is the state of software artifact, which decides the difficulty level for carrying out testing activities on that artifact. The GitHub master branch is no more. Then, we'll explain what architects can do to move toward testability. Please check the box if you want to proceed. Share on. a test suite such that, if it is applied to the implementation under test, then we collect enough information to precisely determine whether the system is correct or incorrect according to some specification), a testability hierarchy with the following testability classes has been proposed:[2] Measuring Software Testability Modulo Test Quality. Testability is a software quality characteristic that is of major relevance for test costs and software dependability. Σ They found that some Σ This function "V" is known as the verification function for the system with input I. 5 key software testability characteristics. Software testability and related attributes A software system is testable if it gives up (exposes) its faults easily to the tester. ∈ V a test suite such that, after applying all test cases to the system, collected outputs will let us unambiguously determine whether the system is correct or not according to some specification). To predict and improve software testability, a large number of techniques and metrics have been proposed by both practitioners and researchers in the last several decades. Find a point where you can add the most testability for the least price and get to work. 1. One of the things that I like about testability is that it is a part of quality characteristics. Add specifics for your context, and transform the list to your own. Class I: there exists a finite complete test suite. Don't sweat the details with microservices. Testability software has been defined by ISO. What should the core abstractions be? Software validation generally refers to the process of showing that software is computing an expected function. A testable architecture should clearly show integration points between swappable components that run in isolation. We'll send you an email containing your password. Software testability is the degree to which a software system or a unit under test supports its own testing. τ Heterogeneity: The degree to which the use of diverse technologies requires to use diverse test methods and tools in parallel. Other work adds extra characteristics like understandability, traceability and test-support capability [18] to the testability notion. . Data center backup processes take a week to test, during which there is no environment available for regular testing. Easy to operate: High quality software can be tested in a better manner. Letâs assume the following about software development. Over 200 models have been developed since the early 1970s, but how to quantify software reliability still remains largely unsolved. Description how to recognize characteristics of the ADA in an artifact In this paper, we address the following problem: Software testability: | |Software testability| is the degree to which a software artifact (i.e. Still, testability is not an explicit focus in todayâs industrial software development projects. How should they interact with each other? S : t or {\displaystyle \Sigma } (software) But software testability is a tall order, and it can also be an expensive one. This is one of the main drivers behind the switch to test automation. Testability of Software Components 3 output data characteristics and states of the component is small. . Software testability is the degree to which a software artifact (i.e. Automatability: The degree to which it is possible to automate testing of the component under test. on the testability of the software. Testability: Testability is a characteristic that indicates whether a system or component can accurately determine its status (operation, failure, or performance degradation) and isolate its internal failure in a â¦ However, testability has always been an elusive, context-sensitive concept and its correct measurement is a difï¬cult exercise [5]. k ; The practical feasibility of observing a reproducible series of such counterexamples if they do exist. {\displaystyle \tau } No problem! Software Reliability Models. Software testability analyses can exposure the weakness of the software testability and guide the design for software testability. This post covers part two of my 2010 talk on testability. τ which is the input-output set It is used to validate the software product. There are a couple ways to connect the disparate pieces of a multi-cloud architecture. Approaches of Software Testing - Tutorial to learn Approaches of Software Testing in simple, easy and step by step way with syntax, examples and notes. The inclusion into Class I does not require the simplicity of the assumed computation model, as some testing cases involving implementations written in any programming language, and testing implementations defined as machines depending on continuous magnitudes, have been proved to be in Class I. If the implementation under test must be a deterministic finite-state machine failing the specification for a single trace (and its continuations), and its number of states is unknown, then it only belongs to classes from Class III on. Now, take a test input In software, testability refers to the degree that any module, requirements, subsystem or other component of your architecture can be verified as satisfactory or not. If the testability of the software artifact is high, then finding faults in the system (if it has any) by means of testing is easier. Therefore, it is of imperative importance to figure out : can we or can we not create a function that effectively translates into the notion of the set indicator function for the specification set To predict and improve software testability, a â¦ There will be a million reasons why this seems impossible. This enables them recreate failures, isolate them and find the proper fix. Learn how and when to remove this template message, "A General Testability Theory: Classes, properties, complexity, and testing reductions", Improving testability of object-oriented systems, https://en.wikipedia.org/w/index.php?title=Software_testability&oldid=971218068, Articles lacking in-text citations from September 2014, Creative Commons Attribution-ShareAlike License, Properties of the software itself (such as size, complexity and testability), Properties of the development- and testing processes, Qualification and motivation of the persons involved in the test process. This classification can be achieved by noticing that, to be testable, for a functionality of the system under test "S", which takes input "I", a computable functional predicate "V" must exists such that Falsifiability or defeasibility, which means that counterexamples to the hypothesis are logically possible. k ISO9126 Software Quality Characteristics and their role in Software Quality Assurance. In this article you will have a look at the capabilities of the HttpClient component and also some hands-on examples. Software testability is not a characteristic of source code artifacts alone. quantitative (a requirement like "fast response time" can not be, verification/verifiable in practice (a test is feasible not only in theory but also in practice with limited resources). generates output AWS re:Invent 2020 underscores push toward cloud in pandemic, Multi-cloud networking -- how to choose the right path, Why GitHub renamed its master branch to main, An Apache Commons FileUpload example and the HttpClient, 10 microservices quiz questions to test your knowledge. Do Not Sell My Personal Info. Changes to the hardware, operating system, software dependencies, and organizational business rules and policies are handled in adaptive maintenance. tions. Why is unit testing important for developers? Adaptive maintenance includes the environmental changes where your software is living. The test environment is such a scaled-down version of production that it cannot realistically simulate real workloads. A testable architecture should clearly show integration points between swappable components that run in isolation. Separation of concerns. Nowadays software testability analyses include three facets: test cost analysis, sensitivity analysis and testable characteristics analysis. Testability is (1) the degree that characteristics that provide for testing exist, and (2) the degree to which economically feasible tests can be devised for determining whether the developed software will satisfy the requirements. I I Class IV: there exists a complete test suite. Broadening your understanding of what it means to be a valuable member of a modern software development team. Add specifics for your context, and transform the list to your own. O Software Testability actually acts as a software support characteristic for making it easier to test. Set up an environment and tooling to recreate the system that had the problem, reproduce that problem quickly, monitor the issue and then fix and retest as necessary. ) The totality of characteristics of an entity that bear on its ability to satisfy stated or implied needs â ISO; ... Testability. Join Richard Bradshaw on the 10th of February 2021 at 1 PM (New York, US Time) where you will be creating a testability canvas using the 10 P's as guiding characteristics and exploring each one of them. Context: Software testability is the degree to which a software system or a unit under test supports its own testing. {\displaystyle \tau \not \in \Sigma } The aim is to release bug-free, performant software that wonât cost you a fortune in backend running costs. Σ a software system, software module, requirements- or design document) supports testing in a given test context. Software testability is the degree to which a software artifact (i.e. Many software systems are untestable, or not immediately testable. , which generates the output In environments where this is the case it is a frustrating task getting testability changes incorporated into the product, as these are inevitably perceived as lower priority than more marketable features. This is determined by both aspects of the system under test and its development approach. Hence as a software examiner when we focus on the quality of the professional software, we have to take into account the environment at where the software is used and behavior of software changed by people apart from its developers. Σ Boehm introduced his software quality model. O In this article, we'll review the major differences between a testable architecture and one that's lacking. ( A system that does not have adequate and appropriate supportability characteristics cannot be supported. Related: Software Development ) f) Modularity : Any software is said to made of units and modules which are independent of each other. {\displaystyle \tau =(I_{t},O_{t})} This is because if the software is designed and implemented considering quality, then comparatively fewer errors will be detected during the execution of tests. The main studies of testability reported in the literature investigate the relation between class metrics and test effort in terms of the size and complexity of the associated test suites. Software testability estimates such property by relating code characteristics to the test effort. Software Quality Characteristics Go through the list and think about your product/features. such that input Testing is a critical stage of the software development lifecycle. is the testability function for the specification F Testability features are integrated into the FMECA module and are intended for in-depth Testability analysis. S Other things being equal, and on average: The testability is, thus, an important aspect in ensuring the quality, stability, and predictability of the software system in production. Then, we'll explain what architects can do to move toward testability. There are several characteristics of testability, which are listed below. Σ For instance, testing when we assume that the behavior of the implementation under test can be denoted by a deterministic finite-state machine for some known finite sets of inputs and outputs and with some known number of states belongs to Class I (and all subsequent classes). Because automation is cool and it will get them a better job. {\displaystyle I_{t}} The effort and effectiveness of software tests depends on numerous factors including: The testability of software components (modules, classes) is determined by factors such as: The testability of software components can be improved by: Based on the amount of test cases required to construct a complete test suite in each context (i.e. Software testability is the degree to which a software artifact (i.e. In general, the more difficult, ... Software testability analysis measures the benefit provided by a software testing scheme to a particular program. Efforts may be considered in terms of inputs required in testing such as coverage of testing scenarios, the number of test cases, timâ¦ Higher testability: more better tests, same cost. Given this meta information, one can test the system. I This post covers part two of my 2010 talk on testability. Therefore, testability is often thought of as an extrinsic property which results from interdependency of the software to be tested and the test goals, test methods used, and test resources (i.e., the test context). Testability comprises these characteristics and is an important factor to achieve an efï¬cient and effective test process. Controllability: The degree to which it is possible to control the state of the component under test (CUT) as required for testing. 2.1Software Testability. Understanding Testability. ... Testability. Two heads are better than one when you're writing software code. standing for specification. O Controllability determines the work it takes to set up and run test cases and the extent to which individual functions and features of the system under test (SUT) can be made to respond to test â¦ software characteristics. ... Testability : Testing the software should be easy. I ... Letâs consider at some of the characteristics that easy-to-test code should have: t Software Quality Characteristics Go through the list and think about your product/features. f) Modularity : Any software is said to made of units and modules which are independent of each other. Comprehensive software testability should identify dynamic elements and events of a system, as well as system boundaries and interfaces. Software testing is one of the most powerful methods to improve the software quality directly. The two have many common characteristics such as relying on the ability to obtain information on the state of the system and the actions that have been performed on it. Join Richard Bradshaw on the 5th of August 2020 at 1 PM (New York, US Time) where you will be creating a testability canvas using the 10 P's as guiding characteristics and exploring each one of them. Home Conferences ICSE Proceedings ICPC '20 Measuring Software Testability Modulo Test Quality. To help you out, here is a quick list outlining my top 7 default â-ilitiesâ in the order that I prioritize them: 1. [3]. . {\displaystyle V(S,I)} a software system, software module, requirements- or design document) supports testing in a given test context. This is wrong, because finding the right application oracles belongs to software testing basic skills, and if you are a software tester, oracles are more important artifacts than automation scripts. Testing consumes a significant amount of time and effort within an average software development project. However, if the number of states is not known, then it only belongs to all classes from Class II on. Robert V. Binder: Testing Object-Oriented Systems: Models, Patterns, and Tools, This page was last edited on 4 August 2020, at 20:50. Maintainability 6. But you can either fix it or learn to live with the burden of an opaque architecture. What makes a software system easier or harder to test? Rather, software testability concerns the characteristics of the software that Adding testability can even see an improved feature set. Mar 6, 2016 When designing a new software project, one is often faced with a glut of choices about how to structure it. {\displaystyle \Sigma } Start my free, unlimited access. Other elaborated cases, such as the testing framework by Matthew Hennessy under must semantics, and temporal machines with rational timeouts, belong to Class II. → Analyses for object-oriented software testability, considering the economic factor, and evaluating the actual value â¦ Three of the principal supportability characteristics of any design are its reliability, maintainability, and testability. Software Requirement Specifications. Software complexity is another metric that tries to relate how difficult a program is to understand. It should also provide a scriptable test infrastructure that enables programmers and testers to reproduce exact scenarios that happen in production. Introduction 1.2 Software Testability occur in the software. 1 3. In software, testability refers to the degree that any module, requirements, subsystem or other component of your architecture can be verified as satisfactory or not. Functionality 2. In this article, we'll review the major differences between a testable architecture and one that's lacking. Controllability determines the work it takes to set up and run test cases and the extent to which individual functions and features of the system under test (SUT) can be made to respond to test cases. If this size is small, then the testability is high. Testability is valuable and is a quality characteristic of a software system, along with all-time classics like functionality, security, and performance. It helps in determining the efforts that will be needed to execute test activities on a particular software artifact based on its testability. The production of the requirements stage of the software development process is Software Requirements Specifications (SRS) (also called a requirements document).This report lays a foundation for software engineering activities and is constructing when entire requirements are elicited and analyzed. Object-oriented software testability 281 In the object-oriented paradigm, objects are atomic units of encapsulation, classes man age collections of objects, and inheritance structures collections of classes.Objects par tition the state of computation into encapsulated units. Class III: there exists a countable complete test suite. {\displaystyle 1_{\Sigma }} {\displaystyle (I_{k},O_{k})} Reliability 3. Usability 4. It has been proved that each class is strictly included into the next. Supportability engineering activities encompass all aspects of system design. Covers topics like System testing, Debugging process, Debugging Strategies, Characteristics of testability, Attributes of 'good' test, Difference between white and black box testing, Basic Path Testing, Control structure testing, â¦ We call the systematic approach to high test-ability of software systems testability engineering. Take this 10-question quiz to boost your microservices knowledge and impress ... All Rights Reserved, Thesis Committee: Chair: prof. dr. Arie van Deursen, Faculty EEMCS, TU Delft The organization tests messages moving between IoT devices and the network, but without tracing individual service calls from the applications. ). ( The existence should not merely be asserted, should be proven rigorously. Now, the question is whether or not By these modifications to the environment, changes can occur in the other parts of the software. Therefore, software has characteristics that are considerably different than those of hardware. Software testability is now established to be a distinct software quality characteristics [4]. t If I had to design software architecture for this online marketplace, then among its five maintainability characteristics I would optimise for (in this order): 1. testabilityâ¦ {\displaystyle \Sigma } Usability Software testability analysis can help developing a more test friendly testable applications. Isolateability: The degree to which the component under test (CUT) can be tested in isolation. Weigh the pros and cons of outsourcing software development, Software development outsourcing throughout the lifecycle, How Amazon and COVID-19 influence 2020 seasonal hiring trends, New Amazon grocery stores run on computer vision, apps. Class III: there exists a complete testing [ 2 ]: Half empty or Half full is a! Is testable if it gives up ( exposes ) its faults easily to process! Service calls from the applications at the capabilities of the product, and organizational rules! Characteristic of a systemâs source code document ) supports testing in a better job systems from systems! Degree of testability, ISO 9126 does not have adequate and appropriate supportability can! Are integrated into the FMECA module and are intended for in-depth testability measures. Testability means it is possible to observe ( intermediate and final ) test results program. Analysis measures the benefit provided by a software support characteristic for making it easier or to... Available, and we need to obtain information about the images is not known, the. Some testability features are integrated into the FMECA module and are intended for in-depth testability analysis V '' is as! That each class is strictly included into the next is to understand measurement... Increased test effort be testable if it gives up ( exposes ) its faults easily to the hardware, system. That tries to relate how difficult a program is to release bug-free, performant software wonât. Are its reliability, maintainability, and transform the list to your own often the last defense against caused... Supports testing in a given design, based on functional requirements or.. Parts of the most powerful methods to improve the software testability estimates a. Scales of 50 % during software system make it easier or harder to test and! Still, testability is the degree to which a software artifact ( i.e are testable, and.... Events of a software system, as well as system boundaries and interfaces testability and the! Cost analysis, sensitivity analysis and testable characteristics analysis software testability characteristics: Half empty Half! The switch to test automation Std 610.12 ) what makes a software system development phase to! Testability comprises these characteristics and states of the software system, who made the and... We 'll explain what architects can do to move toward testability have look. Final software are then integrated to make the final testability of software engineering, software quality as structured! ( IEEE Std 610.12 ) what makes a software artifact ( i.e part two of my 2010 talk testability! ) what makes a software testing is a software system or a unit under test process! Measures the benefit provided by a software system, software has characteristics that are considerably than! Requirements- or design document ) supports testing in a given test context all of them there exists countable... With which some formal or informal testing criteria can be tested in a better job article, we review! Five key elements that fortify an architecture 's testability: more better,... The process of showing that software is defined as collection of computer programs, procedures rules. Finally, look at the capabilities of the software testability is not,! Each other document ) supports testing in a better manner ( exposes ) its faults easily the. Can not realistically simulate real workloads is that it can also be expensive... Collection ever assembled software reliability still remains largely unsolved results in increased test effort faults easily to the process showing! And we need to obtain a lot of information quickly quality will improve if you want to.! Testability because the client will optimistically ask that you do all of them ICPC '20 software! Of diverse technologies requires to use diverse test methods and tools in parallel degree of.. Characteristics that are considerably different than those of hardware and it can not realistically simulate real workloads pieces. Moving between IoT devices and the network, but that 's not the case {... A list of software is said to be testable if it has been proposed [! Set, the test results to calculate the test effort be testable if it gives (... Why this seems impossible often the last defense against disasters caused by faulty software development existence! Information about the images is not a testable architecture should clearly show integration points swappable. Caused by faulty software software testability characteristics project to each piece of a system, software has characteristics that considerably... Complexity is another metric that tries to relate how difficult a program is to understand test-ability of Contracts... 'Ll review the major differences between a testable architecture should clearly show integration points between components. In usable format main drivers behind the switch to test automation broken system is the to. Of a class, not its implementation and its development approach this meta information, one can the!, testability has always been an elusive, context-sensitive concept and its development approach quality.. Well as system boundaries and interfaces efforts that will be a million reasons why this seems impossible and final test. Methods to improve the software software design for software testability is valuable and an! Its implementation more test friendly testable applications is no environment available for regular testing process industrial... Analyze the test tuple τ { \displaystyle \tau } passes, else the system under test CUT! Of computer programs, procedures, rules and data how difficult a program is to understand, concept. Proposed. [ 2 ] [ 3 ] two components: part two of my 2010 talk testability. It will get them a better manner the characteristics of testability results in increased test.... Help developing a more test friendly testable applications key elements that fortify an architecture 's testability: product! A week to test, during which there is no environment available for regular testing.... And performance incomplete capability to distinguish correct systems from incorrect systems ) can be reached with a finite test... Learn to live with the burden of an entity that bear on its ability to satisfy stated implied... Testing scheme to a particular program ) test results simplicity so that programs are easier to test factor to an! Same cost obtain a lot of information quickly changes were made its faults easily to the testability not! Many software systems testability engineering of time and effort within an average software development.! Extra characteristics like understandability, traceability and test-support capability [ 18 ] to the process of showing software... Not realistically simulate real workloads the other parts of the software should be proven rigorously testability and the! Its requirements can even see an improved feature set its testability to connect the disparate pieces of a systemâs code! Ask that you do all of them issue should lay more emphasis on the large scales of 50 during! | |Software testability| is the one with the burden of an opaque architecture not case! Must display the functional, structural, code simplicity so that programs easier! Get them a better manner test-ability of software quality attributes in quality Assurance and quality control incomplete to. Find and isolate faults as part of quality characteristics Go through the list and think about your.... Test methods and tools in parallel formally, some systems are testable, and the most powerful methods to the., without having any metadata about the quality of the principal supportability characteristics of systems. Is determined by both aspects of the software scaled-down version of production that it is in the.! Development lifecycle each piece of software architecture there are varying metrics that can be satisfied software modules, UML,! Difficult,... software testability analysis can help developing a more test testable... Ease with which some formal or informal testing criteria can be immediately tested if for image... Std 610.12 ) what makes a software testing scheme to a given design, based on requirements! Stability, and predictability of the software or software requirements at all or implied needs â ;. In isolation testability concerns the characteristics of the largest online encyclopedias available, and we need to obtain lot. If you want to proceed 'll explain what architects can do to move toward.! Function  V '' is known as the verification software testability characteristics for the least testability V! Software systems testability engineering logically possible of individual quality characteristics the set the... Finite test suite component is small, then it only belongs to all from., the test tuple τ { \displaystyle \tau } passes, else the system under test CUT... Reproduce exact scenarios that happen software testability characteristics production the things that I like about testability the! An elusive, context-sensitive concept and its correct measurement is a part of your team 's regular process... ) what makes a software artifact ( i.e between IoT devices and the most collection... List of software systems testability engineering isolate faults as part of the of. For estimating maintainability on the interaction between software and testing criterion include facets. Against disasters caused by faulty software development projects belongs to all classes class... High quality software can be reached with a finite test suite, rules and data testers reproduce! Is known as the verification function for the least testability testability results in increased test effort test context isolate as... Strictly included into the next better than one when you 're writing software.! In a given test context operating system, software module, requirements- or design document supports! 2010 talk on testability heterogeneity: the degree to which a software system in production and... But software testability key elements that fortify an architecture 's testability: testing the software software! Thinks that quality will improve if you want to proceed check the box if you more. Verification function for the least testability a reproducible series of such counterexamples if they do exist has always been elusive...


text:
## 11.7 File structure and workflow

As projects get bigger, it is really important that they are well organised. This will avoid errors and make collaboration easier.

Here is our suggested approach.

All projects must reside within an RStudio Project that has a meaningful name (not MyProject!). Never work within the (Home) or root directory. Projects should be initiated with a Git repository for version control (see Chapter 13).

proj/
- scripts/
- data/
- doc/
- figs/
- 00_analysis.Rmd

scripts/ contains all the .R script files used for data cleaning/preparation.
data/ contains all raw data, such as .csv files.
doc/ contains all output documents and reports, such as .doc and .PDF files.
figs/ contains all figures and plots.
00_analysis.Rmd or 00_analysis.R is the actual main working file, and we keep this in the main project directory. We prefix this with 00 so it is always obvious which is the main file.

### 11.7.1 Data cleaning

This is all done in specific .R files, which are kept in the scripts/ folder, and are clearly labelled, e.g.

scripts/0_source_all.R
scripts/02_make_factors.R
scripts/03_duplicate_records.R

For instance, 01_data_upload.R may look like this.

# Melanoma project

# Get data
here::here("data", "melanoma.csv")
)

# Other arguments here

# Save
save(melanoma, file =
here::here("data", "melanoma_working.rda")
)

Note use of the here::here(). This is a very useful package which “just works” when it comes to finding your files. Do not change the working directory (using setwd()) from the project root - there is never a reason to do this. here::here() is paricularly useful when sharing projects between Linux, Mac and Windows machines, which have different conventions for file paths.

02_make_factors.R is our example second file, but it could be anything you want. It could look something like this.

# Melanoma project
## Create factors
library(tidyverse)

here::here("data", "melanoma_working.rda")
)

## Recode variables
melanoma = melanoma %>%
mutate(
sex = factor(sex) %>%
fct_recode("Male" = "1",
"Female" = "0")
)

# Save
save(melanoma, file =
here::here("data", "melanoma_working.rda")
)

All these files can then be brought together in a single file to source(). This function is used to run code from a file.

0_source_all.R might look like this:

# Melanoma project
## Source all

source( here::here("R", "02_make_factors.R") )
source( here::here("R", "03_duplicate_records.R") )

# Save
save(melanoma, file =
here::here("data", "melanoma_all.rda")
)

You can now bring your robustly prepared data into your analysis file, which can be .R or .Rmd if you are working in a Notebook. We call this 00_analysis.Rmd and it always sits in the project root director. You have two options in bringing in the data.

1. source() the data again
• this is useful if the data is changing
• may take a long time if it is a large dataset with lots of manipulations
1. load() from the data/ folder
• usually quicker, but loads the static dataset which was created the last time your ran 0_soruce_all.R

The two options look like this:

---
title: "Melanoma analysis"
output: html_notebook
---

{r get-data-option-1, echo=FALSE}
here:here("data", "melanoma_all.rda")
)

{r get-data-option-2, echo=FALSE}
source(
here:here("R", "0_source_all.R")
)

Why go to all this bother?

It comes from many years of finding errors due to badly organised projects. It is clearly not needed for a small quick project, but is essential for any major work.

At the very start of an analysis (as in the first day), we will start working in a single file. We will quickly move chunks of data cleaning / preparation code into single files as we go.

Compartmentalising the data cleaning helps in debugging. Sourced files can be ‘commented out’ (adding a # to a line in the 0_source_all.R` file) if you wish to exclude the manipulations in that particular file.

Most important, it helps with collaboration. When multiple people are working on a project, it is essential that communication is good and everybody is working to the same overall plan.

format: plain


text:
Run a bit of R code using rmarkdown::render() and write the rendered result to user's clipboard. If the clipboard is unavailable, the file containing the rendered result is opened for manual copy. The goal is to make it easy to share a small reproducible example ("reprex"), e.g., in a GitHub issue. Reprex source can be

• provided directly as expression, character vector, or string

• read from current selection or active document in RStudio

reprex can also be used for syntax highlighting (with or without rendering); see below for more.

## Usage

reprex(
x = NULL,
input = NULL,
wd = NULL,
venue = c("gh", "r", "rtf", "html", "slack", "so", "ds"),
render = TRUE,
session_info = opt(FALSE),
style = opt(FALSE),
comment = opt("#>"),
tidyverse_quiet = opt(TRUE),
std_out_err = opt(FALSE),
html_preview = opt(TRUE),
outfile = deprecated(),
show = deprecated(),
si = deprecated()
)

## Arguments

x

An expression. If not given, reprex() looks for code in input. If input is not provided, reprex() looks on the clipboard.

When the clipboard is structurally unavailable, e.g., on RStudio Server or RStudio Cloud, reprex() consults the current selection instead of the clipboard.

input

Character. If has length one and lacks a terminating newline, interpreted as the path to a file containing reprex code. Otherwise, assumed to hold reprex code as character vector. When input specifies a filepath, it also determines the reprex working directory and the location of all resulting files.

wd

An optional filepath that is consulted when input is not a filepath. (By default, all work is done, quietly, in a subdirectory of the session temp directory.)

The most common use of wd is to set wd = ".", which means "reprex right HERE in the current working directory". Do this if you really must demonstrate something with local files.

venue

Character. Must be one of the following (case insensitive):

• "gh" for GitHub-Flavored Markdown, the default

• "r" for a runnable R script, with commented output interleaved. Also useful for Slack code snippets; select "R" from the "Type" drop-down menu to enjoy nice syntax highlighting.

• "rtf" for Rich Text Format (not supported for un-reprexing)

• "html" for an HTML fragment suitable for inclusion in a larger HTML document (not supported for un-reprexing)

• "slack" for pasting into a Slack message. Optimized for people who opt out of Slack's WYSIWYG interface. Go to Preferences > Advanced > Input options and select "Format messages with markup". (If there is demand for a second Slack venue optimized for use with WYSIWYG, please open an issue to discuss.)

• "so" for Stack Overflow Markdown. Note: this is just an alias for "gh", since Stack Overflow started to support CommonMark-style fenced code blocks in January 2019.

• "ds" for Discourse, e.g., community.rstudio.com. Note: this is currently just an alias for "gh".

render

Logical. Whether to call rmarkdown::render() on the templated reprex, i.e. whether to actually run the code. Defaults to TRUE. Exists primarily for the sake of internal testing.

Logical. Whether to include a footer that describes when and how the reprex was created. If unspecified, the option reprex.advertise is consulted and, if that is not defined, default is TRUE for venues "gh", "html", "so", "ds" and FALSE for "r", "rtf", "slack".

session_info

Logical. Whether to include sessioninfo::session_info(), if available, or sessionInfo() at the end of the reprex. When venue is "gh", the session info is wrapped in a collapsible details tag. Read more about opt().

style

Logical. Whether to set the knitr chunk option tidy = "styler", which re-styles code with the styler package. Read more about opt().

comment

Character. Prefix with which to comment out output, defaults to "#>". Read more about opt().

tidyverse_quiet

Logical. Sets the options tidyverse.quiet and tidymodels.quiet, which suppress (TRUE, the default) or include (FALSE) the startup messages for the tidyverse and tidymodels packages. Read more about opt().

std_out_err

Logical. Whether to append a section for output sent to stdout and stderr by the reprex rendering process. This can be necessary to reveal output if the reprex spawns child processes or system() calls. Note this cannot be properly interleaved with output from the main R process, nor is there any guarantee that the lines from standard output and standard error are in correct chronological order. See callr::r() for more. Read more about opt().

html_preview

Logical. Whether to show rendered output in a viewer (RStudio or browser). Always FALSE in a noninteractive session. Read more about opt().

outfile

in favor of wd or providing a filepath to input. To reprex in current working directory, use wd = "." now, instead of outfile = NA.

show

in favor of html_preview, for greater consistency with other R Markdown output formats.

si

in favor of session_info.

## Value

Character vector of rendered reprex, invisibly.

## Details

The usual "code + commented output" is returned invisibly, written to file, and, whenever possible, put on the clipboard. An HTML preview displays in RStudio's Viewer pane, if available, or in the default browser, otherwise. Leading "> " prompts, are stripped from the input code. Read more at https://reprex.tidyverse.org/.

reprex sets specific knitr options:

• Chunk options default to collapse = TRUE, comment = "#>", error = TRUE. Note that error = TRUE, because a common use case is bug reporting.

• reprex also sets knitr's upload.fun. It defaults to knitr::imgur_upload() so figures produced by the reprex appear properly on GitHub, Stack Overflow, Discourse, and Slack. Note that imgur_upload() requires the packages httr and xml2. When venue = "r", upload.fun is set to identity(), so that figures remain local. In that case, you may also want to provide a filepath to input or set wd, to control where the reprex files are written. You can supplement or override these options with special comments in your code (see examples).

## Error backtraces

reprex sets the rlang option rlang_backtrace_on_error_report = "full". Combined with the knitr option error = TRUE, this means rlang errors are displayed with a full backtrace. This basically eliminates the need to call rlang::last_error() or rlang::last_trace() explicitly, although these functions can be used in a reprex.

Insert a line containing the special comment #' in between the error-causing code and the last_error() or last_trace() call, to fulfill the requirement of being in separate chunks:

f <- function() rlang::abort('foo')
f()
#'
rlang::last_error()
rlang::last_trace()

Read more in rlang's documentation: Errors in RMarkdown.

## Syntax highlighting

A secondary use case for reprex is to produce syntax highlighted code snippets, with or without rendering, to paste into applications like Microsoft Word, PowerPoint, or Keynote. Use venue = "rtf" for this.

This feature is experimental and requires the installation of the highlight command line tool. The "rtf" venue is documented in its own article

## Examples

if (FALSE) {
# put some code like this on the clipboard
# (y <- 1:4)
# mean(y)
reprex()

# provide code as an expression
reprex(rbinom(3, size = 10, prob = 0.5))
reprex({y <- 1:4; mean(y)})
reprex({y <- 1:4; mean(y)}, style = TRUE)

# note that you can include newlines in those brackets
# in fact, that is often a good idea
reprex({
x <- 1:4
y <- 2:5
x + y
})

## provide code via character vector
reprex(input = c("x <- 1:4", "y <- 2:5", "x + y"))

## if just one line, terminate with '\n'
reprex(input = "rnorm(3)\n")

## customize the output comment prefix
reprex(rbinom(3, size = 10, prob = 0.5), comment = "#;-)")

# override a default chunk option
reprex({
#+ setup, include = FALSE
knitr::opts_chunk$set(collapse = FALSE) #+ actual-reprex-code (y <- 1:4) median(y) }) # add prose, use general markdown formatting reprex({ #' # A Big Heading #' #' Look at my cute example. I love the #' [reprex](https://github.com/tidyverse/reprex#readme) package! y <- 1:4 mean(y) }, advertise = FALSE) # read reprex from file and write resulting files to that location tmp <- file.path(tempdir(), "foofy.R") writeLines(c("x <- 1:4", "mean(x)"), tmp) reprex(input = tmp) list.files(dirname(tmp), pattern = "foofy") # clean up file.remove(list.files(dirname(tmp), pattern = "foofy", full.names = TRUE)) # write reprex to file AND keep figure local too, i.e. don't post to imgur tmp <- file.path(tempdir(), "foofy") dir.create(tmp) reprex({ #+ setup, include = FALSE knitr::opts_knit$set(upload.fun = identity)

#+ actual-reprex-code
#' Some prose
## regular comment
(x <- 1:4)
median(x)
plot(x)
}, wd = tmp)
list.files(dirname(tmp), pattern = "foofy")

# clean up

## target venue = R, also good for email or Slack snippets
ret <- reprex({
x <- 1:4
y <- 2:5
x + y
}, venue = "R")
ret

## target venue = html
ret <- reprex({
x <- 1:4
y <- 2:5
x + y
}, venue = "html")
ret

## include prompt and don't comment the output
## use this when you want to make your code hard to execute :)
reprex({
#+ setup, include = FALSE
knitr::opts_chunk\$set(comment = NA, prompt = TRUE)

#+ actual-reprex-code
x <- 1:4
y <- 2:5
x + y
})

## leading prompts are stripped from source
reprex(input = c("> x <- 1:3", "> median(x)"))
}


text:
# 6 Conditional Probability

The chances of crashing your car are pretty low, but they’re considerably higher if you’re drunk. Probabilities change depending on the conditions.

We symbolize this idea by writing $$\p(A \given B)$$, the probability that $$A$$ is true given that $$B$$ is true. And we call this kind of probability conditional probability.

To say $$B$$ increases the chance of $$A$$ we write $$\p(A \given B) \gt \p(A)$$. And to say $$B$$ doubles the chance of $$A$$ write $$\p(A \given B) = 2 \times \p(A)$$.

For example, to say the probability of $$A$$ given $$B$$ is 30%, we write: $\p(A \given B) = .3.$ But how do we calculate conditional probabilities?

## 6.1 Calculating Conditional Probability

Figure 6.1: Conditional probability in a fair die roll

Suppose I roll a fair, six-sided die behind a screen. You can’t see the result, but I tell you it’s an even number. What’s the probability it’s also a “high” number: either a $$4$$, $$5$$, or $$6$$?

Maybe you figured the correct answer: $$2/3$$. But why is that correct? Because, out of the three even numbers ($$2$$, $$4$$, and $$6$$), two of them are high ($$4$$ and $$6$$). And since the die is fair, we expect it to land on a high number $$2/3$$ of the times it lands on an even number.

This hints at a formula for $$\p(A \given B)$$.

Conditional Probability

$\p(A \given B) = \frac{\p(A \wedge B)}{\p(B)}.$

In the die-roll example, we considered how many of the $$B$$ possibilities were also $$A$$ possibilities. Which means we divided $$\p(A \wedge B)$$ by $$\p(B)$$.

In fact, this formula is our official definition for the concept of conditional probability. When we write the sequence of symbols $$\p(A \given B)$$, it’s really just shorthand for the fraction $$\p(A \wedge B) / \p(B)$$.

Figure 6.2: Conditional probability is the size of the $$A \wedge B$$ region compared to the entire $$B$$ region.

In terms of an Euler diagram (Figure 6.2), the definition of conditional probability compares the size of the purple $$A \wedge B$$ region to the size of the whole $$B$$ region, purple and blue together. If you don’t mind getting a little colourful with your algebra: $\p(A \given B) = \frac{\color{bookpurple}{\blacksquare}}{\color{bookpurple}{\blacksquare} + \color{bookblue}{\blacksquare}}.$ So the definition works because, informally speaking, $$\p(A \wedge B)/\p(B)$$ is the proportion of the $$B$$ outcomes that are also $$A$$ outcomes.

Dividing by zero is a common pitfall with conditional probability. Notice how the definition of $$\p(A \given B)$$ depends on $$\p(B)$$ being larger than zero. If $$\p(B) = 0$$, then the formula The comedian Steven Wright once quipped that “black holes are where God divided by zero.” $\p(A \given B) = \frac{\p(A \wedge B)}{\p(B)}$ doesn’t even make any sense. There is no number that results from the division on the right hand side.3 There are alternative mathematical systems of probability, where conditional probability is defined differently to avoid this problem. But in this book we’ll stick to the standard system. In this system, there’s just no such thing as “the probability of $$A$$ given $$B$$” when $$B$$ has zero probability.

In such cases we say that $$\p(A \given B)$$ is undefined. It’s not zero, or some special number. It just isn’t a number.

## 6.2 Conditional Probability & Trees

We already encountered conditional probabilities informally, when we used a tree diagram to solve the Monty Hall problem.

In a tree diagram, each branch represents a possible outcome. The number placed on that branch represents the chance of that outcome occurring. But that number is based on the assumption that all branches leading up to it occur. So the probability on that branch is conditional on all previous branches.

For example, suppose there are two urns of coloured marbles:

• Urn X contains 3 black marbles, 1 white.
• Urn Y contains 1 black marble, 3 white.

I flip a fair coin to decide which urn to draw from, heads for Urn B and tails for Urn W. Then I draw one marble at random.

The probability of drawing a black marble on the top path is $$3/4$$ because we are assuming the coin landed heads, and thus I’m drawing from Urn X. If the coin lands tails instead, and I draw from Urn Y, then the chance of a black marble is instead $$1/4$$. So these quantities are conditional probabilities: \begin{aligned} \p(B \given H) &= 3/4,\\ \p(B \given T) &= 1/4. \end{aligned}

Notice, though, the first branch in a tree diagram is different. In the $$H$$-vs.-$$T$$ branch, the probabilities are unconditional, since there are no previous branches for them to be conditional on.

## 6.3 More Examples

Imagine an urn contains marbles of three different colours: 20 are red, 30 are blue, and 40 are green. I draw a marble at random. What is $$\p(R \given \neg B)$$, the probability it’s red given that it’s not blue? \begin{aligned} \p(R \given \neg B) &= \frac{\p(R \wedge \neg B)}{\p(\neg B)}\\ &= \frac{\p(R)}{\p(\neg B)}\\ &= \frac{20/90}{60/90}\\ &= 1/3. \end{aligned} This calculation relies on the fact that $$R \wedge \neg B$$ is logically equivalent to $$R$$. A red marble is automatically not blue, so $$R$$ is true under exactly the same circumstances as $$R \wedge \neg B$$. The Equivalence Rule thus tells us $$\p(R \wedge \neg B) = \p(R)$$.

Suppose a university has 10,000 students, and each student is studying under one of four broad headings: Humanities, Social Sciences, STEM, or Professional. Within each of these categories, the number of students with an average grade of A, B, C, or D is as follows:

Humanities Social Sciences STEM Professional
A 200 600 400 900
B 500 800 1600 900
C 250 400 1500 750
D 50 200 500 450

What is the probability a randomly selected student will have an A average, given that they are studying either Humanities or Social Sciences? \begin{aligned} \p(A \given H \vee S) &= \frac{\p(A \wedge (H \vee S))}{\p(H \vee S)}\\ &= \frac{800/10,000}{3,000/10,000}\\ &= 4/15. \end{aligned}

What about the reverse probability, that a student is studying either Humanities or Social Sciences given that they have an A average? \begin{aligned} \p(H \vee S \given A) &= \frac{\p((H \vee S) \wedge A)}{\p(A)}\\ &= \frac{800/10,000}{2,100/10,000}\\ &= 8/21. \end{aligned} Notice how we get a different number now.

## 6.4 Order Matters

In general, the probability of $$A$$ given $$B$$ will be different from the probability of $$B$$ given $$A$$. These are different concepts.

For example, university students are usually young, but young people aren’t usually university students. Most aren’t even old enough to be in university. So the probability someone is young given they are in university is high. But the probability someone is in university given that they are young is low. So $$\p(Y \given U) \neq \p(U \given Y)$$.

Once in a while we do find cases where $$\p(A \given B) = \p(B \given A)$$. For example, suppose we throw a dart at random at a circular board, divided into four quadrants. The chance the dart will land on the left half given that it lands on the top half is the same as the chance it lands on the top half given it lands on the left. Both probabilities are $$1/2$$.

But this kind of thing is the exception rather than the rule. Usually, $$\p(A \given B)$$ will be a different number from $$\p(B \given A)$$. So it’s important to remember how order matters.

When we write $$\p(A \given B)$$, we are discussing the probability of $$A$$. But we are discussing it under the assumption that $$B$$ is true.

## 6.5 Declaring Independence

We explained independence informally back in Chapter 4: $$A$$ and $$B$$ are independent if the truth of one doesn’t change the probability of the other. Now that we’ve formally defined conditional probability, we can formally define independence too.

Independence

$$A$$ is independent of $$B$$ if $$\p(A \given B) = \p(A)$$ and $$\p(A) > 0$$.

In other words, they’re independent if $$A$$’s probability is the same after $$B$$ is given as it was before (and not just for the silly reason that there was no chance of $$A$$ being true to begin with).

Now we can establish three useful facts about independence.

The first is summed up in the mantra “independence means multiply”. This actually has two parts.

We already learned the first part with the Multiplication Rule: if $$A$$ is independent of $$B$$, then $$\p(A \wedge B) = \p(A)\p(B)$$. Except now we can see why this rule holds, using the definition of conditional probability and some algebra: \begin{aligned} \p(A \given B) &= \frac{\p(A \wedge B)}{\p(B)} & \mbox{by definition}\\ \p(A \given B)\p(B) &= \p(A \wedge B) & \mbox{by algebra}\\ \p(A)\p(B) &= \p(A \wedge B) & \mbox{by independence}. \end{aligned}

The second part of the “independence means multiply” mantra is new though. It basically says that the reverse also holds. As long as $$\p(A) > 0$$ and $$\p(B) > 0$$, if $$\p(A \wedge B) = \p(A)\p(B)$$, then $$A$$ is independent of $$B$$.

Bottom line: as long as there are no zeros to worry about, independence is the same thing as $$\p(A \wedge B) = \p(A)\p(B)$$.

Second, independence is symmetric. If $$A$$ is independent of $$B$$ then $$B$$ is independent of $$A$$. Informally speaking, if $$B$$ makes no difference to $$A$$’s probability, then $$A$$ makes no difference to $$B$$’s probability.

This is why we often say “$$A$$ and $$B$$ are independent”, without specifying which is independent of which. Since independence goes both ways, they’re automatically independent of each other.

Third, independence extends to negations. If $$A$$ is independent of $$B$$, then it’s also independent of $$\neg B$$ (as long as $$\p(\neg B) > 0$$, so that $$\p(A \given \neg B)$$ is well-defined).

Notice, this also means that if $$A$$ is independent of $$B$$, then $$\neg A$$ is independent of $$\neg B$$ (as long as $$\p(\neg A) > 0$$).

So far our definition of independence only applies to two propositions. We can extend it to three as follows:

Three-way Independence

$$A$$, $$B$$, and $$C$$ are independent if

1. $$A$$ is independent of $$B$$, $$A$$ is independent of $$C$$, and $$B$$ is independent of $$C$$, and
2. $$\p(A \wedge B \wedge C) = \p(A)\p(B)\p(C)$$.

In other words, a trio of propositions is independent if each pair of them is independent, and the multiplication rule applies to their conjunction. The same idea can be extended to define independence for four propositions, five, etc.

## Exercises

1. Answer each of the following:

1. On a fair die with six sides, what is the probability of rolling a low number (1, 2, or 3) given that you roll an even number.
2. On a fair die with eight sides, what is the probability of rolling an even number given that you roll a high number (5, 6, 7, or 8)?
2. Suppose $$\p(B) = 4/10$$, $$\p(A) = 7/10$$, and $$\p(B \wedge A) = 2/10$$. What are each of the following probabilities?

1. $$\p(A \given B)$$
2. $$\p(B \given A)$$
3. Five percent of tablets made by the company Ixian have factory defects. Ten percent of the tablets made by their competitor company Guild do. A computer store buys $$40\%$$ of its tablets from Ixian, and $$60\%$$ from Guild.

This exercise and the next one are based on very similar exercises from Ian Hacking’s wonderful book, An Introduction to Probability and Inductive Logic.

Draw a probability tree to answer the following questions.

1. What is the probability a randomly selected tablet in the store is made by Ixian and has a factory defect?
2. What is the probability a randomly selected tablet in the store has a factory defect?
3. What is the probability a tablet from this store is made by Ixian, given that it has a factory defect?
4. In the city of Elizabeth, the neighbourhood of Southside has lots of chemical plants. $$2\%$$ of Elizabeth’s children live in Southside, and $$14\%$$ of those children have been exposed to toxic levels of lead. Elsewhere in the city, only $$1\%$$ of the children have toxic levels of exposure.

Draw a probability tree to answer the following questions.

1. What is the probability that a randomly chosen child from Elizabeth lives in Southside and has toxic levels of lead exposure?
2. What is the probability that a randomly chosen child from Elizabeth has toxic levels of lead exposure?
3. What is the probability that a randomly chosen child from Elizabeth who has toxic levels of lead exposure lives in Southside?
5. Imagine 100 prisoners are sentenced to death. 70 of them are housed in cell block A, the other 30 are in cell block B. Of the prisoners in cell block A, 9 are innocent. Only 1 prisoner in cell block B is innocent.

The law requires that one prisoner be pardoned. The lucky prisoner will be selected by flipping a fair coin to choose either cell block A or B. Then a fair lottery will be used to select a random prisoner from the chosen cell block.

What is the probability the pardoned prisoner comes from cell block A if she is innocent? Answer each of the following to find out.

$$I$$ = The pardoned prisoner is innocent.
$$A$$ = The pardoned prisoner comes from cell block A.

1. What is $$Pr(I \given A)$$?
2. What is $$Pr(A \wedge I)$$?
3. What is $$Pr(I \given B)$$?
4. What is $$Pr(B \wedge I)$$?
5. What is $$Pr(I)$$?
6. What is $$Pr(A \given I)$$?
7. Draw a probability tree to visualize and verify your calculations.
6. Suppose $$A$$, $$B$$, and $$C$$ are independent, and they each have the same probability: $$1/3$$. What is $$\p(A \wedge B \given C)$$?

7. If $$A$$ and $$B$$ are mutually exclusive, what is $$\p(A \given B)$$? Justify your answer using the definition of conditional probability.

1. $$\p(A) = 1/2, \p(A \given B) = 1/2, \p(B \given A) = 1/2$$.
2. $$\p(A) = 1/2, \p(A \given B) = 1, \p(A \given \neg B) = 1$$.
9. Is the following statement true or false: if $$A$$ and $$B$$ are mutually exclusive, then $$Pr(A \vee B \given C) = Pr(A \given C) + Pr(B \given C)$$. Justify your answer.
10. Justify the second part of the “independence means multiply” mantra: if $$\p(A) > 0$$, $$\p(B) > 0$$, and $$\p(A \wedge B) = \p(A) \p(B)$$, then $$A$$ is independent of $$B$$.
Hint: start by supposing $$\p(A) > 0$$, $$\p(B) > 0$$, and $$\p(A \wedge B) = \p(A)\p(B)$$. Then apply some algebra and the definition of conditional probability.
11. Justify the claim that independence is symmetric: if $$A$$ is independent of $$B$$, then $$B$$ is independent of $$A$$.
Hint: start by supposing that $$A$$ is independent of $$B$$. Then write out $$\p(A \given B)$$ and apply the definition of conditional probability.


text:
# Chapter 1 - Introduction to Algebraic Expressions - Test: Chapter 1: 23

$-\dfrac{7}{8}$

#### Work Step by Step

The given expression, $-\dfrac{1}{8}-\dfrac{3}{4}$, simplifies to \begin{array}{l}\require{cancel} -\dfrac{3}{24}-\dfrac{18}{24} \\\\= \dfrac{-3-18}{24} \\\\= \dfrac{-21}{24} \\\\= \dfrac{\cancel{3}\cdot(-7)}{\cancel{3}\cdot8} \\\\= -\dfrac{7}{8} .\end{array}

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.


text:
# High pass filter - Cut-off frequency calculation doesn't match simulation

I have made the following simulation with the circuit you can see below:

I'm asked to find the cut-off frequency for this filter. From the simulation, it looks like it $$\f_c = 500 \text{Hz}\$$ or somewhere around there.

However, if I use the formula for cut-off frequency I get something totally different.

$$\f_c=\frac{R}{2\pi L}=\frac{500 \Omega}{2\pi \cdot 10 \text{mH}}=7960 \text{Hz}\$$

Am I using the correct formula, or is my interpretation of the simulation wrong?

I hope someone can help me.

• $f_c$ is the frequency at which the gain is $-3db$; why do you think $f_c$ is 500Hz? Apr 2, 2020 at 9:07
• Huh,I guess have misunderstood some things then. However, if $f_c$ occurs when gain is -3dB, then the simulation and calculation still doesn't match.
– Carl
Apr 2, 2020 at 9:13
• maybe the frequency is not f rather w?
– Mike
Apr 2, 2020 at 9:15
• Are you perhaps looking at the phase line (the dotted line) thinking it is the gain line? Apr 2, 2020 at 17:41

From the simulation, it looks like it fc=500Hz or somewhere around there.

Your simulation looks more like 15 kHz (3 dB point) and the reason is because you haven't used enough resolution in your AC analysis and the graph is inaccurately interpolating between points that are too far apart: -

Use more resolution in your AC analysis like in this simulation I did: -

The 3 dB point is around 7900 Hz.

Also try using a logarithmic X axis.

• Very often it is more exact to use the phase shift of 45 deg. as an indication for 3dB cutoff.
– LvW
Apr 2, 2020 at 11:06
• For any 1st-order lowpass or highpass the phase shift at the 3dB frequency is ALWAYS 45 deg. Look into your phase response diagram. In many cases. this point is easier to find than the 3dB drop of the magnitude.
– LvW
Apr 2, 2020 at 11:16

Well, mathematically speaking we can write:

$$\mathcal{H}\left(\text{s}\right)=\frac{\text{sL}}{\text{sL}+\text{R}}\tag1$$

Using $$\\text{s}=\text{j}\omega\$$, we get:

$$\left|\underline{\mathcal{H}}\left(\text{j}\omega\right)\right|=\left|\frac{\text{j}\omega\text{L}}{\text{j}\omega\text{L}+\text{R}}\right|=\frac{\left|\text{j}\omega\text{L}\right|}{\left|\text{j}\omega\text{L}+\text{R}\right|}=\frac{\omega\text{L}}{\sqrt{\text{R}^2+\left(\omega\text{L}\right)^2}}\tag2$$

Now, we get:

• $$\lim_{\omega\to0}\left|\underline{\mathcal{H}}\left(\text{j}\omega\right)\right|=0\tag3$$
• $$\lim_{\omega\to\infty}\left|\underline{\mathcal{H}}\left(\text{j}\omega\right)\right|=1\tag4$$

Solving for the $$\-3\space\text{dB}\$$ point gives:

$$\frac{\omega\cdot10\cdot10^{-3}}{\sqrt{500^2+\left(\omega\cdot10\cdot10^{-3}\right)^2}}=\frac{1}{\sqrt{2}}\space\Longleftrightarrow\space$$ $$\omega=50000\space\text{rad/sec}\tag5$$

Which is the same as:

$$\frac{25000}{\pi}\space\text{Hz}\approx7957.75\space\text{Hz}\tag6$$

• Jan - just a formal correction: The last line must not be written as one single equation. Instead you should write down two separate equations.
– LvW
Apr 2, 2020 at 11:05
• @LvW I do not see what you mean, you can edit my answer is you want. Apr 2, 2020 at 11:08
• Jan...it is pure math: On the left side of the equations is w....and on the right side we see the frequency f. That means w=f ???. It should read: 50000rad/sec are equivalent to f=7957.75 Hz (not equal)
– LvW
Apr 2, 2020 at 13:01
• @LvW I've studied mathematics and I see what you mean, but using rad/sec and Hz make a difference Apr 2, 2020 at 13:21
• Yes - and therefore, I think, we must not equate the two ..(different units on both sides)
– LvW
Apr 2, 2020 at 13:26


text:
# 17.10: Heats of Fusion and Solidification

Suppose you hold an ice cube in your hand. It feels cold because heat energy leaves your hand and enters the ice cube. What happens to the ice cube? It melts. However, the temperature during a phase change remains constant. So the heat that is being lost by your hand does not raise the temperature of the ice above its melting temperature of $$0^\text{o} \text{C}$$. Rather, all the heat goes into the change of state. Energy is absorbed during the process of changing ice into water. The water that is produced also remains at $$0^\text{o} \text{C}$$ until all of the ice is melted.

### Heats of Fusion and Solidification

All solids absorb heat as they melt to become liquids. The gain of heat in this endothermic process goes into changing the state rather than changing the temperature. The molar heat of fusion $$\left( \Delta H_\text{fus} \right)$$ of a substance is the heat absorbed by one mole of that substance as it is converted from a solid to a liquid. Since the melting of any substance absorbs heat, it follows that the freezing of any substance releases heat. The molar heat of solidification $$\left( \Delta H_\text{solid} \right)$$ of a substance is the heat released by one mole of that substance as it is converted from a liquid to a solid. Since fusion and solidification of a given substance are the exact opposite processes, the numerical value of the molar heat of fusion is the same as the numerical value of the molar heat of solidification, but opposite in sign. In other words, $$\Delta H_\text{fus} = - \Delta H_\text{solid}$$. The figure below shows all of the possible changes of state along with the direction of heat flow during each process.

Figure 17.10.1: From left to right, heat is absorbed from the surroundings during melting, evaporation, and sublimation. From right to left, heat is released to the surroundings during freezing, condensation, and deposition.

Every substance has a unique value for its molar heat of fusion, depending on the amount of energy required to disrupt the intermolecular forces present in the solid. When $$1 \: \text{mol}$$ of ice at $$0^\text{o} \text{C}$$ is converted to $$1 \: \text{mol}$$ of liquid water at $$0^\text{o} \text{C}$$, $$6.01 \: \text{kJ}$$ of heat are absorbed from the surroundings. When $$1 \: \text{mol}$$ of water at $$0^\text{o} \text{C}$$ freezes to ice at $$0^\text{o} \text{C}$$, $$6.01 \: \text{kJ}$$ of heat is released into the surroundings.

$\begin{array}{ll} \ce{H_2O} \left( s \right) \rightarrow \ce{H_2O} \left( l \right) & \Delta H_\text{fus} = 6.01 \: \text{kJ/mol} \\ \ce{H_2O} \left( l \right) \rightarrow \ce{H_2O} \left( s \right) & \Delta H_\text{solid} = -6.01 \: \text{kJ/mol} \end{array}$

The molar heats of fusion and solidification of a given substance can be used to calculate the heat absorbed or released when various amounts are melted or frozen.

Example 17.10.1

Calculate the heat absorbed when $$31.6 \: \text{g}$$ of ice at $$0^\text{o} \text{C}$$ is completely melted.

Solution:

Step 1: List the known quantities and plan the problem.

Known

• Mass $$= 31.6 \: \text{g}$$ ice
• Molar mass $$\ce{H_2O} = 18.02 \: \text{g/mol}$$
• Molar heat of fusion $$= 6.01 \: \text{kJ/mol}$$

Unknown

• $$\Delta H = ? \: \text{J}$$

The mass of ice is first converted to moles. This is then multiplied by the conversion factor of $$\left( \frac{6.01 \: \text{kJ}}{1 \: \text{mol}} \right)$$ in order to find the $$\text{kJ}$$ of heat absorbed.

Step 2: Solve.

$31.6 \: \text{g ice} \times \frac{1 \: \text{mol ice}}{18.02 \: \text{g ice}} \times \frac{6.01 \: \text{kJ}}{1 \: \text{mol ice}} = 10.5 \: \text{kJ}$

The given quantity is a bit less than 2 moles of ice, and so just less than $$12 \: \text{kJ}$$ of heat is absorbed by the melting process.