Affirmation and Stereotype Threat
Exploring your values
- When I think of the times in my life where I've been the happiest, the proudest, or the most satisfied, the following values and qualities come to mind
- Accomplishment, Achievement, Confidence, Enthusiasm, Excellence, Growth, Personal Development, Meaningful, Self-respect
- Most important value = 'Personal Development'
- At this stage of my life and career, it's important to continue to grow, learn, and have both career/personal development.
- Currently, I have a good and stable job that I am exceling at. However, I feel that I am not growing and not learning anything new and I feel that I am not challenged as I should and want to be.
- The main reason why I am taking Dev Bootcamp is that I want to learn how to code and feel that the ability to code will help me and further enhance my career, whether I build my own company or work for another company.
Rating Values in My Life
- Accomplishment - 4
- Achievement - 4
- Confidence - 3
- Enthusiasm - 5
- Excellence - 5
- Growth - 3
- Personal Development - 3
- Meaningful - 4
- Self-respect - 5
What was the last topic that someone asked for your advice on?
- The last topic that someone asked me for my advice on was around reviewing their new website. My friend is trying to start a new consulting company and wanted my advice on whether the content on the website promoted him well and helped him stay out from other consulting companies. He wanted my advice on how to better target his audience and show the values and differentiators that he wanted to easily convey from his website.
Values and Stereotype threat
- How do you feel when you think about your values?
- I constantly try to remind myself and live by these values. I judge myself on whether I am living to these values and if not, how I better myself and what can I do to live up to these values.
- Do you think it can help you mediate stereotype threat if you recognize you feel it?
- I am a pretty open person having lived in the Bay Area for most of my life and being a minority myself, I like to think that I am personally color blind and do not judge or sterotype
- Can you think of any other exercises you can use to help you when you are feeling down (for whatever reason) at DBC?
- None at this time, but I am sure that I can come up with ways to keep myself positive during DBC. By nature, I am a pretty positive person.


java.lang.Object java.lang.Enum<GamePad.Button> GamePad.Button
public static enum GamePad.Button
An enum of all of the different buttons most commonly supported.
| Enum Constant Summary | |
|---|---|
ACTION_DOWN
|
|
ACTION_LEFT
|
|
ACTION_RIGHT
|
|
ACTION_UP
|
|
L1
|
|
L2
|
|
L3
|
|
R1
|
|
R2
|
|
R3
|
|
SELECT
|
|
START
|
| Method Summary | |
|---|---|
static GamePad.Button |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
static GamePad.Button[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
| Methods inherited from class java.lang.Enum |
|---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Enum Constant Detail |
|---|
public static final GamePad.Button ACTION_DOWN
public static final GamePad.Button ACTION_LEFT
public static final GamePad.Button ACTION_RIGHT
public static final GamePad.Button ACTION_UP
public static final GamePad.Button L1
public static final GamePad.Button L2
public static final GamePad.Button L3
public static final GamePad.Button R1
public static final GamePad.Button R2
public static final GamePad.Button R3
public static final GamePad.Button SELECT
public static final GamePad.Button START
| Method Detail |
|---|
public static GamePad.Button valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic static GamePad.Button[] values()
for (GamePad.Button c : GamePad.Button.values()) System.out.println(c);


TRANSLATOR
Enter a sentance to translate
Pick a language to translate to:
Russian
German
French
Spanish
Your tranlation is:


Migrations are a type of version control for your database. They allow a team to modify the database schema and stay up to date on the current schema state. Migrations are typically paired with the Schema Builder to easily manage your application's schema.

To create a migration, you may use the migrate:make
command on the Artisan CLI:
php artisan migrate:make create_users_table
The migration will be placed in your app/database/migrations
folder, and will contain a timestamp which allows the framework to determine the order of the migrations.
You may also specify a --path
option when creating the migration. The path should be relative to the root directory of your installation:
php artisan migrate:make foo --path=app/migrations
The --table
and --create
options may also be used to indicate the name of the table, and whether the migration will be creating a new table:
php artisan migrate:make add_votes_to_user_table --table=users
php artisan migrate:make create_users_table --create=users

php artisan migrate
php artisan migrate --path=app/foo/migrations
php artisan migrate --package=vendor/package
Note: If you receive a "class not found" error when running migrations, try running the
composer dump-autoload
command.
Some migration operations are destructive, meaning they may cause you to lose data. In order to protect you from running these commands against your production database, you will prompted for confirmation before these commands are executed. To force the commands to run without a prompt, use the --force
flag:
php artisan migrate --force

php artisan migrate:rollback
php artisan migrate:reset
php artisan migrate:refresh
php artisan migrate:refresh --seed

Laravel also includes a simple way to seed your database with test data using seed classes. All seed classes are stored in app/database/seeds
. Seed classes may have any name you wish, but probably should follow some sensible convention, such as UserTableSeeder
, etc. By default, a DatabaseSeeder
class is defined for you. From this class, you may use the call
method to run other seed classes, allowing you to control the seeding order.
class DatabaseSeeder extends Seeder {
public function run()
{
$this->call('UserTableSeeder');
$this->command->info('User table seeded!');
}
}
class UserTableSeeder extends Seeder {
public function run()
{
DB::table('users')->delete();
User::create(array('email' => 'foo@bar.com'));
}
}
To seed your database, you may use the db:seed
command on the Artisan CLI:
php artisan db:seed
By default, the db:seed
command runs the DatabaseSeeder
class, which may be used to call other seed classes. However, you may use the --class
option to specify a specific seeder class to run individually:
php artisan db:seed --class=UserTableSeeder
You may also seed your database using the migrate:refresh
command, which will also rollback and re-run all of your migrations:
php artisan migrate:refresh --seed


SHUTTERS
Lifestyle Enhancements
- Great light control
- Reduction of noise from the outside
- Insulation to help retain heat
- Privacy when you adjust the louvres
- Provide a touch of elegant, style to your windows whether you are inside looking out or outside looking in
Shutters are a stylish and versatile option as they are available in a range of colours and can be made to fit any shape or size window or door. Shutters are a major purchase, however they are a great investment and add value and curb appeal to your property.
Whether you prefer a modern contemporary or a traditional look, we have the solution and expert advice to help you make the right choices
Full Height
A full height shutter covers the whole window from top to bottom. Full height shutters can be supplied with different louvres opening options, for example the bottom part of the shutters closed, whilst the top part of the shutter remains open. This has the added benefit of controlling privacy whilst allowing natural light into the room.
Cafe Style
Café shutters are custom made to cover part of the window which gives a continental look and feel. The Benefit of these shutters is allowing privacy at the bottom of the window whilst allowing full light to come into the room at the top of the window.
Tier on Tier
Tier on tier shutters are custom made to have two sets of panels, one on top of the other that open and operate independently of each other.
Solid
Shutters that are a solid wood panel and completely cover the window and block out the outside view
Shaped
Bespoke panels that are custom made to fit shaped and awkward windows. This type of shutter is brilliant for making the most of original architecture in your property.
Tracked
Tracked shutters slide on a track in front of large windows or doors, giving easy access. They can be pulled right back to let the light stream in.
BLINDS
Venetian
The simple and contemporary Venetian Blind perfectly blends style with practicality. Venetian blinds can be provided in a range of finishes, including real wood, faux wood and aluminium with a range of different size slats and colours
Pleated
Pleated blinds have a number of advantages that make them a good choice for window coverings. These blinds come in a wide range of contemporary fabrics including specialist performance fabric options that can control heat and offer a wide range of benefits making them a good choice for south-facing conservatories. These blinds are available in free hang, roof blinds and perfect fit with top-down/bottom-up opening options.
We can also supply pleated roof blinds that are motorised which are operated with a remote control.
Perfect Fit
Perfect fit blinds are made to measure blinds and are ideal for UPVC windows, doors and conservatories. These blinds require no drilling as they clip into the window frame. Perfect fit blinds can be supplied in pleated fabrics, cellular fabrics or aluminium venetian slats each with their own properties.
Roman
If you are looking for an alternative to curtains but still want an air of luxury, the Roman blind is an ideal solution. The roman blind provides a clean finish and can be chain or motor operated. With various fabric options and designs and added black out options, these fabric blinds add an air of luxury to any window.
Vertical Blinds
The traditional elegance and functionality of a vertical blind makes it the perfect option for your living room, conservatory or home office.
Roller Blinds
Roller blinds come in various different fabric ranges, whether you require the standard roller, a roller with a cassette (hiding the roller mechanism) a standard chain operation, a spring loaded roller blind with cordless controls (i.e. no chain) or a remote controlled battery operated option there is sure to be something to meet your requirements. Roller blinds can be supplied in many different colours and designs to match into your existing room décor, or something more neutral to add a classic look to your window.
Conservatory blinds
Window and roof blinds added to a conservatory allows more control over the light and privacy. Depending on your chosen option, you can choose a neutral design or one of the many coloured or patterned options to add character and a feature to your windows and ceiling. All conservatory blinds are individually measured for a perfect fitting solution.
Childrens
Children’s blinds are in the main supplied in either a roller blind or a roman blind with the added benefit of black-out option. There are a wide range of styles and design to choose from to suit your preference.
RECENT WORK
Full Height Shutters
Shaped Shutters
Full Height Shutters
Skylight Blinds
Shaped Shutter
Perfect Fit Venetian
Full Height Shutters
Full Height Shutters
Full Height Shutters
Full Height Shutters
MAINTENANCE & REPAIRS
We provide a range of fit only options and provide a repair service for existing blinds (subject to survey and age of existing blinds).
Please ask for further details about our additional services


News
Contact
About
Shop
News
Contact
About
Shop
Shop
Coming Soon...
Price: $69.00
You get a cool thingy and a cool GitHub and stuff.
GET GEAR ⇨
Price: $50.00
You get a cool thingy and a cool GitHub and stuff.
GET GEAR ⇨
Price: $50.00
You get a cool thingy and a cool GitHub and stuff.
GET GEAR ⇨
© Hypercharged 2017


---
layout: post
title: 'Choose Your Own Adventure: JRuby Compatibility'
date: '2008-11-03T13:56:00.000-08:00'
author: headius
tags:
modified_time: '2011-01-25T21:44:31.234-08:00'
blogger_id: tag:blogger.com,1999:blog-4704664917418794835.post-7062479149686297995
---
Warning: This blog post is not meant to be read straight through. Instead, you choose your own path by making decisions at various points during the story.
Book One: The Keystone
We live in a world of choices and compromises. For every path in life, there's an alternate path, an alternate road leading to an alternate future. So when


Experienced and motivated full stack software developer on existing and green field projects. Strong skills in all areas of software development from planning, requirements analysis, design, coding, unit testing and acceptance testing. Experience in software maintenance and support. A supportive team member in an Agile environment, with excellent communication skills, making independent decisions where required. Proven track record of delivering high quality software to tight deadlines. Driven to learn new technologies. Bilingual with native competence of both English and (European) Portuguese.
2.1


Gold price analysis: XAU/USD under pressure near four-month lows, trades below $1465/oz
by Flavio Tosti- Gold remains under pressure at the start of the week.
- Bears are likely eying the 1455/50 price zone.
Gold daily chart
Gold remains under bearish pressure near four-month lows below the 1465 resistance and the 50/100 SMAs.
Gold four-hour chart
The metal is weakening below the main SMAs. The sellers will likely try to extend the bear move towards the 1455/50 zone and potentially to the 1440 lebel on the way down. Resistance is seen at the 1465 and 1472 price levels.
Additional key levels
XAU/USD
| Overview | |
|---|---|
| Today last price | 1460.78 |
| Today Daily Change | 0.08 |
| Today Daily Change % | 0.01 |
| Today daily open | 1460.7 |
| Trends | |
|---|---|
| Daily SMA20 | 1465.22 |
| Daily SMA50 | 1481.73 |
| Daily SMA100 | 1487.3 |
| Daily SMA200 | 1405.02 |
| Levels | |
|---|---|
| Previous Daily High | 1477.1 |
| Previous Daily Low | 1458.88 |
| Previous Weekly High | 1484.06 |
| Previous Weekly Low | 1454.05 |
| Previous Monthly High | 1515.38 |
| Previous Monthly Low | 1445.8 |
| Daily Fibonacci 38.2% | 1465.84 |
| Daily Fibonacci 61.8% | 1470.14 |
| Daily Pivot Point S1 | 1454.02 |
| Daily Pivot Point S2 | 1447.35 |
| Daily Pivot Point S3 | 1435.81 |
| Daily Pivot Point R1 | 1472.24 |
| Daily Pivot Point R2 | 1483.78 |
| Daily Pivot Point R3 | 1490.45 |


dig [@server] [-b address] [-c class] [-f filename] [-k filename] [-p port#] [-t type] [-x addr] [-y name:key] [name] [type] [class] [queryopt...]
dig [-h]
dig [global-queryopt...] [query...]
dig (domain information groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. Most DNS administrators use dig to troubleshoot DNS problems because of its flexibility, ease of use and clarity of output. Other lookup tools tend to have less functionality than dig.
Although dig is normally used with command-line arguments, it also has a batch mode of operation for reading lookup requests from a file. A brief summary of its command-line arguments and options is printed when the -h option is given. Unlike earlier versions, the BIND9 implementation of dig allows multiple lookups to be issued from the command line.
Unless it is told to query a specific name server, dig will try each of the servers listed in /etc/resolv.conf.
When no command line arguments or options are given, will perform an NS query for "." (the root).
A typical invocation of dig looks like:
dig @server name typewhere:
is the name or IP address of the name server to query. This can be an IPv4 address in dotted-decimal notation or an IPv6 address in colon-delimited notation. When the supplied server argument is a hostname, dig resolves that name before querying that name server. If no server argument is provided, dig consults /etc/resolv.conf and queries the name servers listed there. The reply from the name server that responds is displayed.
is the name of the resource record that is to be looked up.
indicates what type of query is required — ANY, A, MX, SIG, etc. type can be any valid query type. If no type argument is supplied, dig will perform a lookup for an A record.
The -b option sets the source IP address of the query to address. This must be a valid address on one of the host's network interfaces.
The default query class (IN for internet) is overridden by the -c option. class is any valid class, such as HS for Hesiod records or CH for CHAOSNET records.
The -f option makes dig operate in batch mode by reading a list of lookup requests to process from the file filename. The file contains a number of queries, one per line. Each entry in the file should be organised in the same way they would be presented as queries to dig using the command-line interface.
If a non-standard port number is to be queried, the -p option is used. port# is the port number that dig will send its queries instead of the standard DNS port number 53. This option would be used to test a name server that has been configured to listen for queries on a non-standard port number.
The -t option sets the query type to type. It can be any valid query type which is supported in BIND9. The default query type "A", unless the -x option is supplied to indicate a reverse lookup. A zone transfer can be requested by specifying a type of AXFR. When an incremental zone transfer (IXFR) is required, type is set to ixfr=N. The incremental zone transfer will contain the changes made to the zone since the serial number in the zone's SOA record was N.
Reverse lookups - mapping addresses to names - are simplified by the -x option. addr is an IPv4 address in dotted-decimal notation, or a colon-delimited IPv6 address. When this option is used, there is no need to provide the name, class and type arguments. dig automatically performs a lookup for a name like <IP_ADDRESS>.in-addr.arpa and sets the query type and class to PTR and IN respectively. By default, IPv6 addresses are looked up using the IP6.ARPA domain and binary labels as defined in RFC2874. To use the older RFC1886 method using the IP6.INT domain and "nibble" labels, specify the -n (nibble) option.
To sign the DNS queries sent by dig and their responses using transaction signatures (TSIG), specify a TSIG key file using the -k option. You can also specify the TSIG key itself on the command line using the -y option; name is the name of the TSIG key and key is the actual key. The key is a base-64 encoded string, typically generated by dnssec-keygen(8). Caution should be taken when using the -y option on multi-user systems as the key can be visible in the output from ps(1) or in the shell's history file. When using TSIG authentication with dig, the name server that is queried needs to know the key and algorithm that is being used. In BIND, this is done by providing appropriate key and server statements in named.conf.
dig provides a number of query options which affect the way in which lookups are made and the results displayed. Some of these set or reset flag bits in the query header, some determine which sections of the answer get printed, and others determine the timeout and retry strategies.
Each query option is identified by a keyword preceded by a plus sign (+). Some keywords set or reset an option. These may be preceded by the string no to negate the meaning of that keyword. Other keywords assign values to options like the timeout interval. They have the form +keyword=value. The query options are:
Use [do not use] TCP when querying name servers. The default behaviour is to use UDP unless an AXFR or IXFR query is requested, in which case a TCP connection is used.
Use [do not use] TCP when querying name servers. This alternate syntax to +[no]tcp is provided for backwards compatibility. The "vc" stands for "virtual circuit".
Ignore truncation in UDP responses instead of retrying with TCP. By default, TCP retries are performed.
Set the search list to contain the single domain somename, as if specified in a domain directive in /etc/resolv.conf, and enable search list processing as if the +search option were given.
Use [do not use] the search list defined by the searchlist or domain directive in resolv.conf (if any). The search list is not used by default.
Deprecated, treated as a synonym for +[no]search
This option does nothing. It is provided for compatibility with old versions of dig where it set an unimplemented resolver flag.
Set [do not set] the AD (authentic data) bit in the query. The AD bit currently has a standard meaning only in responses, not in queries, but the ability to set the bit in the query is provided for completeness.
Set [do not set] the CD (checking disabled) bit in the query. This requests the server to not perform DNSSEC validation of responses.
Toggle the setting of the RD (recursion desired) bit in the query. This bit is set by default, which means dig normally sends recursive queries. Recursion is automatically disabled when the +nssearch or +trace query options are used.
When this option is set, dig attempts to find the authoritative name servers for the zone containing the name being looked up and display the SOA record that each name server has for the zone.
Toggle tracing of the delegation path from the root name servers for the name being looked up. Tracing is disabled by default. When tracing is enabled, dig makes iterative queries to resolve the name being looked up. It will follow referrals from the root servers, showing the answer from each server that was used to resolve the lookup.
toggles the printing of the initial comment in the output identifying the version of dig and the query options that have been applied. This comment is printed by default.
Provide a terse answer. The default is to print the answer in a verbose form.
Show [or do not show] the IP address and port number that supplied the answer when the +short option is enabled. If short form answers are requested, the default is not to show the source address and port number of the server that provided the answer.
Toggle the display of comment lines in the output. The default is to print comments.
This query option toggles the printing of statistics: when the query was made, the size of the reply and so on. The default behaviour is to print the query statistics.
Print [do not print] the query as it is sent. By default, the query is not printed.
Print [do not print] the question section of a query when an answer is returned. The default is to print the question section as a comment.
Display [do not display] the answer section of a reply. The default is to display it.
Display [do not display] the authority section of a reply. The default is to display it.
Display [do not display] the additional section of a reply. The default is to display it.
Set or clear all display flags.
Sets the timeout for a query to T seconds. The default time out is 5 seconds. An attempt to set T to less than 1 will result in a query timeout of 1 second being applied.
Sets the number of times to retry UDP queries to server to T instead of the default, 3. If T is less than or equal to zero, the number of retries is silently rounded up to 1.
Set the number of dots that have to appear in name to D for it to be considered absolute. The default value is that defined using the ndots statement in /etc/resolv.conf, or 1 if no ndots statement is present. Names with fewer dots are interpreted as relative names and will be searched for in the domains listed in the search or domain directive in /etc/resolv.conf.
Set the UDP message buffer size advertised using EDNS0 to B bytes. The maximum and minimum sizes of this buffer are 65535 and 0 respectively. Values outside this range are rounded up or down appropriately.
Print records like the SOA records in a verbose multi-line format with human-readable comments. The default is to print each record on a single line, to facilitate machine parsing of the dig output.
Do not try the next server if you receive a SERVFAIL. The default is to not try the next server which is the reverse of normal stub resolver behaviour.
Attempt to display the contents of messages which are malformed. The default is to not display malformed answers.
Requests DNSSEC records be sent by setting the DNSSEC OK bit (DO) in the the OPT record in the additional section of the query.
The BIND 9 implementation of dig supports specifying multiple queries on the command line (in addition to supporting the -f batch file option). Each of those queries can be supplied with its own set of flags, options and query options.
In this case, each query argument represent an individual query in the command-line syntax described above. Each consists of any of the standard options and flags, the name to be looked up, an optional query type and class and any query options that should be applied to that query.
A global set of query options, which should be applied to all queries, can also be supplied. These global query options must precede the first tuple of name, class, type, options, flags, and query options supplied on the command line. Any global query options (except the +[no]cmd option) can be overridden by a query-specific set of query options. For example:
dig +qr www.isc.org any -x <IP_ADDRESS> isc.org ns +noqrshows how dig could be used from the command line to make three lookups: an ANY query for www.isc.org, a reverse lookup of <IP_ADDRESS> and a query for the NS records of isc.org. A global query option of +qr is applied, so that dig shows the initial query it made for each lookup. The final query has a local query option of +noqr which means that dig will not print the initial query when it looks up the NS records for isc.org.


Variational autoencoders
The goal of this post is to provide a look at some of the core mathematical principles of the variational autoencoder. We shall do so by developing the variational autoencoder “from scratch”, starting with a latent variable model and culminating with the use of deep neural networks to train the generative model with a variational procedure.
We begin by considering a directed latent variable model of the following form
where is the latent variable and is the observed variable. This model describes a generative process that samples using the procedure
As such, we shall call this our generative model. If one adopts the belief that the latent variable somehow encodes semantically meaningful information about , it is natural to view this generative process as first generating the “high-level” semantic information about first before fully generating . Such a perspective motivates generative models with rich latent variable structures such as hierarchical generative models —where information about is generated hierarchically—and temporal models such as the Hidden Markov Model—where temporally-related high-level information is generated first before constructing .
We now consider a family of distributions where describes a probability distribution over . Next, consider a family of conditional distributions where describes a conditional probability distribution over given . Then our hypothesis class of generative models is the set of all possible combinations
Given a dataset , we are interested in the following learning and inference tasks
- Selecting that “best” fits .
- Approximate inference of : given a sample , how do we impute its latent variable ?
We shall also assume the following
- Intractability: computing the posterior probability is intractable.
- Big data: the dataset is too large to fit in memory; we can only work with small, sub-sampled batches of .
Learning Directed Latent Variable Models
One way to measure how closely fits the data is to measure the Kullback-Leibler (KL) divergence between the data distribution (which we denote as ) and the model’s marginal distribution ,
The distribution that ``best’’ fits is thus that minimizes the KL divergence. Equivalently, we wish to solve the maximum marginal log-likelihood problem
However, this problem is intractable due to the difficulty of marginalizing the latent variable—which is as difficult as computing the posterior . Rather than maximizing the log-likelihood directly, we instead construct a lower bound that is more amenable to optimization. To do so, we introduce a variational family and note that the following relationships hold true1 for all proposal distributions
where the inequality arises from Jensen’s inequality. The gap between the LHS (marginal log-likelihood) and the RHS (Evidence Lower Bound) is captured by the KL divergence . The inequality is tight when the proposed distribution exactly matches . In contrast to the marginal log-likelihood, the ELBO admits a tractable unbiased estimator
so long as it is easy to sample from and compute densities for . Since the ELBO itself presents an optimization problem, the maximum marginal log-likelihood problem is now replaced with
Black-Box Variational Inference
In this post, we shall focus on first-order stochastic gradient methods for optimizing the ELBO. These optimization techniques are desirable in that they allow us to sub-sample the dataset during optimization—but require our objective function to be differentiable with respect to the optimization variables. As such, we shall posit for now that any and are alternatively parameterizable as and and that these distributions are differentiable with respect to and .
This inspires an Expectation-Maximization-like algorithm, where, for each mini-batch , the following two steps are performed.
Step 1
We first do per-sample optimization of by iteratively applying the update
where , and denotes an unbiased estimate of the ELBO gradient. This step seeks to approximate the log-likelihood .
Step 2
We then perform a single update step based on the mini-batch
which corresponds to the step that hopefully moves closer to .
A Note on Gradient Estimation
The gradients and can be estimated via Monte Carlo sampling. While it is straightforward to construct an unbiased estimate of by simply pushing through the expectation operator, the same cannot be said for . Instead, we see that
This equality follows from the log-derivative trick (also commonly referred to as the REINFORCE trick). The full derivation involves some simple algebraic manipulations and is left as an exercise for the reader. The gradient estimator is thus
However, it is often noted that this estimator suffers from high variance. One of the key contributions of the variational autoencoder paper is the reparameterization trick, which introduces an auxiliary distribution and a differentiable function such that the procedure
is equivalent to sampling from . By the Law of the Unconscious Statistician, we can see that
In contrast to the REINFORCE trick, the reparameterization trick is often noted empirically to have lower variance and thus results in more stable training.
Deep Generative Model Parameterization
So far, we have described and in the abstract. To instantiate these objects, we consider choices of parametric distributions for , , and . A popular choice for is the unit Gaussian
An popular alternative is a mixture of Gaussians with trainable mean and covariance parameters.
The conditional distribution is where we introduce a deep neural network. We note that a conditional distribution can be constructed by defining a distribution family (parameterized by ) in the target space (i.e. defines an unconditional distribution over ) and a mapping function . It is natural to call the decoder that is parameterized by . The act of conditioning on is thus equivalent to using the choice of .In other words, defines the conditional distribution
The generative model is called a deep generative model since we will be using a neural network to instantiate the function . In the case where is a Gaussian distribution, we can thus represent it as
where and are neural networks that propose the mean and covariance matrix for the Gaussian distribution over when conditioned on .
Finally, the variational family for the proposal distribution needs to be chosen judiciously so that the reparameterization trick is possible. Once again, a popular choice is the Gaussian distribution, where
where is the Cholesky decomposition of . For simplicity, practitioners often restrict to be a diagonal matrix (which restricts the distribution family to that of factorized Gaussians).
Amortized Variational Inference
A noticable limitation of black-box variational inference is that Step 1 executes an optimization subroutine that is computationally expensive. Recall that the goal of the Step 1 is to find
For a given choice of , there is a well-defined mapping from . A key realization is that this mapping can be learned. In particular, one can train an encoding function (parameterized by ) (where is the space of parameters) on the following objective
It is worth noting at this point that can be interpreted as defining the conditional distribution . With a slight abuse of notation, we define
and rewrite the optimization problem as
It is also worth noting that optimizing over the entire dataset as a subroutine everytime we sample a new mini-batch is clearly not reasonable. However, if we believe that is capable of quickly adapting to always give a close-enough approximation of given the current choice of , then we can interleave the optimization and . The yields the following procedure, where for each mini-batch , we perform the following two updates jointly
rather than running BBVI’s Step 1 as a subroutine. By leveraging the learnability of , this optimization procedure amortizes the cost of variational inference. If one further chooses to define as a neural network, the result is the variational autoencoder.
Footnotes
-
The first equality only holds if the support of includes that of . If not, it is an inequality. ↩


Before Change
logger.debug("got internally published event with verb %s id %s" % (activity.verb, activity.id))
if activity.verb in ["ban", "kick", "remove"]:
self.handle_local_node_events(data, activity)
else:
// otherwise it"s external events for possible analysis
After Change
self.handle_server_activity(data, activity)
except Exception as e:
logger.error("could not handle server activity: %s" % str(e))
logger.exception(traceback.format_exc())
def _handle_server_activity(self, data: dict, activity: Activity) -> None:
if activity.id in self.recently_delegated_events:


THE FORMAL MINISTER OF WORKS AND HOUSING WHO DIED BY MOTOR ACCIDENT IN OUR HOME TOWN IN ANGOLA ON 30TH DECEMBER 2003. I WISH TO INFORM YOU THAT HE LEFT ($10.8M UNITED STATE DOLLAS)FOR ME IN A HOLDING FIRM IN (EUROPE) WHICH HAS BEEN DORMANT FOR THE PAST ONE YEAR IN WHICH I WAS THE NEXT OF KIN AND HIS SPECIAL BENEFICIARY.     MY REGARD BOGA WASSE.


Service-Center Management UI Console
Service-Center Management UI Console enables user to view the list of MicroServices registered in SC. Users can view the detailed information of their MicroServices, Instances and Schemas. Service-Center UI also offers a unique feature of testing the Schemas of their MicroServices from UI, Users can also download the html client for their Schemas.
Preview of Management Console
Features
Service-Center Management console offers very useful features which makes users easy to use and manage service-center.
Dashboard
This is the place where you can get the overall information about the services which are registered in your service-center like total number of services, providers, consumers and total instances. You can also get a list of Services which based on their current status.
Micro-Service List
This is the place where you can see the basic details of all the services which are registered in Service-Center. You can see the details like MicroService Name, Application Name, Status, Version, Creation time and Instance count. You can also un-register the microservice from Operations Tab if there is no running instances for the microservice.
Instance Details
This is the place where you can see all the current running instances for the MicroService, you can get the list of endpoints and their protocols.
Provider List
This is the place where you can get the list of all the providers for the MicroService.
Consumer List
This is the place where you can get the list of all the consumers for the MicroService
Schema List
This is the place where we can get the list of all the Schema's for your MicroService, here you get options of viewing the Schema in Swagger form or Test the Schema on some particular instance. Here you also get an option to Download the Schema file in Html Client form.
For Viewing the Schema in Swagger form you can click on Test Schema button and you can view the complete details of Schema in Swagger form.
If you wish to test the Schema on some particular Instance then you can click on Test Schema and select the instance on which you want to test the Schema and then select the endpoints for that instance.
Once you selected the instance then you are ready for testing the Schema, you can input the required parameters for the Schema and hit on ‘Try it Out’ Button.
留下评论
您的电子邮箱地址并不会被展示。请填写标记为必须的字段。 *


visible only on large screen greater then 1200px
visible only on medium scren between 992px to 1999px
visible only on small screen between 768px to 992px
visible only on extra small screen lesser than 768px
hidden only on extra small screen between 768px to 992px


{% extends "layout.html" %} {% block nav_all_threads_active %} class="active"{% endblock %} {% block content %}
There don't seem to be any active conversations.


--- title: Google make the web faster excerpt: 'Google "Let''s make the web faster" site: http://code.google.com/speed/ 2009-06-24' date: '2009-06-24 18:30:22 +0200' date_gmt: '2009-06-24 16:30:22 +0200' categories: - Webdev ---
Google "Let's make the web faster" site: http://code.google.com/speed/ 2009-06-24


|
Game Engine Architecture
1.0
A simple 3D game engine.
|
A class that manages the level and gameplay. More...
#include <Scene.h>
Public Member Functions | |
| Scene (const std::string &p_SceneFile, std::shared_ptr< DefaultGame > p_Game, glm::vec3 p_BackgroundColour=glm::vec3(0.2f, 0.2f, 0.2f)) | |
| Constructor. More... | |
| ~Scene ()=default | |
| Default destructor. | |
| void | Update (float p_DeltaTime) |
| Updates the scene. More... | |
| void | Render (std::shared_ptr< IEngineCore > p_EngineInterface) |
| Renders the scene. More... | |
| std::unordered_multimap< std::type_index, std::shared_ptr< GameObject > > | GetObjectsRequiringInput () const |
| Gets the objects that require input. More... | |
A class that manages the level and gameplay.
| Scene::Scene | ( | const std::string & | p_SceneFile, |
| std::shared_ptr< DefaultGame > | p_Game, | ||
| glm::vec3 | p_BackgroundColour = glm::vec3(0.2f, 0.2f, 0.2f) |
||
| ) |
Constructor.
| p_SceneFile | the (scene's) JSON file location. |
| p_Game | a pointer to the game object (must be turned into a weak pointer, if stored). |
| p_BackgroundColour | the colour of the window's background - default initialised. |
| std::unordered_multimap<std::type_index, std::shared_ptr<GameObject> > Scene::GetObjectsRequiringInput | ( | ) | const |
Gets the objects that require input.
| void Scene::Render | ( | std::shared_ptr< IEngineCore > | p_EngineInterface | ) |
Renders the scene.
| p_EngineInterface | the engine interface pointer. |
| void Scene::Update | ( | float | p_DeltaTime | ) |
Updates the scene.
| p_DeltaTime | time passed. |


In the for-as-across subclause the for or as construct binds the variable var to the value of each element in the array vector. The loop keyword across marks the array vector; across is used as a preposition in this syntax. Iteration stops when there are no more elements in the supplied array that can be referenced. Some implementations might recognize a the special form in the vector form to produce more efficient code.
<IP_ADDRESS>.5.1 Examples of for-as-across subclause


Whence
Where
Departure Date
July 27
Returning Date
July 29
Passenger(s)
Seat Class
8:30
Dublin 27 July
MSQ
OSL
18 h 25 m (average)
12:45
Oslo 29 July
3,210$
Buy ticket
8:30
Dublin 27 July
MSQ
OSL
18 h 25 m (average)
1 transfer RIX
12:45
Oslo 29 July
3,210$
Buy ticket
8:30
Dublin 27 July
MSQ
OSL
18 h 25 m (average)
1 transfer RIX
12:45
Oslo 29 July
3,210$
Buy ticket


proudly developed by 'Taylor and Friends'
Before being able to export user must save a seed first
downloadify


Group Theory and Sage#
Author: Robert A. Beezer, University of Puget Sound
This compilation collects Sage commands that are useful for a student in an introductory course on group theory. It is not intended to teach Sage or to teach group theory. (There are many introductory texts on group theory and more information on Sage can be found via www.sagemath.org) Rather, by presenting commands roughly in the order a student would learn the corresponding mathematics they might be encouraged to experiment and learn more about mathematics and learn more about Sage. Not coincidentally, when Sage was the acronym SAGE, the “E” in Sage stood for “Experimentation.”
This guide is also distributed in PDF format and as a Sage worksheet. The worksheet version can be imported into the Sage notebook environment running in a web browser, and then the displayed chunks of code may be executed by Sage if one clicks on the small “evaluate” link below each cell, for a fully interactive experience. A PDF and Sage worksheet versions of this tutorial are available at http://abstract.ups.edu/sage-aata.html.
Changelog:
2009/01/30 Version 1.0, first complete release
2009/03/03 Version 1.1, added cyclic group size interact
2010/03/10 Version 1.3, dropped US on license, some edits.
Basic properties of the integers#
Integer division#
The command a % b
will return the remainder upon division of \(a\)
by \(b\). In other words, the value is the unique integer \(r\) such that:
\(0 \leq r < b\); and
\(a = bq + r\) for some integer \(q\) (the quotient).
Then \((a - r) / b\) will equal \(q\). For example:
sage: r = 14 % 3
sage: q = (14 - r) / 3
sage: r, q
(2, 4)
will return 2
for the value of r
and 4
for the value of
q
. Note that the “/
” is integer division, where any
remainder is cast away and the result is always an integer. So, for
example, 14 / 3
will again equal 4
, not 4.66666
.
Greatest common divisor#
The greatest common divisor of \(a\) and \(b\) is obtained with the
command gcd(a,b)
, where in our first uses, \(a\) and \(b\) are
integers. Later, \(a\) and \(b\) can be other objects with a notion
of divisibility and “greatness,” such as polynomials. For example:
sage: gcd(2776, 2452)
4
Extended greatest common divisor#
The command xgcd(a, b)
(“eXtended GCD”) returns a triple where the
first element is the greatest common divisor of \(a\) and \(b\) (as with
the gcd(a, b)
command above), but the next two elements are the
values of \(r\) and \(s\) such that \(ra + sb = \gcd(a, b)\). For example,
xgcd(633, 331)
returns (1, 194, -371)
. Portions of the triple
can be extracted using [ ]
to access the entries of the triple,
starting with the first as number 0
. For example, the following
should return the result True
(even if you change the values of
a
and b
). Studying this block of code will go a long way
towards helping you get the most out of Sage’s output. (Note that
“=
” is how a value is assigned to a variable, while as in the last
line, “==
” is how we determine equality of two items.)
sage: a = 633
sage: b = 331
sage: extended = xgcd(a, b)
sage: g = extended[0]
sage: r = extended[1]
sage: s = extended[2]
sage: g == r*a + s*b
True
Divisibility#
A remainder of zero indicates divisibility. So (a % b) == 0
will
return True
if \(b\) divides \(a\), and will otherwise return
False
. For example, (9 % 3) == 0
is True
, but
(9 % 4) == 0
is False
. Try predicting the output of the
following before executing it in Sage.
sage: answer1 = ((20 % 5) == 0)
sage: answer2 = ((17 % 4) == 0)
sage: answer1, answer2
(True, False)
Factoring#
As promised by the Fundamental Theorem of Arithmetic, factor(a)
will return a unique expression for \(a\) as a product of powers of
primes. It will print in a nicely-readable form, but can also be
manipulated with Python as a list of pairs \((p_i, e_i)\) containing
primes as bases, and their associated exponents. For example:
sage: factor(2600)
2^3 * 5^2 * 13
If you just want the prime divisors of an integer, then use the
prime_divisors(a)
command, which will return a list of all the
prime divisors of \(a\). For example:
sage: prime_divisors(2600)
[2, 5, 13]
We can strip off other pieces of the prime decomposition using two
levels of [ ]
. This is another good example to study in order to
learn about how to drill down into Python lists.
sage: n = 2600
sage: decomposition = factor(n)
sage: print("{} decomposes as {}".format(n, decomposition))
2600 decomposes as 2^3 * 5^2 * 13
sage: secondterm = decomposition[1]
sage: print("Base and exponent (pair) for second prime: "+str(secondterm))
Base and exponent (pair) for second prime: (5, 2)
sage: base = secondterm[0]
sage: exponent = secondterm[1]
sage: print("Base is "+str(base))
Base is 5
sage: print("Exponent is "+str(exponent))
Exponent is 2
sage: thirdbase = decomposition[2][0]
sage: thirdexponent = decomposition[2][1]
sage: print("Base of third term is {} with exponent {}".format(thirdbase, thirdexponent))
Base of third term is 13 with exponent 1
With a bit more work, the factor()
command can be used to factor
more complicated items, such as polynomials.
Multiplicative inverse, modular arithmetic#
The command inverse_mod(a, n)
yields the multiplicative inverse of
\(a\) mod \(n\) (or an error if it doesn’t exist). For example:
sage: inverse_mod(352, 917)
508
(As a check, find the integer \(m\) such that 352*508 == m*917+1
.)
Then try
sage: inverse_mod(4, 24)
Traceback (most recent call last):
...
ZeroDivisionError: inverse of Mod(4, 24) does not exist
and explain the result.
Powers with modular arithmetic#
The command power_mod(a, m, n)
yields \(a^m\) mod \(n\). For example:
sage: power_mod(15, 831, 23)
10
If \(m = -1\), then this command will duplicate the function of
inverse_mod()
.
Euler \(\phi\)-function#
The command euler_phi(n)
will return the number of positive
integers less than \(n\) and relatively prime to \(n\) (i.e. having
greatest common divisor with \(n\) equal to 1). For example:
sage: euler_phi(345)
176
Experiment by running the following code several times:
sage: m = random_prime(10000)
sage: n = random_prime(10000)
sage: euler_phi(m*n) == euler_phi(m) * euler_phi(n) or m == n
True
Feel a conjecture coming on? Can you generalize this result?
Primes#
The command is_prime(a)
returns True
or False
depending on
if \(a\) is prime or not. For example,
sage: is_prime(117371)
True
while
sage: is_prime(14547073)
False
since \(14547073 = 1597 * 9109\) (as you could determine with the
factor()
command).
The command random_prime(a, True)
will return a random prime
between 2 and \(a\). Experiment with:
sage: p = random_prime(10^21, True)
sage: is_prime(p)
True
(Replacing True
by False
will speed up the search, but there
will be a very small probability the result will not be prime.)
The command prime_range(a, b)
returns an ordered list of all the
primes from \(a\) to \(b - 1\), inclusive. For example,
sage: prime_range(500, 550)
[503, 509, 521, 523, 541, 547]
The commands next_prime(a)
and previous_prime(a)
are other
ways to get a single prime number of a desired size. Give them a try.
Permutation groups#
A good portion of Sage’s support for group theory is based on routines from GAP (Groups, Algorithms, and Programming at https://www.gap-system.org. Groups can be described in many different ways, such as sets of matrices or sets of symbols subject to a few defining relations. A very concrete way to represent groups is via permutations (one-to-one and onto functions of the integers 1 through \(n\)), using function composition as the operation in the group. Sage has many routines designed to work with groups of this type and they are also a good way for those learning group theory to gain experience with the basic ideas of group theory. For both these reasons, we will concentrate on these types of groups.
Writing permutations#
Sage uses “disjoint cycle notation” for permutations, see any introductory text on group theory (such as Judson, Section 4.1) for more on this. Composition occurs left to right, which is not what you might expect and is exactly the reverse of what Judson and many others use. (There are good reasons to support either direction, you just need to be certain you know which one is in play.) There are two ways to write the permutation \(\sigma = (1\,3) (2\,5\,4)\):
As a text string (include quotes):
"(1,3) (2,5,4)"
As a Python list of “tuples”:
[(1,3), (2,5,4)]
Groups#
Sage knows many popular groups as sets of permutations. More are
listed below, but for starters, the full “symmetric group” of all
possible permutations of 1 through \(n\) can be built with the command
SymmetricGroup(n)
.
Permutation elements Elements of a group can be created, and composed, as follows
sage: G = SymmetricGroup(5)
sage: sigma = G("(1,3) (2,5,4)")
sage: rho = G([(2,4), (1,5)])
sage: rho^(-1) * sigma * rho
(1,2,4)(3,5)
Available functions for elements of a permutation group include finding the order of an element, i.e. for a permutation \(\sigma\) the order is the smallest power of \(k\) such that \(\sigma^k\) equals the identity element \(()\). For example:
sage: G = SymmetricGroup(5)
sage: sigma = G("(1,3) (2,5,4)")
sage: sigma.order()
6
The sign of the permutation \(\sigma\) is defined to be 1 for an even permutation and \(-1\) for an odd permutation. For example:
sage: G = SymmetricGroup(5)
sage: sigma = G("(1,3) (2,5,4)")
sage: sigma.sign()
-1
since \(\sigma\) is an odd permutation.
Many more available functions that can be applied to a permutation can
be found via “tab-completion.” With sigma
defined as an element
of a permutation group, in a Sage cell, type sigma.
(Note the
“.
”) and then press the Tab key. You will get a list of available
functions (you may need to scroll down to see the whole list).
Experiment and explore! It is what Sage is all about. You really
cannot break anything.
Creating groups#
This is an annotated list of some small well-known permutation groups that can be created simply in Sage. You can find more in the source code file
SAGE_ROOT/src/sage/groups/perm_gps/permgroup_named.py
SymmetricGroup(n)
: All \(n!\) permutations on \(n\) symbols.DihedralGroup(n)
: Symmetries of an \(n\)-gon. Rotations and flips, \(2n\) in total.CyclicPermutationGroup(n)
: Rotations of an \(n\)-gon (no flips), \(n\) in total.AlternatingGroup(n)
: Alternating group on \(n\) symbols having \(n!/2\) elements.KleinFourGroup()
: The non-cyclic group of order 4.
Group functions#
Individual elements of permutation groups are important, but we primarily wish to study groups as objects on their own. So a wide variety of computations are available for groups. Define a group, for example
sage: H = DihedralGroup(6)
sage: H
Dihedral group of order 12 as a permutation group
and then a variety of functions become available.
After trying the examples below, experiment with tab-completion.
Having defined H
, type H.
(note the “.
”) and then press
the Tab key. You will get a list of available functions (you may need
to scroll down to see the whole list). As before,
experiment and explore—it is really hard to break anything.
Here is another couple of ways to experiment and explore. Find a
function that looks interesting, say is_abelian()
. Type
H.is_abelian?
(note the question mark) followed by the Enter key.
This will display a portion of the source code for the
is_abelian()
function, describing the inputs and output, possibly
illustrated with example uses.
If you want to learn more about how Sage works, or possibly extend its
functionality, then you can start by examining the complete Python
source code. For example, try H.is_abelian??
, which will allow
you to determine that the is_abelian()
function is basically
riding on GAP’s IsAbelian()
command and asking GAP do the
heavy-lifting for us. (To get the maximum advantage of using Sage it
helps to know some basic Python programming, but it is not required.)
OK, on to some popular command for groups. If you are using the worksheet, be sure you have defined the group \(H\) as the dihedral group \(D_6\), since we will not keep repeating its definition below.
Abelian?#
The command
sage: H = DihedralGroup(6)
sage: H.is_abelian()
False
will return False
since \(D_6\) is a non-abelian group.
Order#
The command
sage: H = DihedralGroup(6)
sage: H.order()
12
will return 12
since \(D_6\) is a group of with 12 elements.
All elements#
The command
sage: H = DihedralGroup(6)
sage: H.list()
[(),
(1,5,3)(2,6,4),
(1,3,5)(2,4,6),
(1,6,5,4,3,2),
(1,4)(2,5)(3,6),
(1,2,3,4,5,6),
(2,6)(3,5),
(1,5)(2,4),
(1,3)(4,6),
(1,6)(2,5)(3,4),
(1,4)(2,3)(5,6),
(1,2)(3,6)(4,5)]
will return all of the elements of \(H\) in a fixed order as a Python
list.
By default the table uses lowercase Latin letters to name the elements
of the group. The actual elements used can be found using the
row_keys()
or column_keys()
commands for the table.
For example to determine the fifth element in the table, the
element named e
:
sage: H = DihedralGroup(6)
sage: T = H.cayley_table()
sage: headings = T.row_keys()
sage: headings[4]
(1,3)(4,6)
Center#
The command H.center()
will return a subgroup that is the center
of the group \(H\) (see Exercise 2.46 in Judson). Try
sage: H = DihedralGroup(6)
sage: H.center().list()
[(), (1,4)(2,5)(3,6)]
to see which elements of \(H\) commute with every element of \(H\).
Cayley graph#
For fun, try show(H.cayley_graph())
.
Subgroups#
Cyclic subgroups#
If G
is a group and a
is an element of the group (try
a = G.random_element()
), then
a = G.random_element()
H = G.subgroup([a])
will create H
as the cyclic subgroup of G
with generator
a
.
For example the code below will:
create
G
as the symmetric group on five symbols;specify
sigma
as an element ofG
;use
sigma
as the generator of a cyclic subgroupH
;list all the elements of
H
.
In more mathematical notation, we might write \(\langle (1\,2\,3) (4\,5) \rangle = H \subseteq G = S_5\).
sage: G = SymmetricGroup(5)
sage: sigma = G("(1,2,3) (4,5)")
sage: H = G.subgroup([sigma])
sage: H.list()
[(), (1,2,3)(4,5), (1,3,2), (4,5), (1,2,3), (1,3,2)(4,5)]
Experiment by trying different permutations for sigma
and
observing the effect on H
.
Cyclic groups#
Groups that are cyclic themselves are both important and rich in
structure. The command CyclicPermutationGroup(n)
will create a
permutation group that is cyclic with n
elements. Consider the
following example (note that the indentation of the third line is
critical) which will list the elements of a cyclic group of order 20,
preceded by the order of each element.
sage: n = 20
sage: CN = CyclicPermutationGroup(n)
sage: for g in CN:
....: print("{} {}".format(g.order(), g))
1 ()
20 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
10 (1,3,5,7,9,11,13,15,17,19)(2,4,6,8,10,12,14,16,18,20)
20 (1,4,7,10,13,16,19,2,5,8,11,14,17,20,3,6,9,12,15,18)
5 (1,5,9,13,17)(2,6,10,14,18)(3,7,11,15,19)(4,8,12,16,20)
4 (1,6,11,16)(2,7,12,17)(3,8,13,18)(4,9,14,19)(5,10,15,20)
10 (1,7,13,19,5,11,17,3,9,15)(2,8,14,20,6,12,18,4,10,16)
20 (1,8,15,2,9,16,3,10,17,4,11,18,5,12,19,6,13,20,7,14)
5 (1,9,17,5,13)(2,10,18,6,14)(3,11,19,7,15)(4,12,20,8,16)
20 (1,10,19,8,17,6,15,4,13,2,11,20,9,18,7,16,5,14,3,12)
2 (1,11)(2,12)(3,13)(4,14)(5,15)(6,16)(7,17)(8,18)(9,19)(10,20)
20 (1,12,3,14,5,16,7,18,9,20,11,2,13,4,15,6,17,8,19,10)
5 (1,13,5,17,9)(2,14,6,18,10)(3,15,7,19,11)(4,16,8,20,12)
20 (1,14,7,20,13,6,19,12,5,18,11,4,17,10,3,16,9,2,15,8)
10 (1,15,9,3,17,11,5,19,13,7)(2,16,10,4,18,12,6,20,14,8)
4 (1,16,11,6)(2,17,12,7)(3,18,13,8)(4,19,14,9)(5,20,15,10)
5 (1,17,13,9,5)(2,18,14,10,6)(3,19,15,11,7)(4,20,16,12,8)
20 (1,18,15,12,9,6,3,20,17,14,11,8,5,2,19,16,13,10,7,4)
10 (1,19,17,15,13,11,9,7,5,3)(2,20,18,16,14,12,10,8,6,4)
20 (1,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2)
By varying the size of the group (change the value of n
) you can
begin to illustrate some of the structure of a cyclic group (for
example, try a prime).
We can cut/paste an element of order 5 from the output above (in the case when the cyclic group has 20 elements) and quickly build a subgroup:
sage: C20 = CyclicPermutationGroup(20)
sage: rho = C20("(1,17,13,9,5)(2,18,14,10,6)(3,19,15,11,7)(4,20,16,12,8)")
sage: H = C20.subgroup([rho])
sage: H.list()
[(),
(1,17,13,9,5)(2,18,14,10,6)(3,19,15,11,7)(4,20,16,12,8),
(1,13,5,17,9)(2,14,6,18,10)(3,15,7,19,11)(4,16,8,20,12),
(1,9,17,5,13)(2,10,18,6,14)(3,11,19,7,15)(4,12,20,8,16),
(1,5,9,13,17)(2,6,10,14,18)(3,7,11,15,19)(4,8,12,16,20)]
For a cyclic group, the following command will list all of the subgroups.
sage: C20 = CyclicPermutationGroup(20)
sage: C20.conjugacy_classes_subgroups()
[Subgroup generated by [()] of (Cyclic group of order 20 as a permutation group),
Subgroup generated by [(1,11)(2,12)(3,13)(4,14)(5,15)(6,16)(7,17)(8,18)(9,19)(10,20)] of (Cyclic group of order 20 as a permutation group),
Subgroup generated by [(1,6,11,16)(2,7,12,17)(3,8,13,18)(4,9,14,19)(5,10,15,20), (1,11)(2,12)(3,13)(4,14)(5,15)(6,16)(7,17)(8,18)(9,19)(10,20)] of (Cyclic group of order 20 as a permutation group),
Subgroup generated by [(1,5,9,13,17)(2,6,10,14,18)(3,7,11,15,19)(4,8,12,16,20)] of (Cyclic group of order 20 as a permutation group),
Subgroup generated by [(1,3,5,7,9,11,13,15,17,19)(2,4,6,8,10,12,14,16,18,20), (1,5,9,13,17)(2,6,10,14,18)(3,7,11,15,19)(4,8,12,16,20)] of (Cyclic group of order 20 as a permutation group),
Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20), (1,3,5,7,9,11,13,15,17,19)(2,4,6,8,10,12,14,16,18,20), (1,5,9,13,17)(2,6,10,14,18)(3,7,11,15,19)(4,8,12,16,20)] of (Cyclic group of order 20 as a permutation group)]
Be careful, this command uses some more advanced ideas and will not usually list all of the subgroups of a group. Here we are relying on special properties of cyclic groups (but see the next section).
If you are viewing this as a PDF, you can safely skip over the next bit of code. However, if you are viewing this as a worksheet in Sage, then this is a place where you can experiment with the structure of the subgroups of a cyclic group. In the input box, enter the order of a cyclic group (numbers between 1 and 40 are good initial choices) and Sage will list each subgroup as a cyclic group with its generator. The factorization at the bottom might help you formulate a conjecture.
%auto
@interact
def _(n = input_box(default=12, label = "Cyclic group of order:", type=Integer) ):
cyclic = CyclicPermutationGroup(n)
subgroups = cyclic.conjugacy_classes_subgroups()
html( "All subgroups of a cyclic group of order $%s$\n" % latex(n) )
table = "$\\begin{array}{ll}"
for sg in subgroups:
table = table + latex(sg.order()) + \
" & \\left\\langle" + latex(sg.gens()[0]) + \
"\\right\\rangle\\\\"
table = table + "\\end{array}$"
html(table)
html("\nHint: $%s$ factors as $%s$" % ( latex(n), latex(factor(n)) ) )
All subgroups#
If \(H\) is a subgroup of \(G\) and \(g \in G\), then
\(gHg^{-1} = \{ghg^{-1} \mid h \in G\}\) will also be a subgroup of \(G\).
If G
is a group, then the command
G.conjugacy_classes_subgroups()
will return a list of subgroups of
G
, but not all of the subgroups. However, every subgroup can be
constructed from one on the list by the \(gHg^{-1}\) construction with a
suitable \(g\). As an illustration, the code below:
creates
K
as the dihedral group of order 24, \(D_{12}\);stores the list of subgroups output by
K.conjugacy_classes_subgroups()
in the variablesg
;prints the elements of the list;
selects the second subgroup in the list, and lists its elements.
sage: K = DihedralGroup(12)
sage: sg = K.conjugacy_classes_subgroups()
sage: sg
[Subgroup generated by [()] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,7)(2,8)(3,9)(4,10)(5,11)(6,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,2)(3,12)(4,11)(5,10)(6,9)(7,8)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8), (1,7)(2,8)(3,9)(4,10)(5,11)(6,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,7)(2,8)(3,9)(4,10)(5,11)(6,12), (1,10,7,4)(2,11,8,5)(3,12,9,6)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,2)(3,12)(4,11)(5,10)(6,9)(7,8), (1,7)(2,8)(3,9)(4,10)(5,11)(6,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,3,5,7,9,11)(2,4,6,8,10,12), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,2)(3,12)(4,11)(5,10)(6,9)(7,8), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8), (1,7)(2,8)(3,9)(4,10)(5,11)(6,12), (1,10,7,4)(2,11,8,5)(3,12,9,6)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8), (1,3,5,7,9,11)(2,4,6,8,10,12), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,2,3,4,5,6,7,8,9,10,11,12), (1,3,5,7,9,11)(2,4,6,8,10,12), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(1,2)(3,12)(4,11)(5,10)(6,9)(7,8), (1,3,5,7,9,11)(2,4,6,8,10,12), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group),
Subgroup generated by [(2,12)(3,11)(4,10)(5,9)(6,8), (1,2,3,4,5,6,7,8,9,10,11,12), (1,3,5,7,9,11)(2,4,6,8,10,12), (1,5,9)(2,6,10)(3,7,11)(4,8,12)] of (Dihedral group of order 24 as a permutation group)]
sage: print("An order two subgroup:\n{}".format(sg[1].list()))
An order two subgroup:
[(), (1,7)(2,8)(3,9)(4,10)(5,11)(6,12)]
It is important to note that this is a nice long list of subgroups, but will rarely create every such subgroup. For example, the code below:
creates
rho
as an element of the groupK
;creates
L
as a cyclic subgroup ofK
;prints the two elements of
L
; and finallytests to see if this subgroup is part of the output of the list
sg
created just above (it is not).
sage: K = DihedralGroup(12)
sage: sg = K.conjugacy_classes_subgroups()
sage: rho = K("(1,4) (2,3) (5,12) (6,11) (7,10) (8,9)")
sage: L = PermutationGroup([rho])
sage: L.list()
[(), (1,4)(2,3)(5,12)(6,11)(7,10)(8,9)]
sage: L in sg
False
Symmetry groups#
You can give Sage a short list of elements of a permutation group and Sage will find the smallest subgroup that contains those elements. We say the list “generates” the subgroup. We list a few interesting subgroups you can create this way.
Symmetries of an equilateral triangle#
Label the vertices of an equilateral triangle as 1, 2 and 3. Then
any permutation of the vertices will be a symmetry of the triangle.
So either SymmetricGroup(3)
or DihedralGroup(3)
will create
the full symmetry group.
Symmetries of an \(n\)-gon#
A regular, \(n\)-sided figure in the plane (an \(n\)-gon) has \(2n\)
symmetries, comprised of \(n\) rotations (including the trivial one) and
\(n\) “flips” about various axes. The dihedral group
DihedralGroup(n)
is frequently defined as exactly the symmetry
group of an \(n\)-gon.
Symmetries of a tetrahedron#
Label the 4 vertices of a regular tetrahedron as 1, 2, 3 and 4. Fix the vertex labeled 4 and rotate the opposite face through 120 degrees. This will create the permutation/symmetry \((1\,2\, 3)\). Similarly, fixing vertex 1, and rotating the opposite face will create the permutation \((2\,3\,4)\). These two permutations are enough to generate the full group of the twelve symmetries of the tetrahedron. Another symmetry can be visualized by running an axis through the midpoint of an edge of the tetrahedron through to the midpoint of the opposite edge, and then rotating by 180 degrees about this axis. For example, the 1–2 edge is opposite the 3–4 edge, and the symmetry is described by the permutation \((1\,2) (3\,4)\). This permutation, along with either of the above permutations will also generate the group. So here are two ways to create this group:
sage: tetra_one = PermutationGroup(["(1,2,3)", "(2,3,4)"])
sage: tetra_one
Permutation Group with generators [(2,3,4), (1,2,3)]
sage: tetra_two = PermutationGroup(["(1,2,3)", "(1,2)(3,4)"])
sage: tetra_two
Permutation Group with generators [(1,2)(3,4), (1,2,3)]
This group has a variety of interesting properties, so it is worth
experimenting with. You may also know it as the “alternating group
on 4 symbols,” which Sage will create with the command
AlternatingGroup(4)
.
Symmetries of a cube#
Label vertices of one face of a cube with 1, 2, 3 and 4, and on the opposite face label the vertices 5, 6, 7 and 8 (5 opposite 1, 6 opposite 2, etc.). Consider three axes that run from the center of a face to the center of the opposite face, and consider a quarter-turn rotation about each axis. These three rotations will construct the entire symmetry group. Use
sage: cube = PermutationGroup(["(3,2,6,7)(4,1,5,8)",
....: "(1,2,6,5)(4,3,7,8)", "(1,2,3,4)(5,6,7,8)"])
sage: cube.list()
[(),
(1,3)(2,4)(5,7)(6,8),
(1,6)(2,5)(3,8)(4,7),
(1,8)(2,7)(3,6)(4,5),
(1,4,3,2)(5,8,7,6),
(1,2,3,4)(5,6,7,8),
(1,5)(2,8)(3,7)(4,6),
(1,7)(2,6)(3,5)(4,8),
(2,5,4)(3,6,8),
(1,3,8)(2,7,5),
(1,6,3)(4,5,7),
(1,8,6)(2,4,7),
(1,4)(2,8)(3,5)(6,7),
(1,2,6,5)(3,7,8,4),
(1,5,6,2)(3,4,8,7),
(1,7)(2,3)(4,6)(5,8),
(2,4,5)(3,8,6),
(1,3,6)(4,7,5),
(1,6,8)(2,7,4),
(1,8,3)(2,5,7),
(1,4,8,5)(2,3,7,6),
(1,2)(3,5)(4,6)(7,8),
(1,5,8,4)(2,6,7,3),
(1,7)(2,8)(3,4)(5,6)]
A cube has four distinct diagonals (joining opposite vertices through the center of the cube). Each symmetry of the cube will cause the diagonals to arrange differently. In this way, we can view an element of the symmetry group as a permutation of four “symbols”—the diagonals. It happens that each of the 24 permutations of the diagonals is created by exactly one symmetry of the 8 vertices of the cube. So this subgroup of \(S_8\) is “the same as” \(S_4\). In Sage:
sage: cube = PermutationGroup(["(3,2,6,7)(4,1,5,8)",
....: "(1,2,6,5)(4,3,7,8)", "(1,2,3,4)(5,6,7,8)"])
sage: cube.is_isomorphic(SymmetricGroup(4))
True
will test to see if the group of symmetries of the cube are “the same
as” \(S_4\) and so will return True
.
Here is an another way to create the symmetries of a cube. Number the six faces of the cube as follows: 1 on top, 2 on the bottom, 3 in front, 4 on the right, 5 in back, 6 on the left. Now the same rotations as before (quarter-turns about axes through the centers of two opposite faces) can be used as generators of the symmetry group:
sage: cubeface = PermutationGroup(["(1,3,2,5)", "(1,4,2,6)", "(3,4,5,6)"])
sage: cubeface.list()
[(),
(3,5)(4,6),
(1,6,5)(2,4,3),
(1,6,3)(2,4,5),
(1,5,6)(2,3,4),
(1,5,4)(2,3,6),
(1,2)(4,6),
(1,2)(3,5),
(1,4,5)(2,6,3),
(1,4,3)(2,6,5),
(1,3,4)(2,5,6),
(1,3,6)(2,5,4),
(1,4,2,6),
(1,6)(2,4)(3,5),
(1,3,2,5),
(1,5,2,3),
(1,2)(3,4)(5,6),
(3,6,5,4),
(1,6,2,4),
(1,4)(2,6)(3,5),
(1,5)(2,3)(4,6),
(1,3)(2,5)(4,6),
(3,4,5,6),
(1,2)(3,6)(4,5)]
Again, this subgroup of \(S_6\) is “same as” the full symmetric group, \(S_4\):
sage: cubeface = PermutationGroup(["(1,3,2,5)", "(1,4,2,6)", "(3,4,5,6)"])
sage: cubeface.is_isomorphic(SymmetricGroup(4))
True
It turns out that in each of the above constructions, it is sufficient to use just two of the three generators (any two). But one generator is not enough. Give it a try and use Sage to convince yourself that a generator can be sacrificed in each case.
Normal subgroups#
Checking normality#
The code below:
begins with the alternating group \(A_4\);
specifies three elements of the group (the three symmetries of the tetrahedron that are 180 degree rotations about axes through midpoints of opposite edges);
uses these three elements to generate a subgroup; and finally
illustrates the command for testing if the subgroup
H
is a normal subgroup of the groupA4
.
sage: A4 = AlternatingGroup(4)
sage: r1 = A4("(1,2) (3,4)")
sage: r2 = A4("(1,3) (2,4)")
sage: r3 = A4("(1,4) (2,3)")
sage: H = A4.subgroup([r1, r2, r3])
sage: H.is_normal(A4)
True
Quotient group#
Extending the previous example, we can create the quotient (factor) group of \(A_4\) by \(H\). The commands
sage: A4 = AlternatingGroup(4)
sage: r1 = A4("(1,2) (3,4)")
sage: r2 = A4("(1,3) (2,4)")
sage: r3 = A4("(1,4) (2,3)")
sage: H = A4.subgroup([r1, r2, r3])
sage: A4.quotient(H)
Permutation Group with generators [(1,2,3)]
returns a permutation group generated by (1,2,3)
. As expected
this is a group of order 3. Notice that we do not get back a group of
the actual cosets, but instead we get a group isomorphic to the
factor group.
Simple groups#
It is easy to check to see if a group is void of any normal subgroups. The commands
sage: AlternatingGroup(5).is_simple()
True
sage: AlternatingGroup(4).is_simple()
False
prints True
and then False
.
Composition series#
For any group, it is easy to obtain a composition series. There is an element of randomness in the algorithm, so you may not always get the same results. (But the list of factor groups is unique, according to the Jordan-Hölder theorem.) Also, the subgroups generated sometimes have more generators than necessary, so you might want to “study” each subgroup carefully by checking properties like its order.
An interesting example is:
DihedralGroup(105).composition_series()
The output will be a list of 5 subgroups of \(D_{105}\), each a normal subgroup of its predecessor.
Several other series are possible, such as the derived series. Use tab-completion to see the possibilities.
Conjugacy#
Given a group \(G\), we can define a relation \(\sim\) on \(G\) by: for \(a,b \in G\), \(a \sim b\) if and only if there exists an element \(g \in G\) such that \(gag^{-1} = b\).
Since this is an equivalence relation, there is an associated
partition of the elements of \(G\) into equivalence classes. For this
very important relation, the classes are known as “conjugacy
classes.” A representative of each of these equivalence classes can
be found as follows. Suppose G
is a permutation group, then
G.conjugacy_classes_representatives()
will return a list of
elements of $G$, one per conjugacy class.
Given an element \(g \in G\), the “centralizer” of \(g\) is the set \(C(g) = \{h \in G \mid hgh^{-1} = g\}\), which is a subgroup of \(G\). A theorem tells us that the size of each conjugacy class is the order of the group divided by the order of the centralizer of an element of the class. With the following code we can determine the size of the conjugacy classes of the full symmetric group on 5 symbols:
sage: G = SymmetricGroup(5)
sage: group_order = G.order()
sage: reps = G.conjugacy_classes_representatives()
sage: class_sizes = []
sage: for g in reps:
....: class_sizes.append(group_order / G.centralizer(g).order())
...
sage: class_sizes
[1, 10, 15, 20, 20, 30, 24]
This should produce the list [1, 10, 15, 20, 20, 30, 24]
which you
can check sums to 120, the order of the group. You might be able to
produce this list by counting elements of the group \(S_5\) with
identical cycle structure (which will require a few simple
combinatorial arguments).
Sylow subgroups#
Sylow’s Theorems assert the existence of certain subgroups. For
example, if \(p\) is a prime, and \(p^r\) divides the order of a group
\(G\), then \(G\) must have a subgroup of order \(p^r\). Such a subgroup
could be found among the output of the
conjugacy_classes_subgroups()
command by checking the orders of
the subgroups produced. The map()
command is a quick way
to do this. The symmetric group on 7 symbols, \(S_7\), has order
\(7! = 5040\) and is divisible by \(2^4 = 16\). Let’s find one example
of a subgroup of permutations on 4 symbols with order 16:
sage: G = SymmetricGroup(7)
sage: subgroups = G.conjugacy_classes_subgroups()
sage: list(map(order, subgroups))
[1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 8, 8, 8, 8, 8, 8, 8, 9, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 16, 18, 18, 18, 20, 20, 20, 21, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 36, 36, 36, 36, 40, 42, 48, 48, 48, 60, 60, 72, 72, 72, 72, 120, 120, 120, 120, 144, 168, 240, 360, 720, 2520, 5040]
The map(order, subgroups)
command will apply the order()
function to each of the subgroups in the list subgroups
. The
output is thus a large list of the orders of many subgroups (96 to be
precise). If you count carefully, you will see that the 49-th
subgroup has order 16. You can retrieve this group for further study
by referencing it as subgroups[48]
(remember that counting starts
at zero).
If \(p^r\) is the highest power of \(p\) to divide the order of \(G\), then
a subgroup of order \(p^r\) is known as a “Sylow \(p\)-subgroup.” Sylow’s
Theorems also say any two Sylow \(p\)-subgroups are conjugate, so the
output of conjugacy_classes_subgroups()
should only contain each
Sylow \(p\)-subgroup once. But there is an easier way,
sylow_subgroup(p)
will return one. Notice that the argument of the
command is just the prime $p$, not the full power \(p^r\). Failure to
use a prime will generate an informative error message.
Groups of small order as permutation groups#
We list here constructions, as permutation groups, for all of the groups of order less than 16.
---------------------------------------------------------------------------------------------
Size Construction Notes
---------------------------------------------------------------------------------------------
1 SymmetricGroup(1) Trivial
2 SymmetricGroup(2) Also CyclicPermutationGroup(2)
3 CyclicPermutationGroup(3) Prime order
4 CyclicPermutationGroup(4) Cyclic
4 KleinFourGroup() Abelian, non-cyclic
5 CyclicPermutationGroup(5) Prime order
6 CyclicPermutationGroup(6) Cyclic
6 SymmetricGroup(3) Non-abelian, also DihedralGroup(3)
7 CyclicPermutationGroup(7) Prime order
8 CyclicPermutationGroup(8) Cyclic
8 D1 = CyclicPermutationGroup(4)
D2 = CyclicPermutationGroup(2)
G = direct_product_permgroups([D1,D2]) Abelian, non-cyclic
8 D1 = CyclicPermutationGroup(2)
D2 = CyclicPermutationGroup(2)
D3 = CyclicPermutationGroup(2)
G = direct_product_permgroups([D1,D2,D3]) Abelian, non-cyclic
8 DihedralGroup(4) Non-abelian
8 QuaternionGroup() Quaternions, also DiCyclicGroup(2)
9 CyclicPermutationGroup(9) Cyclic
9 D1 = CyclicPermutationGroup(3)
D2 = CyclicPermutationGroup(3)
G = direct_product_permgroups([D1,D2]) Abelian, non-cyclic
10 CyclicPermutationGroup(10) Cyclic
10 DihedralGroup(5) Non-abelian
11 CyclicPermutationGroup(11) Prime order
12 CyclicPermutationGroup(12) Cyclic
12 D1 = CyclicPermutationGroup(6)
D2 = CyclicPermutationGroup(2)
G = direct_product_permgroups([D1,D2]) Abelian, non-cyclic
12 DihedralGroup(6) Non-abelian
12 AlternatingGroup(4) Non-abelian, symmetries of tetrahedron
12 DiCyclicGroup(3) Non-abelian
Also semi-direct product $Z_3 \rtimes Z_4$
13 CyclicPermutationGroup(13) Prime order
14 CyclicPermutationGroup(14) Cyclic
14 DihedralGroup(7) Non-abelian
15 CyclicPermutationGroup(15) Cyclic
----------------------------------------------------------------------------------------------
Acknowledgements#
The construction of Sage is the work of many people, and the group theory portion is made possible by the extensive work of the creators of GAP. However, we will single out three people from the Sage team to thank for major contributions toward bringing you the group theory portion of Sage: David Joyner, William Stein, and Robert Bradshaw. Thanks!


Student, Department of Computer Science & Engineering
Future Institute of Technology
Garia, Kolkata
Student, Department of Computer Science & Engineering
Future Institute of Technology
Garia, Kolkata
Student, Department of Computer Science & Engineering
Future Institute of Technology
Garia, Kolkata
Student, Department of Computer Science & Engineering
Future Institute of Technology
Garia, Kolkata
ayanh9674@gmail.com


To use this language, use the class "language-ruby".
# This is a comment
=begin
Multi-line
comment
=end
"foo \"bar\" baz"
'foo \'bar\' baz'
/foo?[ ]*bar/
$foo = 5;
class InstTest
def set_foo(n)
@foo = n
end
def set_bar(n)
@bar = n
end
end
mystring = :steveT;
"foo #{'bar'+my_variable}"
There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. However, Prism dares to be open and honest about them. If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
#{my_var}
=begin
************************
This is a comment block
************************
=end


Interested in having your donation matched?
Did you know many companies offer matching gift programs to encourage philanthropy among their employees? Your company, your spouses’ company, or even a company you are retired from may match your gift!
Contributions of any amount help us provide meals and support for vulnerable seniors in Illinois.
Use the search field to see if your employer participates in a matching gift program. By simply completing a matching gift form (online or paper), you may be able to bouble, or even triple, the impact of your gift!


Watch Vega visualizations come to life
Enter a Vega specification on the left; an JavaScript function (that takes a Vega visualization object as an argument) in the middle; and either a JSON object describing a Vega dataset, or a JavaScript function that returns one, on the right (you can skip the JavaScript function and the dataset if you like). Or just load one of the many pre-cooked examples. Then hit the compile button and watch as the visualization pops in.


# -*- coding: utf-8 -*-
"""
The functions in this module are related to tribology in general.
"""
from math import sqrt, acos, cos, sin, pi, floor
import numpy as np
[docs]def profrolleriso(x_axis, diam, length):
"""
Generate a roller profile according to DIN 26281 for rollers with
:code:`length` :math:`\\leq` :code:`2.5` :math:`\\cdot` :code:`diam`.
Parameters
----------
x_axis: ndarray
The x-axis of the roller. The origin of the axis must be at the center
of the roller. To obtain sensible results, the axis limits must be
within :code:`+/- length / 2`.
diam: scalar
The diameter of the roller.
length: scalar
The length of the roller.
Returns
-------
x_profile: ndarray
The profile heights of the roller along :code:`x_axis`.
"""
len_ax = abs(max(x_axis) - min(x_axis))
if len_ax == length:
ax_x = x_axis[1:-1]
else:
ax_x = x_axis
prof = 0.00035 * diam * np.log(1 / (1 - np.power(((2 * ax_x) / length), 2)))
prof += np.min(prof)
if len_ax == length:
diam_arr = np.asarray([diam])
x_profile = np.concatenate((diam_arr, np.concatenate((prof, diam_arr))))
else:
x_profile = prof
return x_profile
[docs]def profball(x_axis, r_ball):
"""
Create a 1D ball profile along a central axis.
Parameters
----------
x_axis: ndarray
The coordinate points for which to calculate profile heights. Minimum
and maximum value must be within +/- **r_ball**.
r_ball: scalar
The radius of the ball.
Returns
-------
prof_heights: ndarray
The profile heights along the **x_axis**.
"""
prof = np.array(abs(r_ball) - np.sqrt(r_ball ** 2 - np.power(x_axis, 2)))
prof_heights = prof * np.sign(r_ball)
return prof_heights
[docs]def profrevolve(prof_1d, y_axis, y_diam):
"""
Create a 2D surface (profile heights) by revolving a 1D profile around a
central axis.
Parameters
----------
prof_1d: ndarray
The profile heights along the central (x) axis of the surface.
y_axis: ndarray
The y-axis of the surface.
y_diam: scalar
The maximum diameter of the surface along its y-axis.
Returns
-------
prof_2d: ndarray
The surface heights of the profile. The array size is
:code:`len(prof_2d)` :math:`\\times` :code:`len(y_axis)`
y_profile: ndarray
The profile heights along the y-direction of the surface at the central
element of the x-axis.
"""
len_x = len(prof_1d)
len_y = len(y_axis)
prof_2d = np.zeros((len_x, len_y))
sign_diam = np.sign(y_diam)
for i_x in range(len_x):
for i_y in range(len_y):
bracket = pow((y_diam / 2 - sign_diam * prof_1d[i_x]), 2)\
- pow(y_axis[i_y], 2)
if bracket <= 0:
prof_2d[i_x, i_y] = abs(y_diam) / 2
else:
prof_2d[i_x, i_y] = abs(y_diam) / 2 - sign_diam * sqrt(bracket)
if y_diam > 0:
min_prof = prof_2d.min()
else:
min_prof = prof_2d[round(len_x / 2) - 1, round(len_x / 2) - 1]
prof_2d = (prof_2d - min_prof)
y_profile = prof_2d[:, floor(len_y / 2)]
return prof_2d, y_profile
[docs]def vslide(vel_1, vel_2):
"""
Calculate the sliding speed in a tribological contact based on contact body
velocities.
Parameters
----------
vel_1: ndarray, scalar
The contact velocity of body 1.
vel_2: ndarray, scalar
The contact velocity of body 2
Returns
-------
vel_slide: ndarray, scalar
The sliding velocity in the tribological contact.
"""
vel_slide = vel_1 - vel_2
return vel_slide
[docs]def vroll(vel_1, vel_2):
"""
Calculate the rolling speed in a tribological contact based on contact body
velocities.
Parameters
----------
vel_1: ndarray, scalar
The contact velocity of body 1.
vel_2: ndarray, scalar
The contact velocity of body 2
Returns
-------
vel_roll: ndarray, scalar
The rolling velocity in the tribological contact.
"""
vel_roll = (vel_1 + vel_2) / 2
return vel_roll
[docs]def srr(vel_1, vel_2):
"""
Calculate the slide-to-roll ratio (SRR) in a tribological contact based on
contact body velocities.
Parameters
----------
vel_1: ndarray, scalar
The contact velocity of body 1.
vel_2: ndarray, scalar
The contact velocity of body 2
Returns
-------
srr: ndarray, scalar
The slide-to-roll ratio in the tribological contact.
"""
val_srr = vslide(vel_1, vel_2) / vroll(vel_1, vel_2)
return val_srr
[docs]def radpersec2rpm(vel_rad_per_sec):
"""
Convert velocity from rotations per minute (rpm) to radians per second
(rad/s).
Parameters
----------
vel_rad_per_sec: ndarray, scalar
The velcity in radians per second.
Returns
-------
vel_rpm: ndarray, scalar
The velocity in rotations per minute.
"""
vel_rpm = 1 / rpm2radpersec(1 / vel_rad_per_sec)
return vel_rpm
[docs]def rpm2radpersec(vel_rpm):
"""
Convert velocity from radians per second (rad/s) to rotations per minute
(rpm).
Parameters
----------
vel_rpm: ndarray, scalar
The velcity in rotations per minute.
Returns
-------
vel_rad_per_sec: ndarray, scalar
The velocity in radians per second.
"""
vel_rad_per_sec = vel_rpm / 60 * 2 * pi
return vel_rad_per_sec
[docs]def rball3plates(r_ball, plate_angle=1.5708):
"""
Calculate the sliding radius (lever arm) for a ball-on-3-plates test setup.
Parameters
----------
r_ball: ndarray, scalar
The radius of the ball.
plate_angle: ndarray, scalar, optional
The plate angle in radians, measured with respect to the rotational
axis of the ball. Default value corresponds to 45 degree.
Returns
-------
r_slide: ndarray, scalar
The sliding radius.
"""
r_slide = r_ball * np.sin((pi - plate_angle) / 2)
return r_slide
[docs]def fball3plates(ax_force, plate_angle=1.5708):
"""
Calculate the normal force per contact in ball-on-3-plates setup.
Parameters
----------
ax_force: ndarray, scalar
The force acting along the rotational axis of the ball (axial force).
plate_angle: ndarray, scalar, optional
The plate angle in radians, measured with respect to the rotational
axis of the ball. Default value corresponds to 45 degree.
Returns
-------
norm_force:
The normal force acting in each ball-plate contact.
"""
norm_force = ax_force / 3 / np.cos(plate_angle / 2)
return norm_force
[docs]def gfourball(r_1, r_2):
"""
Geometric parameters of 4-ball setup
Parameters
----------
r_1 : scalar
The radius of the rotating ball.
r_2 : scalar
The radius of the (a) stationary ball.
Returns
-------
sliding_radius : scalar
The sliding radius (lever arm) on the rotating ball.
contact_angle : scalar
Contact angle between direction of ball normal force and vertical axis.
"""
r_circum_circle = sqrt(3) / 3 * 2 * r_2
contact_angle = acos(r_circum_circle / (r_1 + r_2))
sliding_radius = r_circum_circle - r_2 * cos(contact_angle)
return sliding_radius, contact_angle
[docs]def ffourball(r_1, r_2, ax_force):
"""
Calculate the normal force per contact in a 4-ball test setup.
Parameters
----------
r_1:
The radius of the rotating ball.
r_2:
The radius of the stationary balls.
ax_force:
The force acting along the rotational axis of the rotating ball.
Returns
-------
norm_force: ndarray, scalar
The normal force in a single ball-ball contact.
"""
_, contact_angle = gfourball(r_1, r_2)
norm_force = ax_force / sin(contact_angle) / 3
return norm_force
[docs]def refix(val, p_in="", p_out=""):
"""
Convert between different SI unit prefixes. Available options are:
:code:`'T'` Terra
:code:`'G'` Giga
:code:`'M'` Mega
:code:`'k'` Kilo
:code:`'m'` Milli
:code:`'mu'` Micro
:code:`'n'` Nano
:code:`'p'` Pico
Parameters
----------
val: scalar
The value for which to convert the unit prefix.
p_in: string, any of the above, optional
The current prefix of :code:`val`. If :code:`p_in` is undefined,
:code:`val` has no SI unit prefix.
p_out: string, any of the above, optional
The prefix of :code:`val_refix` after the conversion. If :code:`p_in`
is undefined, :code:`val_refix` has no SI unit prefix.
Returns
-------
val_refix: scalar
The value in units of prefix :code:`p_out`.
"""
prefix = {
'p': 10 ** -12,
'n': 10 ** -9,
'mu': 10 ** -6,
'm': 10 ** -3,
'': 10 ** -0,
'k': 10 ** 3,
'M': 10 ** 6,
'G': 10 ** 9,
'T': 10 ** 12
}
val_refix = val * prefix[p_in] / prefix[p_out]
return val_refix
if __name__ == "__main__":
pass


Providing online support for doctors, clinicians, nurses, health professionals and the public.
Please submit all enquiries using the form below:


All forms follow several simple rules.
Form hints exist to help give more information about the inputs they are attached to. They should be directly preceded by the input in which they describe.
Hints have two states. The default state is established by the
go-hint
class.
All inputs have three basic states.
The default state is established by the go-form__input
class on text based inputs.
The disabled state can be achieved by the addition of the
disabled
attribute,
while the error state can be applied by the addition of the
go-form__input--error
modifier class.
An input with an error modifier should be followed by an error hint describing why it is in such a state.
If there is an instance where an individual label or input
needs to be displayed on top of a dark background the
--dark
modifiers
can be added.
.go-form__label--dark
- To apply the dark theme styles to a label
.go-form__input--dark
- To apply the dark theme styles to an input
Similar to the input element, the default state of select boxes are established
by the go-form__select
class.
The disabled state can be achieved by the addition of the
disabled
attribute, while the error state can be applied by the addition of the
go-form__select--error
modifier class.
A select box with an error modifier should be followed by an error hint describing why it is in such a state.
If there is an instance where an individual label or select
box needs to be displayed on top of a dark background the
--dark
modifiers
can be added.
.go-form__label--dark
- To apply the dark theme styles to a label
.go-form__select--dark
- To apply the dark theme styles to the select box
Similar to the input element, the default state of check boxes and radio buttons
are established by the go-form__checkbox
class.
These types of inputs often appear in groups and should always be wrapped in a
fieldset
element with an additional
legend
element describing the choice
that is being made.
The disabled state can be achieved by the addition of the
disabled
attribute to the parent
fieldset
, while the error state can be applied by the addition of the
go-form__select--error
modifier class to the same element.
A input with an error modifier should be followed by an error hint describing why it is in such a state.
If there is an instance where an individual label or fieldset
needs to be displayed on top of a dark background the
--dark
modifiers
can be added.
.go-form__label--dark
- To apply the dark theme styles to a label
.go-form__fieldset--dark
- To apply the dark theme styles to the fieldset
Dark forms are mostly like the default forms with a few alterations based on the state of the input. Labels and text show up as a light color so they are legible on a dark background. When the input is in a disabled state, the input will darken slightly to better portray itself as such.
The dark form effect can be achieved in one of two ways.
Generally speaking we will have a whole form that we need
to make dark. In this case, we can simply add the
.go-form--dark
modifier class to the surrounding form element.
There might be cases, however, where individual inputs are
not contained within a form element. The dark input styles
can be applied to individual elements by adding the
--dark
modifier to any individual element as well. See documentation
above for individual examples of how to implement dark forms.
One of the most common use cases of a dark form is when forms are being displayed in the off canvas.
Below is an example of all of the pieces working together. This includes a good example of how to use the grid system in conjunction with the form inputs to create a more robust layout.