Podcast
Questions and Answers
Which of the following is NOT one of the five main personal factors that influence health?
Which of the following is NOT one of the five main personal factors that influence health?
- Sense of control
- Personal beliefs about health care
- Income and social status (correct)
- Personal lifestyle choices
Maintaining eye contact is generally recommended when interacting with individuals who have illnesses or disabilities.
Maintaining eye contact is generally recommended when interacting with individuals who have illnesses or disabilities.
False (B)
What is an acute illness?
What is an acute illness?
Illnesses and disabilities that last for a relatively short period of time
_____ can be defined as a person's beliefs, values, or opinion toward engaging in healthy behaviors.
_____ can be defined as a person's beliefs, values, or opinion toward engaging in healthy behaviors.
Match the following DIPPS principles with their corresponding descriptions:
Match the following DIPPS principles with their corresponding descriptions:
According to the material, what is the definition of disability?
According to the material, what is the definition of disability?
All clients will experience illness and disability in the same way.
All clients will experience illness and disability in the same way.
List four common reactions to illness and disability.
List four common reactions to illness and disability.
Achievement of optimal health (or wellness) is the achievement of the possible in all five dimensions of one's life: physical, emotional, social, _______, and spiritual dimensions.
Achievement of optimal health (or wellness) is the achievement of the possible in all five dimensions of one's life: physical, emotional, social, _______, and spiritual dimensions.
Which determinant of health is associated with better health outcomes?
Which determinant of health is associated with better health outcomes?
Flashcards
Genetic endowment
Genetic endowment
A person's tendency towards a wide range of reactions that affect health status.
Achieving Optimal Health
Achieving Optimal Health
The level of wellness achieved considering all dimensions: physical, emotional, social, cognitive, and spiritual.
Illness
Illness
The loss of physical or mental health.
Disability
Disability
Signup and view all the flashcards
Acute illness/disability
Acute illness/disability
Signup and view all the flashcards
Persistent illness/disability
Persistent illness/disability
Signup and view all the flashcards
Attitude
Attitude
Signup and view all the flashcards
What does DIPPS stand for?
What does DIPPS stand for?
Signup and view all the flashcards
Common reactions to illness/disability
Common reactions to illness/disability
Signup and view all the flashcards
Change/loss associated with illness/disability
Change/loss associated with illness/disability
Signup and view all the flashcards
Study Notes
Clinical Laboratory - Complete Blood Count (CBC)
Hemoglobin (Hb)
- Hemoglobin is an iron-containing oxygen-transport metalloprotein in red blood cells.
- Normal Hb values:
- Male: 13.5-17.5 g/dL
- Female: 11.5-15.5 g/dL
- Clinical significance:
- Increased Hb may indicate dehydration, polycythemia vera, or severe burns.
- Decreased Hb may indicate anemia, hemorrhage, hemolysis, or kidney disease.
Hematocrit (Hct)
- Hematocrit is the percentage of red blood cells in the blood.
- Normal Hct values:
- Male: 41.0-53.0%
- Female: 36.0-46.0%
- Clinical significance:
- Increased Hct may indicate dehydration, polycythemia vera, or severe burns.
- Decreased Hct may indicate anemia, hemorrhage, hemolysis, or kidney disease.
Red Blood Cell (RBC)
- Red blood cells carry oxygen from the lungs to the body tissues and carbon dioxide from tissues back to the lungs.
- Normal RBC values:
- Male: 4.5-5.5 x $10^6/µL$
- Female: 4.0-5.0 x $10^6/µL$
- Clinical significance:
- Increased RBC count may indicate dehydration, polycythemia vera, or severe burns.
- Decreased RBC count may indicate anemia, hemorrhage, hemolysis, or kidney disease.
White Blood Cell (WBC)
- White blood cells protect the body against infection.
- Normal WBC value: 4.0-10.0 x $10^3/µL$
- Clinical significance:
- Increased WBC count may indicate infection, inflammation, or leukemia.
- Decreased WBC count may indicate drug toxicity or bone marrow failure.
Platelet (PLT)
- Platelets are cell fragments in the blood that help stop bleeding.
- Normal PLT value: 150-400 x $10^3/µL$
- Clinical significance:
- Increased platelet count may indicate thrombocytosis or some types of anemia.
- Decreased platelet count may indicate thrombocytopenia or some types of anemia.
Chapter 14: Graphics
Introduction
- The basics of producing graphics using Python are introduced.
- How to work with the
graphics.py
package is explained. - How to create simple drawings using the package is shown.
- Instructions on writing programs that respond to mouse clicks and keyboard entry are given.
Overview
- Computer graphics involve the generation and display of pictures using a computer.
graphics.py
package by John Zelle is used in the book for creating graphics in Python.
The graphics.py
Package
- Download the non-standard package
graphics.py
and save it where Python can find it. Place it in the same folder or a site-packages directory. - Import the package for use in a program with the command
from graphics import *
.
Simple Example
- Opens a graphics window and draws a circle.
from graphics import *
imports all the names from the graphics module.win = GraphWin("My Circle", 100, 100)
creates a 100x100 pixel window titled "My Circle."- Circle
c
is constructed with its center at (50, 50) and a radius of 10 pixels. c.draw(win)
draws the circle in the window.- The code waits for a mouse click and then closes the window.
Coordinate System
- A
GraphWin
has a default coordinate system with (0, 0) in the upper left corner and (200, 200) in the lower right. $x$ and $y$ Coordinates increase to the right and downward. - The default coordinates can be changed; for example,
win.setCoords(0.0, 0.0, 10.0, 10.0)
places (0.0, 0.0) in the lower left and (10.0, 10.0) in the upper right.
Pixel Addresses
- The resolution of a display is the number of pixels that make up the display.
- Each pixel on the screen has a unique address to determine its position.
Creating Graphics Objects
The Point
Class
- Point is the basic building block for all figures, specified by $x$ and $y$ coordinates.
- Example to create a point, also gets values:
p = Point(50, 60) p.getX() p.getY()
The Circle
Class
- To draw a circle, specify the coordinates of the center point and the radius.
center = Point(100, 100) circ = Circle(center, 30) circ.draw(win)
The Rectangle
Class
- To draw a rectangle, specify the coordinates of two opposite corners.
p1 = Point(30, 40) p2 = Point(120, 150) rect = Rectangle(p1, p2) rect.draw(win)
The Line
Class
- To draw a line, specify the two endpoints.
line = Line(Point(30, 40), Point(120, 150)) line.draw(win)
The Oval
Class
- An oval is specified by two corner points of the bounding box.
oval = Oval(Point(20, 30), Point(180, 90)) oval.draw(win)
The Polygon
Class
- A polygon is a closed shape with an arbitrary number of sides, specified by listing its vertices in order.
p1 = Point(30, 50) p2 = Point(60, 30) p3 = Point(150, 70) poly = Polygon(p1, p2, p3) poly.draw(win)
The Text
Class
- A
Text
object displays a string of characters on the screen centered at a specified point.message = Text(Point(100, 70), "Hello World!") message.draw(win)
The Entry
Class
- An Entry object is a box for entering text, centered at a specified point with a set number of characters displayed.
inputBox = Entry(Point(100, 70), 10) inputBox.draw(win)
Drawing Multiple Objects
- Multiple objects can be drawn in the same window in code.
from graphics import * def main(): win = GraphWin("Shapes", 400, 400) win.setBackground("white") circ = Circle(Point(100, 100), 30) circ.setFill("blue") circ.draw(win) rect = Rectangle(Point(30, 40), Point(120, 150)) rect.setOutline("red") rect.draw(win) line = Line(Point(30, 40), Point(120, 150)) line.draw(win) oval = Oval(Point(20, 30), Point(180, 90)) oval.setFill("yellow") oval.draw(win) poly = Polygon(Point(30, 50), Point(60, 30), Point(150, 70)) poly.setFill("green") poly.draw(win) message = Text(Point(100, 70), "Hello World!") message.draw(win) inputBox = Entry(Point(100, 70), 10) inputBox.draw(win) win.getMouse() win.close() main()
Object Methods
- All graphics objects support a
move(dx, dy)
function that moves the objectdx
units in the $x$ direction anddy
units in the $y$ direction. An example iscircle.move(10, 20)
. - The fill color on filled graphics objects (Circle, Rectangle, Oval, Polygon) can be set using
setFill(color)
.
setOutline(color)
- All graphics objects support a
setOutline
method that sets the outline color of the object.circle.setOutline("red") rectangle.setOutline("blue") line.setOutline("yellow") oval.setOutline("green") polygon.setOutline("black")
setWidth(pixels)
- All graphics objects support a
setWidth
method that sets the width of the outline of the object.circle.setWidth(5) rectangle.setWidth(5) line.setWidth(5) oval.setWidth(5) polygon.setWidth(5)
setText(string)
- The
Text
object supports asetText
method that changes the text that is displayed.message.setText("Goodbye!")
setTextColor(color)
- The
Text
object supports asetTextColor
method that changes the color of the text.message.setTextColor("red")
setSize(point)
- The
Text
object supports asetSize
method that changes the size of the text.message.setSize(14)
setFace(family)
- The
Text
object supports asetFace
method that changes the font of the text.message.setFace("courier")
setStyle(style)
- The
Text
object supports asetStyle
method that changes the style of the text.message.setStyle("italic")
getMouse()
- The
getMouse
method waits for the user to click the mouse inside the window and returns the Point where the mouse was clicked.
Simple Animation
- Code to animate a circle across the screen.
from graphics import * import time def main(): win = GraphWin("Circle", 400, 400) win.setBackground("white") circ = Circle(Point(100, 100), 30) circ.setFill("blue") circ.draw(win) for i in range(100): circ.move(2, 0) time.sleep(0.05) win.getMouse() win.close() main()
- Code to animate a bouncing ball across the screen.
from graphics import * import time def main(): win = GraphWin("Bouncing Ball", 400, 400) win.setBackground("white") circ = Circle(Point(50, 50), 10) circ.setFill("blue") circ.draw(win) dx = 5 dy = 3 while True: circ.move(dx, dy) center = circ.getCenter() if center.getX() < 10 or center.getX() > 390: dx = -dx if center.getY() < 10 or center.getY() > 390: dy = -dy time.sleep(0.02) win.close() main()
Mouse Clicks and Input
getMouse
returns the clicked Point in the window.from graphics import * def main(): win = GraphWin("Click Me!", 400, 400) win.setBackground("white") for i in range(10): p = win.getMouse() circ = Circle(p, 10) circ.setFill("blue") circ.draw(win) win.close() main()
- The
Entry
object can be used to get text input from the user. ThegetText
method returns the string that the user typed into the entry box.from graphics import * def main(): win = GraphWin("Name", 400, 400) win.setBackground("white") nameBox = Entry(Point(200, 200), 20) nameBox.draw(win) win.getMouse() name = nameBox.getText() message = Text(Point(200, 100), "Hello " + name + "!") message.draw(win) win.getMouse() win.close() main()
Case Study: Simple Dice Game
Problem Description
- Simulate rolling two dice with rectangles and dots.
- Allow to roll again by clicking the mouse, until the user quits.
Initial Plan
main()
controls the program.rollDice()
returns a random integer between 1 and 6.drawDice(win, x, y, value)
draws a die with the given value at the location(x, y)
.
Developing the Algorithm
- Create a graphics window.
- Draw the first pair of dice.
- While the user doesn't click the quit button:
- Wait for a mouse click.
- Roll the dice.
- Update the display to show the new dice values.
- Close the window.
Python Implementation
from graphics import *
from random import randrange
def rollDice():
return randrange(1, 7)
def drawDice(win, x, y, value):
# Draw the die as a rectangle
rect = Rectangle(Point(x - 30, y - 30), Point(x + 30, y + 30))
rect.setFill("white")
rect.draw(win)
# Draw the dots
if value == 1:
drawDot(win, x, y)
elif value == 2:
drawDot(win, x - 20, y - 20)
drawDot(win, x + 20, y + 20)
elif value == 3:
drawDot(win, x, y)
drawDot(win, x - 20, y - 20)
drawDot(win, x + 20, y + 20)
elif value == 4:
drawDot(win, x - 20, y - 20)
drawDot(win, x + 20, y + 20)
drawDot(win, x - 20, y + 20)
drawDot(win, x + 20, y - 20)
elif value == 5:
drawDot(win, x, y)
drawDot(win, x - 20, y - 20)
drawDot(win, x + 20, y + 20)
drawDot(win, x - 20, y + 20)
drawDot(win, x + 20, y - 20)
elif value == 6:
drawDot(win, x - 20, y - 20)
drawDot(win, x + 20, y + 20)
drawDot(win, x - 20, y + 20)
drawDot(win, x + 20, y - 20)
drawDot(win, x - 20, y)
drawDot(win, x + 20, y)
def drawDot(win, x, y):
dot = Circle(Point(x, y), 5)
dot.setFill("black")
dot.draw(win)
def main():
win = GraphWin("Dice", 400, 200)
win.setBackground("green")
# Initial dice values
dice1 = rollDice()
dice2 = rollDice()
# Draw the initial dice
drawDice(win, 100, 100, dice1)
drawDice(win, 300, 100, dice2)
# Display the total
total = dice1 + dice2
totalText = Text(Point(200, 30), "Total: " + str(total))
totalText.draw(win)
# Roll the dice until the user clicks the mouse
while True:
click = win.getMouse()
# Roll the dice
dice1 = rollDice()
dice2 = rollDice()
# Clear the dice
for item in win.items[:]:
item.undraw()
# Draw the new dice
drawDice(win, 100, 100, dice1)
drawDice(win, 300, 100, dice2)
# Update the total
total = dice1 + dice2
totalText = Text(Point(200, 30), "Total: " + str(total))
totalText.draw(win)
win.close()
main()
Chapter Summary
- Introduced the basics of computer graphics using the
graphics.py
package. graphics.py
is not standard, so it must be downloaded and saved where Python can access it.GraphWin
creates the graphics window.- Default coordinate 0, 0 is in the upper left corner and 200, 200 in bottom right
Point
establishes the basic building blocks for figures- Classes for creating graphic objects are
Circle
,Rectangle
,Line
,Oval
,Polygon
,Text
andEntry
. move
moves the objectsetFill
sets the interior color, supported by filled graphics objects only.setOutline
sets the outline colour.- setWidth` sets the lines' width, by pixel size.
setText
changes the text that is displayed (for Text object).- 'setTextColor' changes the text colour (for Text object).
- 'setSize' changes the text size (for Text object).
setFace
changes the font (for Text object).setStyle
changes the style (italic, bold, etc).getMouse
waits for the user to click the mouse.- 'Entry' is the object to achieve text input from user.
Lecture 18: Hypothesis Testing
Statistical Hypothesis
- A statistical hypothesis is an assumption about a population parameter that may or may not be true.
Steps for Hypothesis Testing
- State the null hypothesis ($H_0$).
- State the alternative hypothesis ($H_1$).
- Set α, the acceptable probability of wrongly rejecting $H_0$.
- Compute the test statistic.
- Determine the $p$-value.
- Reject $H_0$ if $p \le \alpha$.
Null Hypothesis $H_0$
- A statement of "no effect," "no difference," or "equality."
- $H_0$ is assumed to be true unless there is enough evidence to reject it.
- Examples: $\mu = 100$, $\mu_1 = \mu_2$, $p = 0.5$
Alternative Hypothesis $H_1$
- A statement contradicting the null hypothesis.
- Provides Evidence to support $H_1$.
- Examples: $\mu \ne 100$ (two-tailed), $\mu > 100$ (right-tailed), $\mu < 100$ (left-tailed)
Type I and Type II Errors
Accept $H_0$ | Reject $H_0$ | |
---|---|---|
$H_0$ is true | Correct Decision | Type I Error |
$H_0$ is false | Type II Error | Correct Decision |
- Type I Error: Rejecting $H_0$ when it is true. P(Type I Error) = α
- Type II Error: Failing to reject $H_0$ when it is false. P(Type II Error) = β
Test Statistic
- A value calculated from the sample data to determine whether to reject the null hypothesis.
- Examples: $z = \frac{\bar{x} - \mu}{\sigma / \sqrt{n}}$ (z-test), $t = \frac{\bar{x} - \mu}{s / \sqrt{n}}$ (t-test)
P-value
- Probability of observing a test statistic as extreme as, or more extreme than, the one computed, assuming $H_0$ is true.
- A small $p$-value suggests that the observed data is inconsistent with $H_0$.
- Reject $H_0$ if the $p$-value is less than or equal to $\alpha$.
Diagram
- Is $p \le \alpha$?
- Yes: Reject $H_0$
- No: Fail to Reject $H_0$
The P-value Flow Chart
- Start
- Assume $H_0$ is true.
- Is $p \le \alpha$?
- Yes: Reject $H_0$
- No: Fail to Reject $H_0$
- Conclusion
Lecture 10: Hypothesis Testing
Concepts
- Introduces hypothesis testing.
- Discusses terminology, including types of hypotheses, test statistic, and P-value.
- Explains calculating a P-value for a basic text.
Motivating Example: Extrasensory Perception (ESP)
Terminology
- Subject: The person being tested.
- Trial: A single test of the subject.
- Run: A collection of trials.
Setup
- The experimenter has a deck of 10 cards, 5 red and 5 blue.
- In each trial, the experimenter shuffles the deck, draws a card, looks at it, and asks the subject to guess the color of the card.
- This is repeated for 100 trials (i.e. one run).
- The experimenter records the number of correct guesses.
Question
- If someone does not have ESP, how many correct guesses would we expect?
- Would we ever expect someone to get all 100 correct?
Model
-
Let $X$ be the number of correct guesses.
-
If the subject is guessing randomly, then we can model $X$ as:
$$ X \sim Bin(n = 100, p = 0.5) $$
Terminology
- Null Hypothesis ($H_0$): The assumption that the subject does not have ESP, and is just guessing.
- Alternative Hypothesis ($H_A$): The assumption that the subject has ESP, and is doing better than guessing.
Example
- The subject guesses correctly 63 times out of 100.
- Is this provide strong indication refuting $H_0$?
- How "weird" is this result if the null hypothesis is true?
p-value
- The p-value is the probability of observing a test statistic as extreme as, or more extreme than, the value actually observed, assuming that the null hypothesis is true.
- "Extreme" is defined with respect to the alternative hypothesis.
- The test statistic is the number of correct guesses.
- The p-value is the probability of observing 63 or more correct guesses, if the subject is just guessing. $$ P(X \geq 63) = \sum_{i = 63}^{100} {100 \choose i} (0.5)^i (0.5)^{100 - i} \approx 0.0017 $$
Interpreting the p-value
- The p-value is the probability of observing a test statistic as extreme as, or more extreme than, the value actually observed, assuming that the null hypothesis is true.
- In the example, the p-value calculates to being 0.0017.
- It means that if the subject is just guessing, the probability of observing 63 or more correct guesses is 0.0017.
- The small probability gives strength to rejecting the null hypothesis.
Hypothesis Testing
- Can only be done after a procedure for using sample data to evaluate the credibility.
-
- State the null and alternative hypotheses.
-
- Choose a significance level ($\alpha$).
-
- Calculate the test statistic.
-
- Calculate the p-value.
-
- Make a decision
- Reject the null hypothesis if the p-value is lower than alpha value.
- Otherwise fail to reject the null hypothesis.
- The significance level ($\alpha$) is the probability of rejecting the null hypothesis when it is true and is also known as a Type 1 error.
- 0.05 and 0.01 are common values for α.
Example: Increased Germination
Scenario
- A farmer buys a fertilizer advertised that it increases the seeds germination rate.
- The farmer plants 100 seeds with the new fertilizer and 87 of them germinate.
- Historically, the germination rate for these seeds is 75%.
- Is there evidence that the new fertilizer increases the germination rate
Model
- Let X be the number of seeds that germinate.
- germination can be modeled as: $$ X \sim Bin(n = 100, p = 0.75) $$
Hypothesis Testing
- State the null and alternative hypotheses:
- $H_0$: The fertilizer has no effect on the germination rate (i.e., $p = 0.75$).
- $H_A$: The fertilizer increases the germination rate (i.e., $p > 0.75$).
- Choose a significance level:
- Let's choose $\alpha = 0.05$.
- Calculate the test statistic:
- The test statistic is the number of seeds that germinate, which is 87.
- Calculate the p-value:
- The p-value is the probability of observing 87 or more seeds germinate, if the fertilizer has no effect. $$ P(X \geq 87) = \sum_{i = 87}^{100} {100 \choose i} (0.75)^i (0.25)^{100 - i} \approx 0.0027 $$
- Make a decision:
- The p-value (0.0027) is less than $\alpha$ (0.05), so we reject the null hypothesis.
- We conclude that the fertilizer increases the germination rate.
One-sided vs. Two-sided Tests
- Use a one-sided test
- Because we were only interested in whether the fertilizer increased the germination rate.
- If we were interested in whether the fertilizer had any effect on the germination rate (i.e., either increased or decreased it), we would use a two-sided test.
- We get a p-value of test to see the probability of finding a result at equal limits in either side.
Example: Two-Sided Test
- Check whether a find if a coin is fair.
- Tossed coin to 100 times showing 40 heads
- Showing evidence the coin is biased?
Hypothesis Testing
- State the null and alternative hypotheses:
- $H_0$: The coin is fair (i.e., $p = 0.5$).
- $H_A$: The coin is biased (i.e., $p \neq 0.5$).
- Choose a significance level:
- Let's choose $\alpha = 0.05$.
- Calculate the test statistic:
- The test statistic is the number of heads, which is 40.
-
Calculate the p-value:
$$ P(X \leq 40 \text{ or } X \geq 60) = \sum_{i = 0}^{40} {100 \choose i} (0.5)^i (0.5)^{100 - i} + \sum_{i = 60}^{100} {100 \choose i} (0.5)^i (0.5)^{100 - i} \approx 0.0568 $$
-
Make a decision:
- The p-value (0.0568) is greater than $\alpha$ (0.05), so we fail to reject the null hypothesis.
- We conclude that there is no evidence that the coin is biased.
Summary
- A procedure for using data to evaluate the strength of a hypothesis of a population.
- Hypothesis testing is a formal approach by:
- Define the null and alternative hypotheses.
- Set a significance level (α).
- Determine and calculate test statistic.
- Obtain the P-value.
- Decide the validity by:
- Reject the null hypothesis.
- Otherwise fail to reject the null hypothesis.
- Use a test when only interested in when the test statistic is extreme on one limit.
- A 2 sided test is performed when the statistic is either extreme or has equal probability.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.