<mat-form-field>
is a component used to wrap several Angular Material components and apply common
Text field styles such as the
underline, floating label, and hint messages.
In this document, "form field" refers to the wrapper component <mat-form-field>
and
"form field control" refers to the component that the <mat-form-field>
is wrapping
(e.g. the input, textarea, select, etc.)
The following Angular Material components are designed to work inside a <mat-form-field>
:
<input matNativeControl>
& <textarea matNativeControl>
<select matNativeControl>
<mat-select>
<mat-chip-list>
mat-form-field
supports two different appearance variants which can be set via the appearance
input: fill
and outline
. The fill
appearance displays the form field with a filled background
box and an underline, while the outline
appearance shows the form field with a border all the way
around.
Out of the box, if you do not specify an appearance
for the <mat-form-field>
it will default to
fill
. However, this can be configured using a global provider to choose a different default
appearance for your app.
@NgModule({
providers: [
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}}
]
})
The floating label is a text label displayed on top of the form field control when
the control does not contain any text or when <select matNativeControl>
does not show any option
text. By default, when text is present the floating label floats above the form field control. The
label for a form field can be specified by adding a mat-label
element.
If the form field control is marked with a required
attribute, an asterisk will be appended to the
label to indicate the fact that it is a required field. If unwanted, this can be disabled by
setting the hideRequiredMarker
property on <mat-form-field>
The floatLabel
property of <mat-form-field>
can be used to change this default floating
behavior. It can be set to always
to float the label even when no text is present in the form
field control, or to auto
to restore the default behavior.
The floating label behavior can be adjusted globally by providing a value for
MAT_FORM_FIELD_DEFAULT_OPTIONS
in your application's root module. Like the floatLabel
input,
the option can be either set to always
or auto
.
@NgModule({
providers: [
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {floatLabel: 'always'}}
]
})
Hint labels are additional descriptive text that appears below the form field's underline. A
<mat-form-field>
can have up to two hint labels; one start-aligned (left in an LTR language, right
in RTL), and one end-aligned.
Hint labels are specified in one of two ways: either by using the hintLabel
property of
<mat-form-field>
, or by adding a <mat-hint>
element inside the form field. When adding a hint
via the hintLabel
property, it will be treated as the start hint. Hints added via the
<mat-hint>
hint element can be added to either side by setting the align
property on
<mat-hint>
to either start
or end
. Attempting to add multiple hints to the same side will
raise an error.
Error messages can be shown under the form field underline by adding mat-error
elements inside the
form field. Errors are hidden initially and will be displayed on invalid form fields after the user
has interacted with the element or the parent form has been submitted. Since the errors occupy the
same space as the hints, the hints are hidden when the errors are shown.
If a form field can have more than one error state, it is up to the consumer to toggle which
messages should be displayed. This can be done with CSS, ngIf
or ngSwitch
. Multiple error
messages can be shown at the same time if desired, but the <mat-form-field>
only reserves enough
space to display one error message at a time. Ensuring that enough space is available to display
multiple errors is up to the user.
Custom content can be included before and after the input tag, as a prefix or suffix. It will be included within the visual container that wraps the form control as per the Material specification.
Adding the matPrefix
directive to an element inside the <mat-form-field>
will designate it as
the prefix. Similarly, adding matSuffix
will designate it as the suffix.
If the prefix/suffix content is purely text-based, it is recommended to use the matTextPrefix
or
matTextSuffix
directives which ensure that the text is aligned with the form control.
In addition to the form field controls that Angular Material provides, it is possible to create
custom form field controls that work with <mat-form-field>
in the same way. For additional
information on this see the guide on
Creating Custom mat-form-field Controls.
<mat-form-field>
has a color
property which can be set to primary
, accent
, or warn
. This
will set the color of the form field underline and floating label based on the theme colors
of your app.
By itself, MatFormField
does not apply any additional accessibility treatment to a control.
However, several of the form field's optional features interact with the control contained within
the form field.
When you provide a label via <mat-label>
, MatFormField
automatically associates this label with
the field's control via a native <label>
element, using the for
attribute to reference the
control's ID.
If a floating label is specified, it will be automatically used as the label for the form
field control. If no floating label is specified, the user should label the form field control
themselves using aria-label
, aria-labelledby
or <label for=...>
.
When you provide informational text via <mat-hint>
or <mat-error>
, MatFormField
automatically
adds these elements' IDs to the control's aria-describedby
attribute. Additionally, MatError
applies aria-live="polite"
by default such that assistive technology will announce errors when
they appear.
This error occurs if you have added multiple hints for the same side. Keep in mind that the
hintLabel
property adds a hint to the start side.
This error occurs when you have not added a form field control to your form field. If your form
field contains a native <input>
or <textarea>
element, make sure you've added the matInput
directive to it and have imported MatInputModule
. Other components that can act as a form field
control include <mat-select>
, <mat-chip-list>
, and any custom form field controls you've
created.


tower2diag
tower2diag is a JavaScript tool to easily add boards with stacks or towers
to a webpage. The
source code was based on the board2diag tool.
First, one has to include the call to the tower2diag.js file, in the following
form:
<SCRIPT LANGUAGE="JavaScript" src="tower2diag.js"></SCRIPT>
Then, one can use a new JavaScript part, and make a call to tower2diag. This
version assumes all files are in the same directory (this is easily changed).
Just click on
to download the actual version. The function has two arguments, the
first is a background image for the board (include relative path and extension). The
second argument is a string of the following form:
- Number of columns of the first row
- Comma
- Number of columns of the maximal row
- Comma
- String that describes the position. Here:
- a / marks the end of a row
- a . is one empty square
- 1 to 5, places a tower of 1 to 5 black pieces
- 6 to 0, places a tower of 1 to 5 white pieces
- [abcde] places a tower with five pieces, namely, use 'xwycbgrm' for black, white,
yellow, gray, blue, green, red, magenta. Use uppercase to mark them
(this mark can be used to represent more than 6 stones per stack, for
e.g., each mark means 5 stones).
It's also possible to place an empty cell by using letter 'e'.
- to mark empty cell with numbers, use 'abcdefghi' for 1 to 9.
- to remove a cell inside the board, use 'z'
Version 0.31 - June 2002


"How many designers does it take to replace a light bulb?"
Designer: "Does it have to be a light bulb?"
Think about some of the designs that you consider to be great innovations. Quite likely, they came about because the design team was able to see a new problem or opportunity, or reframe things in a new way. As the light bulb joke illustrates, an important strategy of successful designers is to reframe things so that... we can see things in a new light. This first week's exercise is intended to work your perception and reframing "muscles". How creative can you be? (Later exercises will work different "muscles".)
Any questions about this assignment should be posed to the forums and will be answered promptly by the staff.
For this first project, your mission is to redesign the experience of waiting in line.
An important part of the designer's role is to come up with a point of view. For example, your point of view might be that standing in line is intrinsic, but being bored is not.
What can we do with our time that is more productive, more interesting, or more entertaining than just wait? Maybe it's reading the news, playing a game, or preempt the parents by giving them a surprise call? Alternatively, your point of view might be to eliminate the line by preordering, or hire people to act as placeholders in the line? Or maybe this is precious time for us to do nothing? A few minutes to space out, or quickly center ourselves. No matter what you come up with, it should be something that improves the experience of standing in line. For one jumping off point, here's a few thoughts from the New York Times.
This assignment will introduce iterative design so that during the main course project, the steps of the design process will be more familiar. For further explanations about the design process, have a look at the d.school Bootcamp Bootleg here.
Observing people helps designers learn more about their needs, goals, desires, abilities, values, and situation. In this assignment, we bootstrapped this process for you by observing and interviewing people about standing in line. You can find the video here. Go through the video. If you have the opportunity, you are encouraged to observe and interview line-waiters by yourself.
Use insights from it as background material, and brainstorm ideas for how you would redesign the waiting in line experience. Go for volume when you brainstorm, you should come up with at least 20 different ideas. Ask a couple of people to get together and brainstorm with you, you will find that it's easier to find inspiration when you work with other people.
Select your two favorite ideas and give a 1-sentence explanation of why you chose each. Choosing these two prototypes does not mean that you will have to work on them for the rest of the quarter. We would like you to get a good idea of how to use these skills and determine problems before choosing your final project idea.
Take these two ideas and rapidly prototype them. Really rapidly. No computers. Go for very, very simple. For instance, if your idea involves a mobile phone, use 3 x 5 index cards to represent the screen, and a sharpie. Anything that won't fit into that is too detailed. If your idea is more conceptual, rapidly prototype the experience however you see fit. Use any props you think will effectively convey the look and feel of the user experience, but remember to keep it simple. As a rule of thumb, each prototype should take about a half-hour to produce.
Take pictures of your prototypes.
Now you are ready for feedback. Pick one of your prototypes and find people (people really waiting in line) to try it out. Go to the place you intend your design to be used, people who will use your prototype as if it was a real application. Explain that you'd like their help, and that it'll take 5-10 minutes of their time. If the activity is quick, we recommend trying it on at least 5 people. If it takes some time, at least 3 users should be fine.
Given that your prototype is made of pulp, markers, and imagination, you'll need to be an active operator. For example, if a user "clicks" a button, you simulate what would happen by changing screens (new index card). Do not tell the user what to do. Prototypes are a probe; a way to get feedback and learn how to improve your design. Success is not blithely saying "people really liked it" but rather "I learned all of these cool things that will make the design better". Iterative design is about "failing" early and often, in order to rapidly arrive at a great design.
Take notes and pictures of what users do and say. Pay attention to when people get confused or if they offer feedback on what they liked or didn't like. Use your notes to help you reflect on the feedback you received; distill a list of major insights that could inform a future revision. These insights should require some reflection on your part; it is not just taking what users take point blank.
Check out an example of this assignment from last year here. Keep in mind that the assignment was slightly different last year.
| Category | Unsatisfactory | Bare minimum | Satisfactory effort & performance | Above & Beyond | Outside the Box |
|---|---|---|---|---|---|
| Brainstorm | 0: No ideas brainstormed. | 1: Less than 5 ideas brainstormed that connect to a user need or point of view. | 3: 5 - 10 ideas brainstormed that connect to a user need or point of view. | 5: 20 ideas brainstormed that connect to a user need or your point of view. | |
| Prototype Reasoning | 0: No explanation submitted. | 1: The reasoning was thin, could have applied to many different ideas, and/odoes not relate to a user need. | 3: The reasoning somewhat connects to the point of view or a user need. | 5: The reasoning connects strongly to a point of view or a user need. | |
| Prototype Quality | 0: No prototypes submitted. | 3: Fewer than 2 prototypes; unnecessary formality. | 5: 1 prototype, created rapidly OR 2 prototypes, unnecessary formality. | 7: 2 prototypes, created rapidly. | 8: Really creative (i.e., both novel and useful) prototyping technique. |
| Testing | 0: No user testing. | 1: The testing was hasty, and done with your roommates for the sake of convenien. | 3: The testing was hasty, although done with real users who were waiting ia real line. | 5: Yes. With real users who were waiting in a real line. | |
| Insights | 0: No insights submitted. | 2: The list just contains things that could have been figured out without anprototyping and testing. | 4: Pretty much all the insights came from either silent visual observatioor direct user feedback (but not both). | 6: Conceptual insights that would enable revision. It was obvious that visuaobservation of the users and direct feedback from the users were both helpful. | 7: Unearthed a sublime point of view. |


This game was custom-coded for the final advent calendar entry. It's a classic that we hope you'll enjoy (the hint is in the title). Thank you for following QEMU Advent Calendar 2014, it's been great fun to share an interesting disk image each day. Happy New Year!
Contributed by Kevin Wolf, Max Reitz, and Stefan Hajnoczi. Unpack with tar xf day24.tar.xz and run the day24/run script. Source code
DownloadPebble smartwatch can be connected to iOS and Android devices and runs its own apps. The emulator for app development is QEMU and the Pebble team have made a preview release available for the QEMU Advent Calendar! Check out the Getting Started guide for app development in C or Javascript.
Disk image prepared by Matthew Hungerford at Pebble. Unpack with tar xf pebble-qemu-preview.tar.xz and launch the pebble-qemu-preview/run script. Source code
DownloadWe can't finish the advent calendar without a System z mainframe disk image. Here is an ASCII art action game that turns out to be quite fun! Drive your moon buggy across craters and shoot aliens - a clear task for the mainframe.
Disk image prepared by Alexander Graf, game by Jochen Voss. Unpack with tar xf s390-moon-buggy.tar.xz and run the s390-moon-buggy/run script. Source code
DownloadThe Ninth annual ICFP Programming Contest hosted by Carnegie Mellon University's POP Group was an epic programming puzzle, perfect for the winter holiday break. This disk image has everything you need to start exploring a series of challenging puzzles into programming languages and obscure systems. Read the full back-story here.
Disk image prepared by Stefan Hajnoczi, puzzle source code released by CMU POP Group under GPL. Unpack with tar xf boundvariable.tar.xz and launch the boundvariable/run script. Source code
DownloadHelenOS is a modern, general-purpose operating system written from scratch. It is based on microkernel multiserver design principles. Core system functionality is decomposed into isolated, intensively communicating and mostly simple user space tasks. HelenOS is still in development and this is a preview of the upcoming 0.6.0 release. There is a step-by-step tutorial and the HelenOS wiki.
Disk image prepared by Martin Decky, Jakub Jermar, and Mark Cave-Ayland. Unpack with tar xf helenos.tar.xz and run the helenos/run script. Source code
DownloadThe Mandelbrot set is one of the most well-known fractals. This demo for PowerPC implements the fractal in Forth so it executes as an OpenFirmware boot script. You can zoom in/out and move around the fractal.
Contributed by Dr. David Alan Gilbert. Unpack with tar xf mandelbrot.tar.xz and launch the mandelbrot/run script. Source code
DownloadThe Ceph open source distributed storage system has become a popular way to provide cloud storage and VM disk image hosting on commodity hardware. Object storage, block storage, and file system use cases are all supported. A quickstart guide is available, try ceph status.
Disk image prepared by Patrick McGarry. Unpack with tar xf ceph.tar.xz and run the ceph/run script. Source code
DownloadBB is an ASCII art demo that renders surprisingly smooth effects using aalib. aalib converts pixel images or movies to ASCII art using the shapes of characters to achieve pleasing visuals. Matrix digital rain fans will enjoy this demo!
Disk image contributed by Christian Horn, demo by Filip Kupsa, Jan Hubicka, Mojmir Svoboda, and Kamil Toman. Unpack with tar xf bb_debian.tar.xz and launch the bb_debian/run script. Source code
DownloadTempest Showroom plays melodies on AM radio by displaying specific image patterns. Back when CRT monitors were the norm, there were concerns about electromagnetic surveillance due to the signals that computer systems emitted. A related demo is Fabrice Bellard's Analog and Digital TV (DVB-T) Signal Generation.
ISO by Dirk Loss, Tempest for Eliza by Erik Thiele. Unpack with tar xf tempest-showroom.tar.xz and run the tempest-showroom/run script. Source code
DownloadPlan 9 from Bell Labs was designed as a successor to Unix. Some of its key features made it back into Linux, including private mount namespaces, userspace file systems, and UTF-8. You still need to experience the original where these concepts really work together to achieve an elegant operating system.
Disk image contributed by Stefan Hajnoczi. Unpack with tar xf plan9.tar.xz and launch the plan9/run script.
DownloadThe Multiboot boot sequence is supported by the GRUB bootloaders and QEMU as a way to standardize common mechanisms like kernel command-lines, modules/initrd, x86 protected mode, and graphics mode at startup. This little spaceship game is implemented as a Multiboot-compliant binary so it can be loaded directly by QEMU.
Disk image prepared by Fam Zheng and Fabian Greffrath, game by Erik Thiele. Unpack with tar xf invaders.tar.xz and run the invaders/run script. Invaders source code
DownloadSecond Reality is a well-known PC demo from 1993 that combines both 2D and 3D graphics techniques. The source code was released in 2013. Try it out and bring the demo to life in QEMU!
Disk image was contributed by Paolo Bonzini. Unpack with tar xf 2nd-reality.tar.xz and launch the 2nd-reality/run script. Second Reality source, FreeDOS source
DownloadOberon is both a family of operating systems and a programming language created by Niklaus Wirth of Modula-2 and Pascal fame. This image contains the PC Native Oberon variant with an Oberon compiler, network stack, file systems, and graphical user interface. A parallel universe without UNIX or C...
Prepared by Stefan Hajnoczi with help from Peter Easthope. Unpack with tar xf oberon.tar.xz and run the oberon/run script.
DownloadOSv is a guest operating system that eliminates redundant layers of systems software by building a combined kernel, runtime, and application image. The idea is to simplify management while improving performance. This disk image includes the Redis key-value store for your NoSQL enjoyment.
Dor Laor contributed this image. Unpack with tar xf osv-redis.tar.xz and launch the osv-redis/run script. OSv source, Redis source
DownloadWhy do things properly when you can attempt them in 512 bytes? This selection of demos leaves no precious byte untouched. Featuring a ray tracer that spells out "QMU", a software-rendered triangle, and a nyan cat demo to rock your PC speaker with a sweet tune.
Demos and disk image by Max Reitz. Unpack with tar xf 512.tar.xz and run the 512/run script. Triangle source, raytracer source, nyan cat source, GRUB source
DownloadSurprise, Ubuntu is adding a new member to their family, Ubuntu Core! The new Snappy package manager makes it easy to share apps or containers with transactional updates. The whole image weighs in at 110 MB and uses kernel confinement to isolate apps for security. Say hello to the new cloud guest operating system from Ubuntu!
Mark Shuttleworth and Alexander Sack contributed this image. Unpack with tar xf ubuntu-core-alpha.tar.xz and launch the ubuntu-core-alpha/run script. Source code
DownloadThis port of the Frotz Z-Machine interpreter allows you to play the original Zork text adventure game on TianoCore UEFI firmware. A significant milestone in UEFI gaming? You be the judge in this showcase of virtual machines without legacy BIOS.
Gerd Hoffmann prepared this disk image from Matthew Garrett's UEFI Boot to Zork. Unpack with tar xf qemu-xmas-uefi-zork.tar.xz and read the qemu-xmas-uefi-zork/README file. TianoCore edk2 source, UEFI Frotz source
DownloadThe venerable MINIX operating system has conquered x86 and ARM platforms with microkernel goodness. Famous for isolating and running operating system components in separate processes so the system can survive failures, MINIX 3 takes pieces from NetBSD userspace so it feels like UNIX - just unstoppable and about to take over the world!
Fam Zheng prepared this image. Unpack with tar xf qemu-xmas-minix3.tar.xz and launch the qemu-xmas-minix3/run script. Source code
DownloadThis tiny disk image renders a Julia fractal in 640x480 resolution 256 color animated glory! Besides using the quaint 256 color palette, this image has a nice sequence of floating point calculations if you want to refresh your x87 instruction knowledge. For a write-up and more screenshots, see this blog post and this one.
Riku Voipio prepared this disk image from Keegan McAllister's demo. Unpack with tar xf fractal-mbr.tar.xz and launch the fractal-mbr/run script. Source code
DownloadQEMU is the first open source emulator with 64-bit ARM support (also known as aarch64). That's right, QEMU doesn't just emulate old hardware, it emulates hardware you may not even own yet!
Riku Voipio contributed this cutting-edge image. Unpack with tar xf arm64.tar.xz and launch the arm64/run script. Instructions for building latest QEMU included. Image source
DownloadSanta has brought you an Atari ST. Get ready for an emulator-inside-an-emulator image that boots straight into the Hatari emulator and the free EmuTOS ROM. This image comes with Atari ST demos for you to enjoy, plus the retro desktop interface.
Thomas Huth contributed this disk image. Unpack with tar xf stxmas.tar.xz and launch the stxmas/run script. Hatari source, EmuTOS source, Linux
DownloadThe first image about algorithms (and there are more puzzles to come). How does this tiny boot sector calculate digits of pi? Disassemble with objdump -D -b binary -m i8086 pi.vfd or mount the disk image's FAT file system to view the source.
Paolo Bonzini prepared this disk image based on QEMU's pi_10.com test case. Unpack with tar xf pi.tar.xz and launch the pi/run script.
DownloadThis FreeDOS disk image contains the latest and greatest from the land of the Disk Operating System. Besides checking out the DOS TCP/IP stack you never got a chance to use with your 2400 baud modem, you can relive id Software's early shareware hit Commander Keen. As a bonus the freeware edition of Jetpack is also included for crazy jet-powered platform action.
Stefan Hajnoczi provided this disk image. Unpack with tar xf freedos.tar.xz and launch the freedos/run script. FreeDOS source
DownloadWhat happens when you dig up the earliest Slackware Linux image to be had? Travel back in time and experience Linux in its early days. And when we say early, we mean kernel pre-1.0 early! The Slackware distribution is the oldest still maintained distribution.
Gerd Hoffmann has provided this blast from the past. Unpack with tar xf qemu-xmas-slackware.tar.xz and check out the qemu-xmas-slackware/README file. Image source
DownloadThe QEMU Advent Calendar 2014 website features a QEMU disk image each day of December until Christmas.
Each day a new disk image file becomes available for download. A QEMU command-line is posted along with the disk image file as the recommended way to start the disk image.
The disk images contain interesting operating systems and software that runs under the QEMU emulator. Some of them are well-known operating systems, old and new, others are custom demos and neat algorithms.
The disk images were created by volunteers from the QEMU community to showcase cool software that QEMU can run.
To get in touch please email<EMAIL_ADDRESS>and CC Stefan Hajnoczi <stefanha@gmail.com>.


/* code snippets for Input control */ /* textarea element */ We live in a mobile-first and cloud-first world. Computing is ubiquitous, and experiences span devices and exhibit ambient intelligence. /* select element */ Processing Big Data with Azure HDInsight Introduction to R Programming Office 365: Managing Identities and Services Introduction to jQuery Processing Big Data with Azure HDInsight Introduction to R Programming Office 365: Managing Identities and Services Introduction to jQuery /* Form element Example */


CASCADE 1.0 Analysis (All models)
Network Properties
In this section we demonstrate the scale-free properties of the CASCADE 1.0 network. We show that both in- and out-degree distributions are asymptotically power-law.
Use the script get_distribution_stats.R to generate the degree distribution stats. We load the results:
dd_stats %>% group_by(in_degree) %>% tally() %>%
ggplot(aes(x = in_degree, y = n)) +
geom_bar(stat = "identity", fill = "steelblue", width = 0.7) +
geom_smooth(aes(color = "red"), se = FALSE, show.legend = FALSE) +
theme_classic() +
labs(title = "In-Degree Distribution (CASCADE 1.0)", x = "In Degree", y = "Number of Nodes")
dd_stats %>% group_by(out_degree) %>% tally() %>%
ggplot(aes(x = out_degree, y = n)) +
geom_bar(stat = "identity", fill = "steelblue") +
geom_smooth(aes(color = "red"), se = FALSE, span = 0.58, show.legend = FALSE) +
theme_classic() +
labs(title = "Out-Degree Distribution (CASCADE 1.0)", x = "Out Degree", y = "Number of Nodes")
Model Stable State Statistics
Using abmlog we generated all \(2^{23} = 8388608\) possible link operator mutated models for the CASCADE 1.0 topology.
The models are stored in both .gitsbe
and .bnet
files in the Zenodo dataset .
The gitsbe
files include also the fixpoint attractors.
Thus we can find the frequency distribution of the number of fixpoints across all produced models (use the script count_models_ss.R).
The model stable state (fixpoint) statistics are as follows:
models_ss_stats = readRDS(file = "data/models_ss_stats.rds")
models_ss_stats %>% group_by(ss_num) %>% tally() %>%
ggplot(aes(x = ss_num, y = n, fill = as.factor(ss_num))) +
geom_bar(stat = "identity", show.legend = FALSE) +
geom_text(aes(label = n), vjust = -0.5) +
geom_text(aes(label = paste0(100 * round(n/nrow(models_ss_stats), digits = 2), "%")), size = 10, vjust = c(2.5, 2.5, -2)) +
theme_classic2() +
theme(plot.title = element_text(hjust = 0.5)) +
labs(title = "Stable States Distribution", x = "Number of Stable States", y = "Number of models")
Less than \(50\%\) of the total possible parameterized models have a single fixpoint attractor which corresponds to a single stable phenotype behavior.
Stable States Data
To load the stable state data for the models that have 1 stable state use the Zenodo dataset and the script get_ss_data.R
Parameterization vs #fixpoints
In this subsection we identify the key nodes whose parameterization affects the change of dynamics of the CASCADE 1.0 network, i.e. are responsible for the change in the number of fixpoint attractors (0,1 and 2) across all link-operator mutated models.
We will use several statistical methods, in each of the sub-sections below.
The training data is a link-operator matrix, where rows are models (\(2^{23}\)), columns/features/variables are link-operator nodes (\(23\) in total) and the parameterization values correspond to \(0\) (AND-NOT
) or \(1\) (OR-NOT
).
The ternary response for each model is a number denoting the number of fixpoints (\(0,1\) or \(2\)).
The matrix we can generate with the script get_lo_mat.R and the response is part of the previously generated data from the script count_model_ss.R.
Glmnet
Use the script param_ss_glmnet.R to fit a multinomial LASSO model for the data (Friedman, Hastie, and Tibshirani 2010). We now simply load the result object:
As we can see there is no \(\lambda\) that could explain more than \(44\%\) of the deviance and there are a lot of non-zero coefficients associated with smaller values of \(\lambda\). For example, choosing \(\lambda = 0.0142\) (tested prediction accuracy \(\approx 0.72\) on a random subset of the data), we have the following coefficients, shown in a heatmap:
# choose a lambda
lambda1 = fit_a1$lambda[32]
fit_a1_coef = coef(fit_a1, s = lambda1) %>%
lapply(as.matrix) %>%
Reduce(cbind, x = .) %>% t()
rownames(fit_a1_coef) = names(coef(fit_a1, s = lambda1)) # 0, 1 and 2 stable states
imp_nodes_colors = rep("black", length(colnames(fit_a1_coef)))
names(imp_nodes_colors) = colnames(fit_a1_coef)
imp_nodes_colors[names(imp_nodes_colors) %in% c("MEK_f", "PTEN", "MAPK14")] = "green4"
ComplexHeatmap::Heatmap(matrix = fit_a1_coef, name = "Coef", row_title = "Number of Fixpoints",
row_names_side = "right", row_dend_side = "right", row_title_side = "right",
column_title = "Glmnet Coefficient Scores (λ = 0.0142)",
column_dend_height = unit(20, "mm"), column_names_gp = gpar(col = imp_nodes_colors))
# check accuracy
# lo_mat = readRDS(file = "data/lo_mat.rds")
# models_ss_stats = readRDS(file = "data/models_ss_stats.rds")
# ss_num = models_ss_stats %>% pull(ss_num)
# set.seed(42)
# model_indexes = sample(x = 1:nrow(lo_mat), size = 100000)
# pred = predict(object = fit_a1, newx = lo_mat[model_indexes, ],
# type = "class", s = lambda1) %>% as.integer()
# acc = sum(pred == ss_num[model_indexes])/length(pred)
# print(acc) # should be ~ 0.72
Even thought the glmnet classifier might not be accurate enough, we still find that the nodes PTEN
and MAPK14
are the most important (larger coefficients) for distinguishing between the models with different number of fixpoints.
Additional nodes (like MEK_f
and CTNNB1
) are likely to be important as well.
If we cross-validate the regularization parameter \(\lambda\) (using the same script, we randomly selected smaller model samples - \(100000\), \(20\) times in total), and choose the \(\lambda_{1se}\) for each different run to get the coefficients, the results can be visualized as follows:
cvfit_data = readRDS(file = "data/cvfit_data.rds")
cvfit_mat_list = lapply(cvfit_data, function(cvfit) {
co = coef(cvfit) %>%
lapply(as.matrix) %>%
Reduce(cbind, x = .) %>%
t()
rownames(co) = names(coef(cvfit)) # 0,1 and 2 stable states
return(co)
})
cvfit_mat = do.call(rbind, cvfit_mat_list)
imp_nodes_colors = rep("black", length(colnames(cvfit_mat)))
names(imp_nodes_colors) = colnames(cvfit_mat)
imp_nodes_colors[names(imp_nodes_colors) %in% c("MEK_f", "PTEN", "MAPK14", "CTNNB1", "mTORC1_c")] = "green4"
ComplexHeatmap::Heatmap(matrix = cvfit_mat, name = "Coef", row_title = "Number of Fixpoints",
row_dend_side = "right", row_title_side = "left",
column_title = "Glmnet Coefficient Scores", row_km = 3, row_km_repeats = 10,
show_row_names = FALSE, column_dend_height = unit(20, "mm"),
column_names_gp = gpar(col = imp_nodes_colors),
left_annotation = rowAnnotation(foo = anno_block(
labels = c("2", "1", "0"), # with `show_row_names = TRUE` you can check this
labels_gp = gpar(col = "black", fontsize = 12))))
The top 5 most important nodes are seen in green in the above heatmap: MAPK14
, PTEN
, CTNNB1
, MEK_f
and mTORC1_c
.
Random Forest
We used the param_ss_randf.R script to tune and train a random forest classifier on the dataset (Liaw and Wiener 2002).
First we tuned the mtry
parameter, the number of variables randomly selected at each tree split:
mtry_data = readRDS(file = "data/mtry_data.rds")
mtry_data %>%
ggplot(aes(x = mtry, y = OOBError, group = mtry)) +
geom_boxplot(fill = "green4") +
labs(title = "Tuning Random Forest mtry parameter") +
theme_classic(base_size = 14) + theme(plot.title = element_text(hjust = 0.5))
A value between \(14-18\) for mtry
seems to minimize the Out-Of-Bag Error, so we choose \(16\) for the rest of the analysis.
For the number of trees parameter, we stayed with the default value (\(500\)) as we observed that they were more than enough after a few test runs.
Next, we randomly selected \(100000\) models from the dataset - a total of \(20\) times - to train the random forest classifier and find the importance score of each node. We load the result data and tidy up a bit:
rf_imp_data = readRDS(file = "data/rf_imp_data.rds")
# make a list of tibbles
tbl_list = lapply(rf_imp_data, function(mat) {
nodes = rownames(mat)
tibble::as_tibble(mat) %>% mutate(nodes = nodes)
})
# OneForAll
imp_res = dplyr::bind_rows(tbl_list)
# Get the importance stats
imp_stats = imp_res %>%
group_by(nodes) %>%
summarise(mean_acc = mean(MeanDecreaseAccuracy),
sd_acc = sd(MeanDecreaseAccuracy),
mean_gini = mean(MeanDecreaseGini),
sd_gini = sd(MeanDecreaseGini),
.groups = 'keep') %>%
ungroup()
The importance scores for each node were the mean decrease in accuracy and node impurity (Gini Index). We calculate the mean importance and standard deviation scores across all random samples for both measures of importance:
# color first 5 nodes in x axis
imp_col = c(rep("green4", 5), rep("grey30", nrow(imp_stats)-5))
imp_stats %>%
mutate(nodes = forcats::fct_reorder(nodes, desc(mean_acc))) %>%
ggplot(aes(x = nodes, y = mean_acc, fill = mean_acc)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_gradient(low = "steelblue", high = "red") +
geom_errorbar(aes(ymin=mean_acc-sd_acc, ymax=mean_acc+sd_acc), width = 0.2) +
theme_classic(base_size = 14) +
theme(axis.text.x = element_text(angle = 90, colour = imp_col)) +
labs(title = "Random Forest Variable Importance (Accuracy)",
x = "Nodes", y = "Mean Decrease Accuracy")
imp_stats %>%
mutate(nodes = forcats::fct_reorder(nodes, desc(mean_gini))) %>%
ggplot(aes(x = nodes, y = mean_gini, fill = mean_gini)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_gradient(low = "steelblue", high = "red") +
geom_errorbar(aes(ymin = mean_gini-sd_gini, ymax = mean_gini+sd_gini), width = 0.2) +
theme_classic(base_size = 14) +
theme(axis.text.x = element_text(angle = 90, colour = imp_col)) +
labs(title = "Random Forest Variable Importance (Gini Index)",
x = "Nodes", y = "Mean Decrease in Node Impurity")
The top 5 important nodes by any of the two importance measures using random forests, include the nodes found as important with the LASSO method: MAPK14
, ERK_f
, MEK_f
, PTEN
, mTORC1_c
.
Same results we get when using a faster, more memory efficient and with multi-thread support, random forest R package, namely ranger
(Wright and Ziegler 2017).
Use the script param_ss_ranger.R to reproduce the results:
ranger_res = readRDS(file = "data/ranger_res.rds")
imp_res = tibble(nodes = names(ranger_res$variable.importance),
gini_index = ranger_res$variable.importance)
imp_res %>%
mutate(nodes = forcats::fct_reorder(nodes, desc(gini_index))) %>%
ggplot(aes(x = nodes, y = gini_index, fill = gini_index)) +
geom_bar(stat = "identity", show.legend = FALSE) +
scale_fill_gradient(low = "steelblue", high = "red") +
scale_y_continuous(labels = scales::label_number_si()) +
theme_classic(base_size = 14) +
theme(axis.text.x = element_text(angle = 90, colour = imp_col)) +
labs(title = "Random Forest (Ranger) Variable Importance (Gini Index)",
x = "Nodes", y = "Mean Decrease in Node Impurity")
Parameterization Map
We use UMAP (McInnes, Healy, and Melville 2018) to reduce the dimensionality of our dataset from \(23\) (number of nodes with link operators) to \(2\) and visualize it to see if there is any apparent visual relation between the models parameterization and number of fixpoints.
We used the param_ss_umap.R script to run the UMAP implementation offered by the uwot
R package.
We make the plots afterwards using the result data with the param_ss_umap_vis.R script.
Unsupervised UMAP
First we used UMAP in unsupervised mode (no a priori knowledge of the number of fixpoints per model provided or of any other information/label per model for that matter).
So, UMAP is given a subset of all binary numbers from \(0\) (\(23\) \(0\)’s) to \(2^{23}-1\) (\(23\) \(1\)’s) representing each possible link operator mutated model (\(0\)’s map to AND-NOT
, \(1\)’s to OR-NOT
) and places them in the 2D plane.
The following figures show us the 2D parameterization map of all CASCADE 1.0 models, colored either by their decimal (base-10) number (converted from the binary link-operator model representation) or by their respective number of fixpoints:
knitr::include_graphics(path = "img/all_models_maps/umap_20nn_model_num.png")
knitr::include_graphics(path = "img/all_models_maps/umap_20nn.png")
UMAP has found \(8\) neighboorhoods/superclusters of similarly parameterized models, which seem to follow the numerical representation (i.e. models with close decimal numbering seem to be clustered together).
Also, models with similar parameterization seem to also have the same number of fixpoints (i.e. there is some order in the placement of models that belong to the same fixpoint class - this phenomenon does not manifest chaotically).
Supervised UMAP
Next, we used UMAP in supervised mode - i.e. the association between each model and the corresponding fixpoint group was given as input to UMAP:
We observe that the \(2\)-fixpoint model structures are spread out in the Y dimension much less than the corresponding \(0\) and \(1\)-fixpoint models. Also, the X dimension can clearly be used to distinguish between the 3 attractor classes.
So, it seems that the more complex are the models (here we mean dynamical complexity - i.e. more attractors) the more spread out are in the parameterization map and form many more distinct clusters.
Embedding Important Nodes in the Map
Using random forest and the regularized LASSO method, we found important nodes whose parameterization affects the change of dynamics (number of fixpoints). Using (supervised) UMAP we took a sample of the dataset (\(33\%\) of the models) and placed it to the 2D plane, linking closely parameterized models in clusters.
We will now color the supervised UMAP-generated map with the link-operator values of the top 5 most important nodes found from the aforementioned methods as well the least important node reported with random forests (use the param_ss_umap_imp_nodes.R script).
The 3 most important nodes:
#knitr::include_graphics(path = "img/umap_supervised_MAPK14.png")
#knitr::include_graphics(path = "img/umap_supervised_MEK_f.png")
#knitr::include_graphics(path = "img/umap_supervised_ERK_f.png")
The next 2 most important nodes:
#knitr::include_graphics(path = "img/umap_supervised_mTORC1_c.png")
#knitr::include_graphics(path = "img/umap_supervised_PTEN.png")
CFLAR
was the least important node for assessing the number of fixpoints of a model from its parameterization:
We can see a visual link between node importance (related to #fixpoints) and link operator assignment: the less important a node is, the more randomly distributed (chaotically) it’s link-operator values are across the parameterization map.
The important nodes can be used to more accurately define families of closely parameterized models.


v1.0.0
npm install mq-js --save
This documentation is best viewed on a Desktop computer or laptop for the sake of viewing the examples at all screen sizes.
This documentation also assumes that you have the ability to use ES6 JavaScript syntax in your project. Try looking into Yeogurt or Babel if you aren't already using ES6 syntax in your projects.
mq-js was inspired by the mq-scss Sass mixin. I wanted to use media queries in JavaScript in a similar sort of way to how I was using media queries in my Sass code.
If you haven't looked into mq-scss I highly recommend checking it out. It makes writing media queries far easier than any other method.
Firstly, use npm install mq-js --save
to add the npm module to your project. If you haven't used npm before, read through this documentation to get set up.
Now, create this simple mq.js
file to set up your website breakpoints.
OR
Alternatively you can save the breakpoints into a JSON file, then import them.
The above breakpoints are what I will be using throughout the examples in this documentation.
I'm providing 2 export statements in the examples. This makes it super easy to access your site breakpoints since it is just a matter of switching out your import statement when you need to. It also means that it doesn't matter if you pull the breakpoints in using JSON or define them directly in the mq.js
file, the code to access them is the same either way.
Now that you have your break points set up, you can use them when calling the function without having to import them. I'll get to why you might want to import the breakpoints
variable later. For now, just stick to only importing the mq
variable on it's own.
In the following example, the button will only turn green if you click it when the browser window is at a minimum width of 981px wide (ie. above the "medium" breakpoint).
To help you figure out when the button is able to be clicked, the border of the button will turn green when it is clickable.
As you can see, you can easily access the "medium"
breakpoint that you defined by simply parsing a string as the breakpoint value. There is no need to import the breakpoints
variable from the mq.js
file to use the "medium"
breakpoint.
You might be wondering why 981px instead of 980px. I will get into that a bit more later but for now just know that it is primarily to avoid conflicts.
You can also use it in an if statement sort of format. Here is the same example again except this time as an if statement.
Notice that the first example gives you access to the screen width at the time the button is clicked. The second example does not (or at least not without custom code).
Also notice that I'm not binding and unbinding the click function on screen resize. By placing mq
inside the click function, it behaves very similarly to how media queries behave in css.
mq.max
does pretty much what you expect it to do. It will only run the function if the screen width is bellow the specified breakpoint.
All of these functions also come in the if
statement format. For the sake of brevity though, I'm just showing the callback
format in the rest of these examples.
mq.max
is inclusive of the breakpoint value where as mq.min
is exclusive of the breakpoint value. That is why mq.min
essentially adds +1 to the breakpoint value when used. This serves two important purposes:
It prevents bugs from occurring in that 1px sweet spot where both would otherwise return true.
It aligns with how mq-scss handles min and max width to prevent odd bugs where JavaScript is firing but the styles aren't there to support it (or vice versa).
mq.inside
works in much the same way as it does in mq-scss.
Instead of stating one value then calling the function, you state two values then call the function.
You can state the breakpoint values in any order but the function needs to be called last (if at all). The function will be triggered if the screen width sits between the two breakpoint values when it is called.
The smaller value always gets +1 for consistency with the mq-scss mixin and to prevent the issues mentioned above.
mq.outside
does what you would expect. It is the opposite of mq.inside
. It will only fire if the screen width is outside of the two breakpoint values.
One of the big features in mq-scss is that you can easily create meaningful media query variables.
Here is how to do a similar sort of thing using mq-js:
Just because you have access to the breakpoint values doesn't mean you have to use them. mq-js still works if you just parse solid numbers into it.
Remember that if you use mq.min
it will be like adding 1 pixel to the value you provide.
What if you only want to tweak one of the normal breakpoint values though so it is just a few pixels larger than the base break point? That is when it is useful to import the breakpoint
variable.
In the following example, I'm importing the breakpoints variable and using it to add 30px to the "medium"
breakpoint.
mq-js is just a simple function that checks the current window size when it is called. It doesn't do anything fancy when you resize the window.
The following example uses Debounce to prevent the function from firing until the window has finished resizing. This improves performance and can avoid odd bugs from occurring.
The button will activate when the screen is at the correct width and deactivate when not. Clicking the button does nothing.
Currently mq-js only supports the mq-scss width based ranges since those are the most important. I will be adding support for more of the mq-scss range types in future updates.


Your LaTeX document does not contain
\documentclass
. Every LaTeX document should have a
\documentclass
command.


Author Lee Child explores origins of hero concept
by Jeff Ayers“The Hero,” TLS, by Lee Child
“The Hero,” a non-fiction essay by author Lee Child, opens with Child looking at language and how words have different meanings over the space of time. Child also asks the question of who was the first person to initiate a particular word or phrase and have that definition mean the same for everyone.
As time passed, people began to tell each other stories. The stories probably were basic at first and then over time heroic traits were added to keep the audience engaged with the tale. The works of Homer saw a hero as a warrior who approached everything with a sense of honour, kind of like the Klingons in “Star Trek.” Today, a hero can be described as a popular athlete or someone who does the right thing under difficult circumstances. How did that change occur?
Child writes popular and intriguing thrillers and his talent for compelling prose isn’t limited to fiction. He delivers an interesting premise and backs up his hypothesis with data and personal insight.
What this book lacks in page count more than compensates in a thought-provoking discussion of the origins of language, storytelling and what makes all of us human.
___
Online:
https://www.leechild.com/


Welcome
Thank you for agreeing to participate in our evaluation. Please ensure that you have been presented with your informed consent form and information booklet. Enter your Participant Number below and continue.
Thank you for agreeing to participate in our evaluation. Please ensure that you have been presented with your informed consent form and information booklet. Enter your Participant Number below and continue.


To gain entry into our elite team of rainforest ecologists, you must successfully complete this exercise,
demonstrating your knowledge of rainforest ecology, knowledge of your specialist species, problem solving-skills
and ability to work in a team-based environment. This exercise consists of 5 steps and will take approximately
30 minutes to complete.
When you are ready to begin, proceed to the simulation lab (in room 204a) and perform a QR scan with this device.
QR code scanning failed
QR scan on room entry failed. Either proceed without scanning or try again.
Welcome to the simulation lab
There are four different versions the Borneo rainforest ecosystem here. Why do they look different?
What happened to these systems? As part of today's exercise you will work with the others in this room to
figure this out.
But first, to facilitate the problem-solving process, you are asked to look for these species (shown above)
within their speciality, across all four rainforests. This is a divide and conquer strategy for everyone to take
stock of the species are in the rainforest ecosystems.
When you are ready, approach one of the rainforest stations and perform a QR scan.
Rainforest QR code scanning failed!
Scanning the QR code of the rainforest failed. Please try again or proceed by pressing the button for the rainforest you are at.
Location:
Organism
Present?
Done?
Done? Click next to continue
Step 1 complete
One of these rainforests display the results from an environmental variable you and your group
members chose to analyze for a report. Your challenge is to eliminate the rainforests that most
likely did NOT result from your variable.
Gather your group members and go to .
When you have all arrived, perform a QR scan.
Rainforest QR code scanning failed!
Scanning the QR code of the rainforest failed. Please try again or proceed by pressing the button for the rainforest you are at.
Location:
Instructions: Your assignment at this location is to be the note-taker. Discuss the
following questions with your group members and record your answers below.
Could this be your rainforest?
Give a brief explanation for your answer.
Location:
Instructions: Your assignment at this location is to look up information in your field guide.
Follow the link below to go to the field guide site.

Follow the link below to go to your group's page.
 Follow the links below to
access the information. If another group member is also assigned to look up information, one person should look up the Field Guide, and
the other should look up your Group's Page.

When you have all arrived, perform a QR scan.
Step 2 complete
Your next task is to locate these researchers (see below) and find out more information about THEIR rainforests.
After all, how will you know which rainforest is yours if you don't know how the other rainforests came to be?
Maybe you can offer your expertise to help them find their rainforests as well. When you are ready, click on
their names to begin.
TEMP 1st interviewee
TEMP 2nd interviewee
Suggested questions:
1. What is your variable?
2. What speciality are you?
3. Which rainforest do you think is related to your variable? Why?
4. How confident are you and your group members?
5. ...
Interview with
What is your group's variable?
Notes
Researcher
Variable
Notes
Step 3 complete
Discuss amongst group members and rank the rainforests from no. 1 to 4, with no. 1 as the environment
that most likely result from YOUR variable. When you are ready, record your choices.
Step 4: Rank rainforests
Rainforests
Rank
Rainforest A
Rainforest B
Rainforest C
Rainforest D
Done? Click next to continue.
Step 4: In progress
Instructions: Discuss the following question with your group members and provide your answer below.
What is your strategy in ranking the rainforests? Describe your process.
Identify at least 3 key pieces of evidence in making your choices.
Identify key insights from your discussion with the other groups members that helped you make your final rankings.

Rainforest QR code scanning failed!
Scanning the QR code of the rainforest failed. Please try again or proceed by pressing the button for the rainforest you are at.


class: center, middle, inverse, title-slide # Central Limit Theorem --- ## Announcements - Midterm assigned on Monday, due Friday at noon - Mostly modeling + inference - But also some exploratory data analysis - Project proposal due tomorrow -- any questions? --- ## .question[ What is the significance of the year 2020 in the US? And why am I asking this question today? ] -- ![](img/10b/ap-census-tweet.png) --- class: center, middle # Sample Statistics and Sampling Distributions --- ## Notation - Means: - Population: mean = `\(\mu\)`, standard deviation = `\(\sigma\)` - Sample: mean = `\(\bar{x}\)`, standard deviation = `\(s\)` - Proportions: - Population: `\(p\)` - Sample: `\(\hat{p}\)`
 - Standard error: `\(SE\)` --- ## Variability of sample statistics - Each sample from the population yields a slightly different sample statistic (sample mean, sample proportion, etc.) - The variability of these sample statistics is measured by the **standard error** - Previously we quantified this value via simulation - Today we talk about the theory underlying **sampling distributions** --- ## Sampling distribution - **Sampling distribution** is the distribution of sample statistics of random samples of size `\(n\)` taken with replacement from a population - In practice it is impossible to construct sampling distributions since it would require having access to the entire population - Today for demonstration purposes we will assume we have access to the population data, and construct sampling distributions, and examine their shapes, centers, and spreads .question[ What is the difference between the sampling and bootstrap distribution? ] --- ## The sampling distribution .question[ We have a population that is normally distributed with mean 20 and standard deviation 3. Suppose we take samples of size 50 from this distribution, and plot their sample means. What shape, center, and spread will this distribution have? ] --- ## The population ```r set.seed(20180328) norm_pop <- tibble(x = rnorm(n = 100000, mean = 20, sd = 3)) ggplot(data = norm_pop, aes(x = x)) + geom_histogram(binwidth = 1) + labs(title = "Population distribution") ``` ![](u2_d10-clt_files/figure-html/unnamed-chunk-1-1.png) --- ## Sampling from the population - 1 ```r samp_1 <- norm_pop %>% sample_n(size = 50, replace = TRUE) ``` -- ```r samp_1 %>% summarise(x_bar = mean(x)) ``` ``` ## # A tibble: 1 x 1 ## x_bar ## <dbl> ## 1 19.3 ``` --- ## Sampling from the population - 2 ```r samp_2 <- norm_pop %>% sample_n(size = 50, replace = TRUE) ``` -- ```r samp_2 %>% summarise(x_bar = mean(x)) ``` ``` ## # A tibble: 1 x 1 ## x_bar ## <dbl> ## 1 20.4 ``` --- ## Sampling from the population - 3 ```r samp_3 <- norm_pop %>% sample_n(size = 50, replace = TRUE) ``` -- ```r samp_3 %>% summarise(x_bar = mean(x)) ``` ``` ## # A tibble: 1 x 1 ## x_bar ## <dbl> ## 1 20.3 ``` -- ... --- ## Sampling distribution ```r sampling <- norm_pop %>% rep_sample_n(size = 50, replace = TRUE, reps = 1000) %>% group_by(replicate) %>% summarise(xbar = mean(x)) ``` ``` ## `summarise()` ungrouping output (override with `.groups` argument) ``` ```r sampling ``` ``` ## # A tibble: 1,000 x 2 ## replicate xbar ## <int> <dbl> ## 1 1 20.4 ## 2 2 20.3 ## 3 3 19.7 ## 4 4 20.4 ## 5 5 20.2 ## 6 6 19.3 ## 7 7 19.4 ## 8 8 19.9 ## 9 9 19.7 ## 10 10 20.2 ## # ... with 990 more rows ``` --- ## Population vs. sampling ![](u2_d10-clt_files/figure-html/unnamed-chunk-9-1.png) --- .question[ How do the shapes, centers, and spreads of these distributions compare? ] ``` ## Warning: Removed 2 rows containing missing values (geom_bar). ## Warning: Removed 2 rows containing missing values (geom_bar). ``` ![](u2_d10-clt_files/figure-html/unnamed-chunk-10-1.png) --- .question[ How do the centers and spreads of these distributions compare? ] ```r norm_pop %>% summarise(mu = mean(x), sigma = sd(x)) ``` ``` ## # A tibble: 1 x 2 ## mu sigma ## <dbl> <dbl> ## 1 20.0 3.00 ``` ```r sampling %>% summarise(mean = mean(xbar), se = sd(xbar)) ``` ``` ## # A tibble: 1 x 2 ## mean se ## <dbl> <dbl> ## 1 20.0 0.426 ``` --- ## Simulating another sampling distribution ```r rs_pop <- tibble(x = rbeta(100000, 1, 5) * 100) ``` ![](u2_d10-clt_files/figure-html/unnamed-chunk-14-1.png) ``` ## # A tibble: 1 x 2 ## mu sigma ## <dbl> <dbl> ## 1 16.7 14.1 ``` --- ## Sampling distribution ```r sampling <- rs_pop %>% rep_sample_n(size = 50, replace = TRUE, reps = 1000) %>% group_by(replicate) %>% summarise(xbar = mean(x)) ``` ``` ## `summarise()` ungrouping output (override with `.groups` argument) ``` ![](u2_d10-clt_files/figure-html/unnamed-chunk-17-1.png) ``` ## # A tibble: 1 x 2 ## mean se ## <dbl> <dbl> ## 1 16.6 2.01 ``` --- .question[ How do the shapes, centers, and spreads of these distributions compare? ] ``` ## Warning: Removed 2 rows containing missing values (geom_bar). ## Warning: Removed 2 rows containing missing values (geom_bar). ``` ![](u2_d10-clt_files/figure-html/unnamed-chunk-19-1.png) --- ## Recap - Regardless of the shape of the population distribution, the sampling distribution follows a normal distribution. - The center of the sampling distribution is at the center of the population distribution. - The sampling distribution is less variable than the population distribution. -- .question[ What was the one (very unrealistic) assumption we had in simulating these sampling distributions? ] --- class: center, middle # Central Limit Theorem --- ## In practice... We can't directly know what the sampling distributions looks like, because we only draw a single sample. - The whole point of statistical inference is to deal with this issue: observe only one sample, try to make inference about the entire population - We have already seen that there are simulation based methods that help us estimate the sampling distribution - Additionally, there are theoretical results (**Central Limit Theorem**) that tell us what the sampling distribution should look like (for certain sample statistics) --- ## Central Limit Theorem If certain conditions are met (more on this in a bit), the sampling distribution of the sample statistic will be nearly normally distributed with mean equal to the population parameter and standard error proportional to the inverse of the square root of the sample size. - **Single mean:** `\(\bar{x} \sim N\left(mean = \mu, sd = \frac{\sigma}{\sqrt{n}}\right)\)` - **Difference between two means:** `\((\bar{x}_1 - \bar{x}_2) \sim N\left(mean = (\mu_1 - \mu_2), sd = \sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}} \right)\)` - **Single proportion:** `\(\hat{p} \sim N\left(mean = p, sd = \sqrt{\frac{p (1-p)}{n}} \right)\)` - **Difference between two proportions:** `\((\hat{p}_1 - \hat{p}_2) \sim N\left(mean = (p_1 - p_2), sd = \sqrt{\frac{p_1 (1-p_1)}{n_1} + \frac{p_2(1-p_2)}{n_2}} \right)\)` --- ## Conditions: - **Independence:** The sampled observations must be independent. This is difficult to check, but the following are useful guidelines: - the sample must be random - if sampling without replacement, sample size must be less than 10% of the population size - **Sample size / distribution:** - numerical data: The more skewed the sample (and hence the population) distribution, the larger samples we need. Usually n > 30 is considered a large enough sample for population distributions that are not extremely skewed. - categorical data: At least 10 successes and 10 failures. - If comparing two populations, the groups must be independent of each other, and all conditions should be checked for both groups. --- ## Standard Error The standard error is the *standard deviation* of the *sampling distribution*, calculated using sample statistics (since we don't know the population parameters like `\(\sigma\)` or `\(p\)`). -- - **Single mean:** `\(SE = \frac{s}{\sqrt{n}}\)` - **Difference between two means:** `\(SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}\)` - **Single proportion:** `\(SE = \sqrt{\frac{\hat{p} (1-\hat{p})}{n}}\)` - **Difference between two proportions:** `\(SE = \sqrt{\frac{\hat{p}_1 (1-\hat{p}_1)}{n_1} + \frac{\hat{p}_2(1-\hat{p}_2)}{n_2}}\)` -- .question[ How are standard error and sample size associated? What does that say about how the spread of the sampling distribution changes as `\(n\)` increases? ] --- ## What is the normal distribution? Normal distribution - is unimodal and symmetric - follows the 68-95-99.7 rule ![](img/10b/6895997.png) --- .question[ Speeds of cars on a highway are normally distributed with mean 65 miles / hour. The minimum speed recorded is 48 miles / hour and the maximum speed recorded is 83 miles / hour. Which of the following is most likely to be the standard deviation of the distribution? ] (a) -5 (b) 5 (c) 10 (d) 15 (e) 30 --- ## What is "unusual" under the normal distribution? Observations that are more than 2 standard deviations away from the mean are often considered unusual under the normal distribution. --- .question[ Suppose my iPod has 3,000 songs. The histogram below shows the distribution of the lengths of these songs. We also know that, for songs on this iPod, the mean length is 3.45 minutes and the standard deviation is 1.63 minutes. Calculate the probability that a randomly selected song lasts more than 5 minutes. ] ![](u2_d10-clt_files/figure-html/unnamed-chunk-20-1.png) --- .question[ I’m about to take a trip to visit friends and the drive is 6 hours. I make a random playlist of 100 songs. What is the probability that my playlist lasts the entire drive? Reminder: For songs on this iPod, the mean length is 3.45 minutes and the standard deviation is 1.63 minutes. ] Hints: - You know how to find the distribution of `\(\bar{x}\)` (average song length) - To find probabilities under the normal curve, use the `pnorm()` function. --- ## Recap -- why do we care? Knowing the distribution of the sample statistic can help us - estimate a population parameter as point estimate `\(\pm\)` margin of error, where the margin of error is comprised of a measure of how confident we want to be and how variable the sample statistic is - test for a population parameter by evaluating how likely it is to obtain to observed sample statistic when assuming that the null hypothesis is true as this probability will depend on how variable the sampling distribution is --- class: center, middle # Inference methods based on CLT --- ## What is the CLT? The Central Limit Theorem tells us the distribution of certain sample statistics if necessary conditions are met. - The distribution of the sample statistic is nearly normal - The distribution is centered at the (often unknown) population parameter - The variability of the distribution is inversely proportional to the square root of the sample size --- ## Inference methods based on CLT If necessary conditions are met, we can also use inference methods based on the CLT: -- - use the CLT to calculate the SE of the sample statistic of interest (sample mean, sample proportion, difference between sample means, etc.) -- - calculate the **test statistic**, number of standard errors away from the null value the observed sample statistic is - Z for proportions - T for means, along with appropriate degrees of freedom -- - use the test statistic to calculate the **p-value**, the probability of an observed or more extreme outcome given that the null hypothesis is true --- ## Z distribution .small[ Also called the **standard normal distribution**: `\(Z \sim N(mean = 0, \sigma = 1)\)` ] .small[ Finding probabilities under the normal curve: ```r pnorm(-1.96) ``` ``` ## [1] 0.0249979 ``` ```r pnorm(1.96, lower.tail = FALSE) ``` ``` ## [1] 0.0249979 ``` ] -- .small[ Finding cutoff values under the normal curve: ```r qnorm(0.025) ``` ``` ## [1] -1.959964 ``` ```r qnorm(0.975) ``` ``` ## [1] 1.959964 ``` ] --- ## T distribution - Also unimodal and symmetric, and centered at 0 - Thicker tails than the normal distribution (to make up for additional variability introduced by using `\(s\)` instead of `\(\sigma\)` in calculation of the SE) - Parameter: **degrees of freedom** - df for single mean: `\(df = n - 1\)` - df for comparing two means: `$$df \approx \frac{(s_1^2/n_1+s_2^2/n_2)^2}{(s_1^2/n_1)^2/(n_1-1)+(s_2^2/n_2)^2/(n_2-1)} \approx min(n_1 - 1, n_2 - 1)$$` --- ## T vs Z distributions ![](u2_d10-clt_files/figure-html/unnamed-chunk-23-1.png) --- ## T distribution .small[ Finding probabilities under the t curve: ```r pt(-1.96, df = 9) ``` ``` ## [1] 0.0408222 ``` ```r pt(1.96, df = 9, lower.tail = FALSE) ``` ``` ## [1] 0.0408222 ``` ] --
 .small[ Finding cutoff values under the t curve: ```r qt(0.025, df = 9) ``` ``` ## [1] -2.262157 ``` ```r qt(0.975, df = 9) ``` ``` ## [1] 2.262157 ``` ] --- class: center, middle # Example --- ## Relaxing after work .question[ The GSS asks "After an average work day, about how many hours do you have to relax or pursue activities that you enjoy?". Do these data provide convincing evidence that Americans, on average, spend more than 3 hours per day relaxing? Note that the variable of interest in the dataset is `hrsrelax`. ] ```r gss = read_csv("../../data/gss2010.csv") gss$hrsrelax <- as.factor(gss$hrsrelax) gss <- read_csv("https://raw.githubusercontent.com/matackett/sta210/master/data/gss2010.csv") gss = read.csv("https://stat.duke.edu/~mc301/data/gss2010.csv") summary(gss$hrsrelax) gss %>% filter(!is.na(hrsrelax)) %>% summarise(x_bar = mean(hrsrelax), med = median(hrsrelax), sd = sd(hrsrelax), n = n()) ``` --- ## Exploratory Data Analysis ```r ggplot(data = gss, aes(x = hrsrelax)) + geom_histogram(binwidth = 1) ``` --- ## Hypotheses .question[ What are the hypotheses for evaluation Americans, on average, spend more than 3 hours per day relaxing? ] -- `$$H_0: \mu = 3$$` `$$H_A: \mu > 3$$` --- ## Conditions .question[ What conditions must be satisfied to conduct this hypothesis test using methods based on the CLT? Are these conditions satisfied? ] --- ## Calculating the test statistic Summary stats from the sample: And the CLT says: `$$\bar{x} \sim N\left(mean = \mu, SE = \frac{\sigma}{\sqrt{n}}\right)$$` -- .question[ How many standard errors away from the population mean is the observed sample mean? ] -- .question[ How likely are we to observe a sample mean that is at least as extreme as the observed sample mean, if in fact the null hypothesis is true? ] --- ## Calculations ```r (se <- hrsrelax_summ$s / sqrt(hrsrelax_summ$n)) (t <- (hrsrelax_summ$xbar - 3) / se) (df <- hrsrelax_summ$n - 1) pt(t, df, lower.tail = FALSE) ``` --- ## Conclusion - Since the p-value is small, we reject `\(H_0\)`. - The data provide convincing evidence that Americans, on average, spend more than 3 hours per day relaxing after work. -- .question[ Would you expect a 90% confidence interval for the average number of hours Americans spend relaxing after work to include 3 hours? ] --- ## Confidence interval for a mean `$$point~estimate \pm critical~value \times SE$$` ```r t_star <- qt(0.95, df) pt_est <- hrsrelax_summ$xbar round(pt_est + c(-1,1) * t_star * se, 2) ``` .question[ Interpret this interval in context of the data. ] --- ## Built-in functionality in R - There are built in functions for doing some of these tests in R: - However a learning goal is this course is not to go through an exhaustive list of all CLT based tests and how to implement them - Instead you should try to understand how these methods are / are not like the simulation based methods we learned about earlier .question[ What is similar, and what is different, between CLT based test of means vs. simulation based test? ] --- .small[ ```r # HT t.test(gss$hrsrelax, mu = 3, alternative = "greater") # CI t.test(gss$hrsrelax, conf.level = 0.90)$conf.int ``` ]


-
National Merit Finalist
Feb 2016
Selected as a finalist for the National Merit Scholarship Corporation.
-
US Presidential Scholarship Candidate
Jan 2016
Nominated as a candidate for the United States Presidential Scholarship Program.
-
Cyber Security Awareness Games High School Forensics Challenge - Top 12 out of 800 teams
October 2015
Participated in CSAW HSF challenge among 800 high school teams from across the US and Abu Dhabi, placing in the top 12 teams and becoming a finalist, invited to NYU Polytechnic School of Engineering, guaranteed at least $28k in scholarships.
-
Johns Hopkins University Engineering Innovation Program
June 2015 (4 weeks)
Rigorous residential academic program introducing each engineering discipline, including tests, research papers and a final bridge building project and exam. Passed the course to earn 3 JHU college credits.
-
Elected Vice President of Science Honor Society
June 2015
Ran for and elected as VP of Science Honor Society, responsibilities including planning meetings and presentations, fundraising and finding scientific volunteer opportunities.
-
Math and Science Research at UMass Lowell
April 2015 - March 2016
Research involving prime pairs and raman spectroscopy/X-ray diffraction of rare earth oxides with Dr. Richard W. Stimets, Ph.D., MIT.
-
Science Olympiad - 3rd place Astronomy Event and 4th place Bridge Building
March 2015
3rd place in Astronomy written exam and 4th place in Bridge Building pre-build (had to buy materials and design/build a bridge beforehand to hold most weight with least mass)
-
HackExeter Competition - 1st place
February 2015
1st place in team Hackaton competition for eye-tracking program that can control one's computer.
-
NACLO - Computational Linguistics Club/Competition
January 2015 - June 2016
New school club to prepare for the North American Compuational Linguistics Olympiad, which is an individual written test on language puzzles, ciphers, and cryptography.
-
New England History Bowl - 1st place
November 2015
1st place in History Bowl regional competition, invitied to national competition in Washington D.C.
-
Honor Society Volunteering
November 2014 - June 2016
Volunteering opportunities from multiple honor societies - STEM night for kids, School Language Festival, Track Meet Monitor, tutoring, etc.
-
Engineering and Robotics Summer Program
July 2014 (2 weeks)
WPI Frontiers II intensive residential academic program where we are taught various topics in physics and engineering and apply mechanical engineering, electrical engineering, and computer programming skills to design a competitive robot. Our robot won first place.
-
Elected President of Science Olympiad team
June 2014
Ran for and won presidency of Science Olypiad team, prominent leadership role with minimum advisor involvement, including designing experiments and plans, assigning teams and events and planning trip to competition.
-
Inducted into National, Science, Math, Spanish and English Honor Societies
April 2014 - October 2015
Applied to and inducted into 4 honor societies, active member and volunteering.
-
Science Olympiad - 1st place Rocks and Minerals Event
April 2014
1st place at state Science Olympiad competition event - Rocks and Minerals written exam.
-
Patent Filed and Pending On Product Idea
March 2014
Filed for patent on product idea (AdCube) - Personalized television advertisement banners for small businesses based on user demographics and survey.
-
Panther Prints School Newspaper
February 2014 - June 2016
Jorunalist and Co-Editor for Panther Prints, our school newspaper, publishing global, national and school-related stories and information each week.
-
DECA State Competition - 1st place in Entrepreneurial Team Event and Business Administration Written Event
February 2014
1st place in Business Plan and Presentation Team Event and Business Administration and Management Individual Written Test, and invited to National competition in Orlando.
-
Informed Students of the World
December 2014 - January 2015
Non-profit organization to educate and inform students about current events and evoke interest in global, national and local affairs. Vice President of Marketing, responsible for Graphic Design, App Content Creation, Marketing and Advertising.
-
New England History Bowl - 2nd place
November 2013
2nd place in History Bowl regional competition, and invitied to national competition in Washington D.C.
-
Current Events Club
October 2013 - June 2016
School club created to inform students of all the interesting and important events occurring globally, nationally and locally, meeting each week to discuss what we think are the biggest topics.
-
Table Tennis Team
September 2013 - June 2015
Member of school's Table Tennis Team, where we meet to practice table tennis and compete amongst ourselves, preparing for a local table tennis competition. Elected vice president in 2014.
-
Entrepreneurs Club
September 2013 - June 2014
Co-founder and VP of school's first Entrepreneurs Club, where we teach students how to start and manage a business in terms of finances, marketing, etc., and conduct a business plan competition for students to use what we taught them to pitch to investors.
-
DECA Business Competition
September 2013 - February 2014
Participated in DECA competition, where I and two teammates prepared a comprehensive 25-page business plan and presentation to pitch a product idea at NH State Competition.
-
New England History Bowl Competition
September 2013 - June 2016
On school's History Bowl Team, where we practice and study history to participate in the regional New England competition each year.
-
Shishu Bharati School for Languages and Culture of India
October 2013 - June 2016
Volunteer at local non-profit school to teach kids about Indian culture and language, main library administrator and classroom assistant.
-
Introduction to Computer Aided Design
August 2013 (1 week)
WPI Launch program that introduces Computer Aided Design and modeling tools such as SolidWorks and Creo, as well as 3D printing.
-
Northeast DOE Science Bowl Regionals
August 2013 - June 2016
Part of DOE Science Bowl Team, where we prepare by practicing answering questions, testing reflexes, and studying intensely to participate in the regional competition at UConn each year.
-
Varsity Tennis
April 2013 - June 2016
On school's Varsity Tennis Team for 4 years, which includes daily practices and exercise and over a dozen matches with different schools. Currently in the Top 6 on our team.
-
The Young Entrepreneurs Business Competition - 3rd Place ($1000)
March 2013
Wrote extensive business plan and pitched product idea to venture capitalists, winning cash prize of $1000.
-
Math Tutoring (High School and Elementary Level)
March 2013 - June 2016
Tutoring at high school during free block and tutoring elementary school kids to prepare them for math education bees.
-
Science Olympiad
September 2012 - June 2016
Member of Science Olympiad team for 4 years, in which we spend the year preparing for a science competition between many NH schools, involving pre-builds, experiments, and exams.
-
Nashua Soup Kitchen
September 2012 - June 2016
Volunteering at local soup kitchen, preparing and serving food and cleaning up.
-
SMASH Math Team
September 2012 - June 2016
Member of mathematics team for 4 years, in which we travel across NH to attend monthly math meet competitions with other schools.
-
India Association of New Hampshire Youth Group
June 2012 - June 2016
Joined IANH Youth Group, group involved in community service activities and fundraising to give money towards Nashua Children's Home and Nashua Soup Kitchen
-
Secret Communication Summer Program
June 2012 (2 weeks)
Academic program dedicated to teaching different ciphers and methods of cryptoanalysis at Colby-Sawyer College.
-
NACLO - Computational Linguistics Club/Competition
January 2015 - June 2016
New school club to prepare for the North American Compuational Linguistics Olympiad, which is an individual written test on language puzzles, ciphers, and cryptography.
-
Panther Prints School Newspaper
February 2014 - June 2016
Jorunalist and Co-Editor for Panther Prints, our school newspaper, publishing global, national and school-related stories and information each week.
-
Current Events Club
October 2013 - June 2016
School club created to inform students of all the interesting and important events occurring globally, nationally and locally, meeting each week to discuss what we think are the biggest topics.
-
Table Tennis Team
September 2013 - June 2015
Member of school's Table Tennis Team, where we meet to practice table tennis and compete amongst ourselves, preparing for a local table tennis competition. Elected vice president in 2014.
-
DECA Business Competition
September 2013 - February 2014
Participated in DECA competition, where I and two teammates prepared a comprehensive 25-page business plan and presentation to pitch a product idea at NH State Competition.
-
Entrepreneurs Club
September 2013 - June 2014
Co-founder and VP of school's first Entrepreneurs Club, where we teach students how to start and manage a business in terms of finances, marketing, etc., and conduct a business plan competition for students to use what we taught them to pitch to investors.
-
New England History Bowl Competition
September 2013 - June 2016
On school's History Bowl Team, where we practice and study history to participate in the regional New England competition each year.
-
Northeast DOE Science Bowl Regionals
August 2013 - June 2016
Part of DOE Science Bowl Team, where we prepare by practicing answering questions, testing reflexes, and studying intensely to participate in the regional competition at UConn each year.
-
Varsity Tennis
April 2013 - June 2016
On school's Varsity Tennis Team for 4 years, which includes daily practices and exercise and over a dozen matches with different schools. Currently in the Top 6 on our team.
-
Science Olympiad
September 2012 - June 2016
Member of Science Olympiad team for 4 years, in which we spend the year preparing for a science competition between many NH schools, involving pre-builds, experiments, and exams.
-
SMASH Math Team
September 2012 - June 2016
Member of mathematics team for 4 years, in which we travel across NH to attend monthly math meet competitions with other schools.


Kyuhyun selected to go to this remote location on 'Journey to the New West' + hilarity ensues
by sl278'Journey to the New West' often ensues in hilarity as the PD sends members to far off locations as a part of 'rewards' that also double as punishments.
In the latest episode broadcast on November 15 showed Kyuhyun picking a prize randomly after winning a challenge alongside team members Lee Soo Geun and Eun Ji Won. The star hilariously picked a stay at a giraffe hotel in Kenya, leading to laughter from the staff as Lee Soo Geun and Eun Ji Won, who had previously gone to Iceland, saw that they would also have to go to Kenya with Kyuhyun.
Are you looking forward to seeing the three cast members hang out with giraffes in Kenya?


IDL source Global index
Set of Interfaces including the Report Concept. This concept is a CAPE-OPEN common service. Its specification is not provided, please refer to the CAPE-OPEN Concepts Document.


Working with multiple browsers
Some web tests need to exercise two different browsers simultaneously. Workflow applications are a good example of this scenario: imagine for example a scenario where one user (say, a salesperson) raises an expense and another user (his or her manager) needs to approve this expense in a different session.
Do you need to use multiple browsers?
Before you go down this path, there are often ways to avoid the use of two browsers in such scenarios. For example, suppose you need to automate the following scenario:
Scenario: Expenses over $1000 need to be reviewed by a manager
Joe and Jane a sales people and Mark is their manager
Given Joe has raised an expenses claim for $1200
And Jane has raised an expenses claim for $900
When he submits his claim for processing
Then Mark should see the following expense claims in his inbox:
| Employee | Claim |
| Joe | $1200 |
In this scenario, three actors are involved: Joe, Jane and Mark. You could test this using three browsers, one for each user. Or, knowing that the expense claim UI is tested elsewhere, you could invoke a web service to inject the claims directly into the system, and use a single web test for Mark, when he views his inbox. Or you could dispense with web testing entirely, and use another web service to query Mark’s inbox. There are often many ways to test a scenario.
When you really do need to use multiple browsers
Nevertheless, there are cases where you really do need multiple browsers in the same test. Suppose you have the following (rather silly) test case:
Scenario: Users are stubborn about their browser choice
Given Joe likes firefox
And Jane prefers chrome
When Joe looks for foxes
And Jane looks for fenders
Then Joe should see mammals
And Jane should see shiny stuff
The interesting thing here is that we have two actors, each using a different browser. How could you implement this test in Serenity?
Using Screenplay
Multiple browsers are easy to manage in Screenplay. In this case, you could just declare two browsers, and assign each of them to a different user, like this:
public class StepDefinitions {
@Managed(driver = "firefox")
WebDriver firefox;
@Managed(driver = "chrome")
WebDriver chrome;
Actor joe = Actor.named("Joe");
Actor jane = Actor.named("Jane");
@Given("^Joe (?:likes|prefers) firefox$")
public void joeLikesFirefox() throws Throwable {
joe.can(BrowseTheWeb.with(firefox));
}
@And("^Jane (?:likes|prefers) chrome$")
public void janeLikeChrome() throws Throwable {
jane.can(BrowseTheWeb.with(chrome));
}
...
Then Joe and Jane will use Firefox and Chrome respectively for their subsequent web interactions.
One nice thing about this approach is that, once the driver is assigned to an actor, any UI interaction will use that driver, no matter what order the calls are made. So the following code will use Chrome or Firefox, depending on whether the actor in question is Jane or Joe:
actor.attemptsTo(Open.url("https://www.google.co.uk"));
actor.attemptsTo(
Enter.theValue(search).into(By.name("q"))
.thenHit(Keys.ENTER)
);
Using @Managed drivers
The @Managed field can be used to declare drivers of specific types, in both JUnit tests and Cucumber step definitions. The driver you declare in this annotation will override any drivers declared in the serenity.properties
file, and you can use the option
attribute to pass in Chrome options, as shown here:
@Managed(driver = "chrome", options = "--headless")
WebDriver chrome;
Obtaining drivers dynamically
Sometimes you need a solution more dynamic than defining the drivers ahead of time with the @Managed
annotation. In this case, you can use the Serenity ThucydidesWebDriverSupport
class to allocate a dynamically driver by name.
For example, suppose you have the following Gherkin statement, where the browser name may vary:
Given Joe likes to browse with firefox
Probably the best way to make both the actor (Joe) and the browser (firefox) dynamic is to use the OnlineCast
class. The OnlineCast
class represents the cast of actors we can call on to perform our web-based tests.
In practice, we can do this by creating an OnlineCast
object and use it to create actors who can browse the web with a browser of a specified type. You can see an example of this in the following listing:
OnlineCast theCast = new OnlineCast(); (1)
@Before
public void setTheStage() {
OnStage.setTheStage(theCast); (2)
}
@Given("^(.*) likes to browse with (.*)")
public void joeBrowsesTheWebWith(String actorName, String driverType) throws Throwable {
Actor actor = theCast.actorUsingBrowser(driverType).named(actorName); (3)
actor.attemptsTo(Open.url("https://www.google.co.uk"));
}
(1) Create a new cast
(2) Set the cast so that we can refer to actors later on using theActorCalled()
and theActorInTheSpotlight()
(3) Retrieve an actor using a given browser with a given name
Obtaining drivers from the WebDriverManager
Another alternative is to retrieve the WebDriver
instance from the Serenity WebDriverManager
class. This class keeps track of all the open drivers, and you can retrieve a driver either by it’s type (e.g. "firefox"), or in conjunction with a unique name. If you provide the unique name, you can have several browsers of the same type simultaneously in the same test.
For example, the following code retrieves a Firefox instance associated with "joe":
WebDriver driver = ThucydidesWebDriverSupport.getWebdriverManager()
.getWebdriverByName("joe", "firefox");
This method can be called from anywhere in the test suite.
Using multiple browsers with Screenplay and legacy Page Object classes
Sometimes you need to use multiple browsers with test code that uses non-Screenplay page objects. You can do this quite easily, by extracting the WebDriver from the actor. For example, suppose you have a page that opens the Google home page:
@DefaultUrl("https://www.google.co.uk")
public static class GooglePage extends PageObject {
public GooglePage(WebDriver driver) {
super(driver);
}
...
}
A simple way to access this class is to wrap it in a Task
class, like the one shown below:
public static class OpenGoogle implements Task {
@Override
public <T extends Actor> void performAs(T actor) {
GooglePage page = new GooglePage(BrowseTheWeb.as(actor).getDriver());
page.open();
}
public static OpenGoogle homePage() {
return instrumented(OpenGoogle.class);
}
}
A Screenplay actor can then open this page, with the corresponding driver instance, like this:
actor.attemptsTo(OpenGoogle.homePage());
Using the @Managed annotation for Remote drivers
Selenium Grid, as well as services like BrowserLabs and SauceSafe, offer a convenient way to scale your web tests by running them on batteries of remote machines. In Serenity, you can run your tests on a remote server simply by specifying the webdriver.remote.url
property in your serenity.properties
file or on the command line:
webdriver.remote.url=http://localhost:4444/wd/hub
You can also use the saucelabs.url
or browserstack.url
properties to work with one of these services.
As soon as you set a remote url, Serenity will use a Remote driver. However Serenity will still respect your choice of browsers on the remote server. For example, suppose you run a test with the following @Managed driver:
@Managed(driver = "chrome", options = "--headless")
WebDriver driver;
If you use a remote url, a Chrome driver will be used on the remote server.


--- layout: post title: Deprecated CTA - List of Fare Media Sales Outlets dataset and corresponding map date: '2014-08-15T17:48:54-05:00' author: Open Data Portal Team categories: - Open Data - Data Portal tags: - ag7u-gr9m - pa8e-mhbh - deprecation ---
We have deprecated the CTA - List of Fare Media Sales Outlets dataset and the CTA - Map of Fare Media Sales Outlets map, based on it, because they are no longer valid. The retail sales program for fare media changed with the introduction of Ventra cards and the current locations are not yet available in dataset format.


DECLARE
Defines a new cursor. Use a cursor to retrieve a few rows at a time from the result set of a larger query.
When the first row of a cursor is fetched, the entire result set is materialized on the leader node, in memory or on disk, if needed. Because of the potential negative performance impact of using cursors with large result sets, we recommend using alternative approaches whenever possible. For more information, see Performance Considerations When Using Cursors.
You must declare a cursor within a transaction block. Only one cursor at a time can be open per session.
For more information, see FETCH, CLOSE.
Syntax
DECLARE cursor_name CURSOR FOR query
Parameters
- cursor_name
-
Name of the new cursor.
- query
-
A SELECT statement that populates the cursor.
DECLARE CURSOR Usage Notes
If your client application uses an ODBC connection and your query creates a result set that is too large to fit in memory, you can stream the result set to your client application by using a cursor. When you use a cursor, the entire result set is materialized on the leader node, and then your client can fetch the results incrementally.
Note
To enable cursors in ODBC for Microsoft Windows, enable the Use Declare/Fetch option in the ODBC DSN you use for Amazon Redshift. We recommend setting the ODBC cache size, using the Cache Size field in the ODBC DSN options dialog, to 4,000 or greater on multi-node clusters to minimize round trips. On a single-node cluster, set Cache Size to 1,000.
Because of the potential negative performance impact of using cursors, we recommend using alternative approaches whenever possible. For more information, see Performance Considerations When Using Cursors.
Amazon Redshift cursors are supported with the following limitations:
-
Only one cursor at a time can be open per session.
-
Cursors must be used within a transaction (BEGIN … END).
-
The maximum cumulative result set size for all cursors is constrained based on the cluster node type. If you need larger result sets, you can resize to an XL or 8XL node configuration.
For more information, see Cursor Constraints.
Cursor Constraints
When the first row of a cursor is fetched, the entire result set is materialized on the leader node. If the result set does not fit in memory, it is written to disk as needed. To protect the integrity of the leader node, Amazon Redshift enforces constraints on the size of all cursor result sets, based on the cluster's node type.
The following table shows the maximum total result set size for each cluster node type. Maximum result set sizes are in megabytes.
| Node type | Maximum result set per cluster (MB) |
|---|---|
|
DS1 or DS2 XL single node |
64000 |
|
DS1 or DS2 XL multiple nodes |
1800000 |
|
DS1 or DS2 8XL multiple nodes |
14400000 |
|
DC1 Large single node |
16000 |
|
DC1 Large multiple nodes |
384000 |
|
DC1 8XL multiple nodes |
3000000 |
|
DC2 Large single node |
8000 |
|
DC2 Large multiple nodes |
192000 |
|
DC2 8XL multiple nodes |
3200000 |
To view the active cursor configuration for a cluster, query the STV_CURSOR_CONFIGURATION system table as a superuser. To view the state of active cursors, query the STV_ACTIVE_CURSORS system table. Only the rows for a user's own cursors are visible to the user, but a superuser can view all cursors.
Performance Considerations When Using Cursors
Because cursors materialize the entire result set on the leader node before beginning to return results to the client, using cursors with very large result sets can have a negative impact on performance. We strongly recommend against using cursors with very large result sets. In some cases, such as when your application uses an ODBC connection, cursors might be the only feasible solution. If possible, we recommend using these alternatives:
-
Use UNLOAD to export a large table. When you use UNLOAD, the compute nodes work in parallel to transfer the data directly to data files on Amazon Simple Storage Service. For more information, see Unloading Data.
-
Set the JDBC fetch size parameter in your client application. If you use a JDBC connection and you are encountering client-side out-of-memory errors, you can enable your client to retrieve result sets in smaller batches by setting the JDBC fetch size parameter. For more information, see Setting the JDBC Fetch Size Parameter.
DECLARE CURSOR Example
The following example declares a cursor named LOLLAPALOOZA to select sales information for the Lollapalooza event, and then fetches rows from the result set using the cursor:
-- Begin a transaction begin; -- Declare a cursor declare lollapalooza cursor for select eventname, starttime, pricepaid/qtysold as costperticket, qtysold from sales, event where sales.eventid = event.eventid and eventname='Lollapalooza'; -- Fetch the first 5 rows in the cursor lollapalooza: fetch forward 5 from lollapalooza; eventname | starttime | costperticket | qtysold --------------+---------------------+---------------+--------- Lollapalooza | 2008-05-01 19:00:00 | 92.00000000 | 3 Lollapalooza | 2008-11-15 15:00:00 |<PHONE_NUMBER>0 | 2 Lollapalooza | 2008-04-17 15:00:00 |<PHONE_NUMBER>0 | 3 Lollapalooza | 2008-04-17 15:00:00 |<PHONE_NUMBER>0 | 4 Lollapalooza | 2008-04-17 15:00:00 |<PHONE_NUMBER>0 | 1 (5 rows) -- Fetch the next row: fetch next from lollapalooza; eventname | starttime | costperticket | qtysold --------------+---------------------+---------------+--------- Lollapalooza | 2008-10-06 14:00:00 |<PHONE_NUMBER>0 | 2 -- Close the cursor and end the transaction: close lollapalooza; commit;


FreeType Fonts and Rendering — Functions for shape engines to manipulate FreeType fonts
The macros and functions in this section are used to access fonts and render text to bitmaps using the FreeType 2 library.
PangoFontMap *
pango_ft2_font_map_new (void
);
Create a new PangoFT2FontMap object; a fontmap is used
to cache information about available fonts, and holds
certain global parameters such as the resolution and
the default substitute function (see
pango_ft2_font_map_set_default_substitute()
).
the newly created fontmap object. Unref
with g_object_unref()
when you are finished with it.
Since: 1.2
void pango_ft2_font_map_set_resolution (PangoFT2FontMap *fontmap
,double dpi_x
,double dpi_y
);
Sets the horizontal and vertical resolutions for the fontmap.
Since: 1.2
PangoContext *
pango_ft2_font_map_create_context (PangoFT2FontMap *fontmap
);
pango_ft2_font_map_create_context
has been deprecated since version 1.22 and should not be used in newly-written code.
Use pango_font_map_create_context()
instead.
Create a PangoContext for the given fontmap.
[skip]
Since: 1.2
void (*PangoFT2SubstituteFunc) (FcPattern *pattern
,gpointer data
);
Function type for doing final config tweaking on prepared FcPatterns.
void pango_ft2_font_map_set_default_substitute (PangoFT2FontMap *fontmap
,PangoFT2SubstituteFunc func
,gpointer data
,GDestroyNotify notify
);
Sets a function that will be called to do final configuration substitution on a FcPattern before it is used to load the font. This function can be used to do things like set hinting and antialiasing options.
fontmap |
||
func |
function to call to to do final config tweaking on FcPattern objects. |
|
data |
data to pass to |
|
notify |
function to call when |
Since: 1.2
void
pango_ft2_font_map_substitute_changed (PangoFT2FontMap *fontmap
);
Call this function any time the results of the
default substitution function set with
pango_ft2_font_map_set_default_substitute()
change.
That is, if your substitution function will return different
results for the same input pattern, you must call this function.
Since: 1.2
PangoContext * pango_ft2_get_context (double dpi_x
,double dpi_y
);
pango_ft2_get_context
has been deprecated since version 1.22 and should not be used in newly-written code.
Use pango_font_map_create_context()
instead.
Retrieves a PangoContext for the default PangoFT2 fontmap
(see pango_ft2_font_map_for_display()
) and sets the resolution
for the default fontmap to dpi_x
by dpi_y
.
[skip]
void pango_ft2_render (FT_Bitmap *bitmap
,PangoFont *font
,PangoGlyphString *glyphs
,gint x
,gint y
);
Renders a PangoGlyphString onto a FreeType2 bitmap.
void pango_ft2_render_transformed (FT_Bitmap *bitmap
,const PangoMatrix *matrix
,PangoFont *font
,PangoGlyphString *glyphs
,int x
,int y
);
Renders a PangoGlyphString onto a FreeType2 bitmap, possibly
transforming the layed-out coordinates through a transformation
matrix. Note that the transformation matrix for font
is not
changed, so to produce correct rendering results, the font
must have been loaded using a PangoContext with an identical
transformation matrix to that passed in to this function.
bitmap |
the FreeType2 bitmap onto which to draw the string |
|
font |
the font in which to draw the string |
|
matrix |
a PangoMatrix, or |
[nullable] |
glyphs |
the glyph string to draw |
|
x |
the x position of the start of the string (in Pango units in user space coordinates) |
|
y |
the y position of the baseline (in Pango units in user space coordinates) |
Since: 1.6
void pango_ft2_render_layout_line (FT_Bitmap *bitmap
,PangoLayoutLine *line
,int x
,int y
);
Render a PangoLayoutLine onto a FreeType2 bitmap
void pango_ft2_render_layout_line_subpixel (FT_Bitmap *bitmap
,PangoLayoutLine *line
,int x
,int y
);
Render a PangoLayoutLine onto a FreeType2 bitmap, with he location specified in fixed-point Pango units rather than pixels. (Using this will avoid extra inaccuracies from rounding to integer pixels multiple times, even if the final glyph positions are integers.)
bitmap |
a FT_Bitmap to render the line onto |
|
line |
||
x |
the x position of start of string (in Pango units) |
|
y |
the y position of baseline (in Pango units) |
Since: 1.6
void pango_ft2_render_layout (FT_Bitmap *bitmap
,PangoLayout *layout
,int x
,int y
);
Render a PangoLayout onto a FreeType2 bitmap
void pango_ft2_render_layout_subpixel (FT_Bitmap *bitmap
,PangoLayout *layout
,int x
,int y
);
Render a PangoLayout onto a FreeType2 bitmap, with he location specified in fixed-point Pango units rather than pixels. (Using this will avoid extra inaccuracies from rounding to integer pixels multiple times, even if the final glyph positions are integers.)
bitmap |
a FT_Bitmap to render the layout onto |
|
layout |
||
x |
the X position of the left of the layout (in Pango units) |
|
y |
the Y position of the top of the layout (in Pango units) |
Since: 1.6
PangoGlyph
pango_ft2_get_unknown_glyph (PangoFont *font
);
pango_ft2_get_unknown_glyph
is deprecated and should not be used in newly-written code.
Return the index of a glyph suitable for drawing unknown characters with
font
, or PANGO_GLYPH_EMPTY
if no suitable glyph found.
If you want to draw an unknown-box for a character that is not covered
by the font,
use PANGO_GET_UNKNOWN_GLYPH()
instead.
int pango_ft2_font_get_kerning (PangoFont *font
,PangoGlyph left
,PangoGlyph right
);
pango_ft2_font_get_kerning
is deprecated and should not be used in newly-written code.
Retrieves kerning information for a combination of two glyphs.
Use pango_fc_font_kern_glyphs()
instead.
FT_Face
pango_ft2_font_get_face (PangoFont *font
);
pango_ft2_font_get_face
is deprecated and should not be used in newly-written code.
Returns the native FreeType2 FT_Face structure used for this PangoFont. This may be useful if you want to use FreeType2 functions directly.

PangoCoverage * pango_ft2_font_get_coverage (PangoFont *font
,PangoLanguage *language
);
pango_ft2_font_get_coverage
is deprecated and should not be used in newly-written code.
Gets the PangoCoverage for a PangoFT2Font. Use
pango_font_get_coverage()
instead.
PangoFontMap *
pango_ft2_font_map_for_display (void
);
pango_ft2_font_map_for_display
is deprecated and should not be used in newly-written code.
Returns a PangoFT2FontMap. This font map is cached and should
not be freed. If the font map is no longer needed, it can
be released with pango_ft2_shutdown_display()
. Use of the
global PangoFT2 fontmap is deprecated; use pango_ft2_font_map_new()
instead.
[skip]
void
pango_ft2_shutdown_display (void
);
pango_ft2_shutdown_display
is deprecated and should not be used in newly-written code.
Free the global fontmap. (See pango_ft2_font_map_for_display()
)
Use of the global PangoFT2 fontmap is deprecated.
typedef struct _PangoFT2FontMap PangoFT2FontMap;
The PangoFT2FontMap is the PangoFontMap implementation for FreeType fonts.
#define PANGO_RENDER_TYPE_FT2 "PangoRenderFT2"
PANGO_RENDER_TYPE_FT2
is deprecated and should not be used in newly-written code.
A string constant that was used to identify shape engines that work
with the FreeType backend. See PANGO_RENDER_TYPE_FC
for the replacement.