abstract: We propose a new neural network architecture for automatic generation of missing characters in a Chinese font set. We call the neural network architecture the Variational Grid Setting Network which is based on the variational autoencoder (VAE) with some tweaks. The neural network model is able to generate missing characters relatively large in size ($256 \times 256$ pixels). Moreover, we show that one can use very few samples for training data set, and get a satisfied result.

author: Chuang, Yu-Neng
Department of Mathematical Sciences, National Chengchi University
Taipei, Taiwan
`firstname.lastname@example.com`; Huang, Zi-Yu
Institute of Industrial Engineering, National Taiwan University
Taipei, Taiwan
`email@example.com`; Tsai, Yen-Lung
Deptartment of Mathematical Sciences, National Chengchi University
Taipei, Taiwan
`firstname.lastname@example.com`
title: Variational Grid Setting Network

# Introduction

Chinese characters are abstractly aesthetic glyphs and usually considered as the most complex ones among all the other language characters. Creating Chinese fonts is a time-consuming task. We propose a new neural network architecture, the *Variational Grid Setting Network* (VGSN), to generate missing Chinese characters from a Chinese font set.

Our model is based on the variational autoencoder (VAE). The key differences between our model and the original VAE are we add a special layer which we called the *grid setting layer* in the end, to generate large image ($256 \times 256$ pixels) of Chinese characters. Moreover, we modified the loss function to gain the best results.

The scenario is as follows: Font A has complete Chinese characters, at least the one we want, and Font B has some missing characters which we would like to get automatically from Font A. We pair some characters that are available in both Font A and Font B as the training dataset. After that, we put the one which is missing in font B but available in Font A into our network, and (hopefully) get the character in the style of font B.

Somewhat surprising observation is that we just need very few samples to generate a character image we desire. In our experiments, usually $5$ examples will be sufficient and we can get a high quality image. As a result, our model runs relatively fast so it has potential to help professional typographers to design new Chinese fonts.

# Architecture

This model mainly contains three parts. The first part of our architecture is the encoder which task is to get the feature of Asian characters, that is, given the image of character with dimension (h, w), find the latent vector of there feature. We use neural network with input layer format as (batch size, height of image, width of image, channel of image), and output layer of the size two, (mean, variation). This part uses $6$ convolution layer with the ReLU as activation function, $6$ batch normalization layer, a fully connect layer to generating basis, and two separate fully connect layer to calculate the latent basis and get the latent vector.
The second part is our grid setting layer which contains dense layer and reshape layer. This part will split the original image into separate partition. The dense layer use to amplify the latent vector for each partition, and the reshape layer use to setting the grid line format.
The final part is the decoder which need to generating the image of each partition and combiming them. This part uses $5$ convolution transpose layer with the ReLU as activation function and same padding, $5$ batch normalization layer to generating the image. And final output layer use a convolution transpose layer with only $1$ kernel to compile partitions together.

## Latent basis calculation

As above, when we estimate the latent vector, we need to calculating the latent basis, respectively. Since the first part of our neural network reduction high dimension of original image, the basis value become critical when we need to decode these digit. In order to preserve the continuous property of basis, we use Gaussian normal distribution to get the feature of encoder. Then, we times the result of probability distribution with exponential of power of encoder variation and plus a mean of encoder which is more effective than the latent basis of conventional VAE. That is,
$$\mu+\exp^{\sigma}\times\frac{1}{{ \sqrt {2\pi } }}e^{{{ - {x} ^2 } \mathord{\left/ {\vphantom {{ - 2\sigma ^2 } }} \right. \kern-\nulldelimiterspace} {2 }}}$$

where $\mu$ is the mean of encoder, and the $\sigma$ is the variational of encoder.

## Traing algorithm

For training, the encoder use standard back-propagation algorithm. Subsampling of these feature is modified the traditional convolution neural network architecture from \[2\]. Since Asian characters is continuous in lots of region, adding some strides and changing number of kernel is used to preserve the properties and reduce the parameter. To accelerating network training in normalization, our normalizing layer based on \[3\] which reducing internal covariate shift.

After calculating latent basis, two dimension vector, called latent vector and denoted by $[\sigma ,\mu]$, generates new probability distribution. And the normalization is ensured by the sigmoid. Then we set the grid in our model,and we use 4$\times$ 4 and 8$\times$`<!-- -->`{=html}8 as experiment. We add some dense layer to preserve of probability distribution.

The decoder is based on the deconvolution neural network \[4\], and we add strides as same in encoder for symmetry. As well the same number of batch normalization layer.

When we train the model, our batch size cannot choose too large (we choose $32$ in most cases ), since the range of result need to same as domain. In order to avoid over-fitting, we need to shuffle the input data in each epoch.

# Experiment

We use some open source data (like Source-Han-Sans and Source-Han-Serif) for our learning model. In our experiment, we generate those character in high dimensional graph and transfer the font style if we choose another one as feature. Two modes of grid setting are used, one is 4$\times$ 4 grid and another is 8$\times$ 8 grid, which means a 256$\times$`<!-- -->`{=html}256 image are split up into $16$ and $64$ parts where the latent vectors are trained respectively.

Given the learned models and mode, we propose three types of optimization methods: Stochastic Gradient Descend (SGD), Adaptive Moment Estimation (Adam) and RMSprop. To make sure we reduce the training time, we also test the traditional VAE, and we can discover that VGSN is faster than traditional one while generating same image in one epoch.

Table 1 and Table 2 show that VGSN trains much faster than the original VAE in same condition. Therefore, it shows that VGSN can handle the fast generating process and avoid overfitting simultaneously. And in Figure 2, we campare with VAE model which shows that VGSN is better than original VAE with grid setting layer. We use original VAE without grid setting layer at first, the outcome were all noise and overfitting. Therefore, we decide to use original VAE model to compare with VGSN.

|                                  |   SGD    |   Adam   | RMSprop  |
|:--------------------------------:|:--------:|:--------:|:--------:|
| 4$\times$`<!-- -->`{=html}4 grid | 87 sec.  | 96 sec.  | 95 sec.  |
| 8$\times$`<!-- -->`{=html}8 grid | 179 sec. | 177 sec. | 175 sec. |

                             Table 1: Time in original Variational Autoencoder

|                                  |   SGD    |   Adam   | RMSprop  |
|:--------------------------------:|:--------:|:--------:|:--------:|
| 4$\times$`<!-- -->`{=html}4 grid | 78 sec.  | 77 sec.  | 74 sec.  |
| 8$\times$`<!-- -->`{=html}8 grid | 148 sec. | 157 sec. | 154 sec. |

                                               Table 2: Time in VGSN

In terms of different model and optimizer for the training model, mean squared error is choosed as loss function to measure the loss in all combination of them. The results of losses plot as follows (Figure 3 and Figure 4). According to the following results, if we use Adam as our optimizer, the learning process will avoid being overfitting. In the case of SGD, the model learns slower because of early convergence. And if RMSprop is given as our optimizer, the model learns well at the early epoch of training process, but fail at the late epoch.

## Optimizer selection

In this work, we choose Source-Han-Sans and Source-Han-Serif as our data set within given three different optimizers and try to figure out which one takes the advantage of generating image.

First, given SGD as our optimizer, we realize that the radical part is certainly well-learning, but few of Chinese characters are somewhere fuzzy. And then given Adam as our optimizer, the main structure is clear, and side area are less fuzzy than SGD. Last, given RMSprop as our optimizer. Although main structure is clear and recognizable, some grid edges are not well-connected and some detail are missing.

In conclusion, no matter which grid we set, Adam plays an essential role. Viewing those outcome(Figure 4 and Figure 5), Adam might not only be the fastest one, but it makes our model to learn more efficient than other two optimizers.

## Grid setting selection

In order to figure out which grid setting performs well, we choose Source-Han-Sans and Source-Han-Serif as our data set within fixing the optimizers.

First, fixed the optimizer, although the main part in both grids are nearly well-learning, it seems that 4$\times$`<!-- -->`{=html}4 grid still has grid segment line, but 8$\times$`<!-- -->`{=html}8 grid did well on this part. Second, we can observe that 8$\times$`<!-- -->`{=html}8 grid solve the connected problem better than 4$\times$`<!-- -->`{=html}4 grid.

In conclusion, no matter which optimizer we used, 4$\times$`<!-- -->`{=html}4 grid is fuzzy at the edge area,and some details are lost at the connected side of each grid.

## Font transfer

In this work, we try to generate a style-transferred Chinese character by using two different font as our data set. Adam is selected as our optimizer and 8$\times$`<!-- -->`{=html}8 grid is chosen as our grid setting parameter. The results show in Figure 6 are transferred by taking Source-Han-Sans-J being our training data and using Source-Han-Serif-K being our testing set.

First, we train our model to learn the feature of $4$ characters of Source-Han-Sans-Japan, and then we apply the feature to generate the characters of Source-Han-Serif-Korean. Moreover, we also try to minimize our training data set and generate the Chinese characters those are not in the training set. Figure 6 shows the style transfer outcome of VGSN. In part a, we pick up the first four characters and generate the last character by training under our model.

In order to highlight our training data is not overlapping our testing data, Figure 6 also shows that we use two different fonts and choose the data randomly from our training font. Training data is announced as follows. The characters are automatically generated by VGSN and not the samples in original training data.

The pronunciation of following example characters in first three row of part a are qian, shan, fei and jue from left to right. In forth row of part a is niao. And in first three row of part b are yong, qin, zhi, she and he from left to right. In other rows from top to bottom are pang, yi, tao and kan.

# Conclusion

We introduce Variational Grid Setting Network (VGSN) in this paper. Our approach is that we can not only generate a high dimensional image within 256$\times$`<!-- -->`{=html}256 pixel through grid setting layer, but also can perform the style transfer between two different fonts by using very few samples.

According to the result of our experiment, we discover that if we choose Adam as our optimizers and 8$\times$`<!-- -->`{=html}8 grid as our grid setting, the outcome is more clear than the other 8 kinds of combination.

Furthermore, it is possible to use our model to deal with word missing problem. Due to the result of font transfer, we can generate the words which do not exist in the new font. Word selection is available and few training data is required in automatically generating the characters. Therefore, we can produce the high quality image of specific characters of rebuilding the missing characters. It surely benefits the typographers to reduce the time while designing new Chinese fonts in the future.


abstract: SIMBOL–X is a high energy "mini" satellite class mission that is proposed by a European collaboration for a launch in 2009. SIMBOL–X is making use of a classical X–ray mirror, of $\sim$ 600 cm$^2$ maximum effective area, with a 30 m focal length in order to cover energies up to several tens of keV. This focal length will be achieved through the use of two spacecrafts in a formation flying configuration. This will give to SIMBOL–X unprecedented spatial resolution (20 HEW) and sensitivity in the hard X–ray range. By its coverage, from 0.5 to 70 keV, and sensitivity, SIMBOL–X will be an excellent instrument for the study of high energy processes in a large number of sources, both compact and extended.
address: DSM/DAPNIA/Service d'Astrophysique, CEA/Saclay, F91191 Gif-sur-Yvette France.
author: Philippe Ferrando
title: SIMBOL–X, an X–ray telescope
  for the 0.5–70 keV range

# Scientific motivation

The study of the non thermal component in high energy astrophysics sources is presently hampered by the large gap in spatial resolution and sensitivity between the X–ray and $\gamma$–ray domains. Below $\sim$ 10 keV, astrophysics missions like XMM–Newton and Chandra are using focusing optics based on grazing incidence mirrors giving extremely good spatial resolution, down to 0.5 for Chandra, and sensitivity. This technique has however an energy limitation at $\sim$ 10 keV due to the maximum focal length that can fit in a single spacecraft. Hard X–ray and $\gamma$–ray imaging instruments, such as those on INTEGRAL, are relying on non focusing techniques which do not allow to reach spatial resolutions better than $\sim$ 10 arc minutes and yield much lower point source sensitivities than in low energy X–rays.

This transition of techniques unfortunately happens roughly at the energy above which the identification of a non thermal component is unambiguous with respect to thermal emission. Considered from the low energy side, this strongly limits the interpretation of the high quality X–ray measurements, and particularly that related to the acceleration of particles. Considered from the high energy side, this often renders impossible the identification of the source of the $\gamma$–ray emission.

The SIMBOL–X motivation is to elucidate the origin of the non thermal emission in accretion / acceleration astrophysical sites, both compact and extended, by offering a spatial resolution and a sensitivity of the "soft X–ray type" from 0.5 to up to $\sim$ 70 keV. With SIMBOL–X it will be possible to solve issues or make new advances on the physics of the accretion onto black holes (both of stellar mass with new capabilities regarding low luminosity states, and much more massive as SgrA\* or those in AGNs), on the high energy emission in jets both of quasars and micro-quasars, on the origin of the hot component at the centre of our Galaxy and in clusters of galaxies, on the particle acceleration in supernovae remnants, on magnetically active stars, or on the diffuse X–ray background in the energy range where its spectrum is peaking.

# Mission concept

SIMBOL–X is built on the classical design of a Wolter I optics focusing X–rays onto a focal plane detector system. The gain in maximum energy is achieved by having a focal length of 30 metres, *i.e.* 4 times that of XMM–Newton mirrors. Since this cannot fit in a single spacecraft, the mirror and the detectors will be flown on two separate spacecrafts, in a formation flying configuration, as sketched in Fig. . We shortly detail below each part of this system.

The focusing optics will be a nested shells Wolter I configuration mirror. Building on the experience acquired on Beppo–SAX, Jet–X, SWIFT, ABRIXAS and XMM–Newton mirrors, it will be made following the Nickel electroforming replication method (*e.g.* Citterio *et al.* 2001). The current design is to have a 108 shells mirror, with an outer diameter of 70 cm (like one XMM–Newton module), and an angular resolution of 20 arcseconds of Half-Energy-Width. The coating will be Pt, in order to increase the high energy response w.r.t. a more classical Au coating. The focal length will be 30 metres.

Figure shows the effective area as a function of energy, for the baseline design. It has roughly a constant value of 600 cm$^2$ up to about 35 keV, before starting to decrease and fall below one cm$^2$ above more than 70 keV. The field of view will be of 6 arcminutes at 50 % vignetting.

The focal plane detector system will be a 6 cm diameter spectro-imager with 500 $\mu$m of maximum pixel size (to provide an oversampling of the mirror PSF) with a "reasonable" spectral resolution below 10 keV for measuring lines, particularly that of Iron, and a 100 % efficiency at high energy. Since this cannot be given by a single detector, the focal plane will combine a low energy detector, stopping photons up to $\sim$ 15 keV, directly on top of high energy detector. This is completed by an optical blocking filter, and an active anticoincidence shield. The best option for the low energy detector today is a DEPFET based APS (*e.g.* Holl 2002) which operates at room temperature, but thick depletion CCDs would also fit SIMBOL–X requirements. These detectors are currently under tests in the MPE Garching and Leicester University. The high energy detector will consist in 2 mm thick CdZnTe pixellated arrays (*e.g.* Limousin 2002) currently under tests in CEA/SAp.

Both mirror and detector spacecrafts will be of the "mini-satellite" class (500 kg max). To keep a constant image quality requires the following constraints on the spacecraft relative positionning : i) their distance must be kept constant within 1 cm, ii) their positionning perpendicular to the optical axis must be kept within 1 cm, and monitored with a 0.5 mm accuracy, and iii) the angular stability must be better than 1 arcmin, and monitored to 3 arcsec. In order to minimize the differential forces between the 2 spacecrafts, as well as to allow uninterrupted observations of variable sources, SIMBOL–X will be put in orbit around L2.

# Sensitivity

Figure  presents the SIMBOL–X sensitivity to point sources, or equivalently to diffuse emission on a 1 arcmin diameter scale, compared to other instruments. SIMBOL–X curve was derived using the background spectrum of Ramsey (2001) for the HXT CdZnTe detector envisionned for Constellation X (also at L2 position), and a model of the astrophysical diffuse background. As expected for an X–ray focusing telescope, the SIMBOL–X sensitivity curve has roughly the shape of the XMM–Newton and Chandra curves (which have no diffuse background component here) but is displaced by about a decade in energy. SIMBOL–X is $\sim$ 100 times better than existing instruments in the 10 to 35 keV range, and has a sensitivity equivalent to INTEGRAL/IBIS at $\sim$ 70 keV.

We have also used this background model to simulate a number of observations that cannot be detailed here. We simply mention two examples to illustrate the SIMBOL–X sensitivity. On the supernovae remnant side, a detailed map of Cas A above 20 keV can be done in 100 ksec, and the spectrum of its brightest 1 arcmin$^2$ part is significant up to 50 keV. On the AGN jet side, the spectrum of the Pictor A hot spot at 4 arcmin from the nucleus (well isolated with SIMBOL–X optics) can be significantly measured up to 40 keV in 50 ks of observation.

# Collaboration and schedule

SIMBOL–X is a collaboration between France (CEA/Saclay, PI Institute, and the Grenoble and Meudon observatories), Italy with Brera Observatory, Germany with MPE Garching, and United Kingdom with Leicester University.

As SIMBOL–X does not involve new difficult technological development neither on the detector side nor on the mirror side, and as the formation flying constraints are rather well within current investigations in this domain, a relatively short development time can be envisionned. Launching SIMBOL–X before the end of the decade would provide an excellent scientific preparation to the much larger observatories Constellation X and XEUS that are scheduled later.

SIMBOL–X has been presented to the Astrophysics group of CNES, the french space agency, with a proposed launch date of early 2009. It has been recommanded in June 2002 for a phase A study.


abstract: Serverless architectures organized around loosely-coupled function invocations represent an emerging design for many applications. Recent work mostly focuses on user-facing products and event-driven processing pipelines. In this paper, we explore a completely different part of the application space and examine the feasibility of analytical processing on big data using a serverless architecture. We present Flint, a prototype Spark execution engine that takes advantage of AWS Lambda to provide a pure pay-as-you-go cost model. With Flint, a developer uses PySpark exactly as before, but without needing an actual Spark cluster. We describe the design, implementation, and performance of Flint, along with the challenges associated with serverless analytics.
author: Youngbin Kim and Jimmy Lin
David R. Cheriton School of Computer Science
University of Waterloo
Waterloo, Ontario, Canada
{youngbin.kim,firstname.lastname@example.com
title: Serverless Data Analytics with Flint

# Introduction

Serverless computing  represents a natural next step of the "as a service" and resource sharing trends in cloud computing. Specifically, "function as a service" offerings such as AWS Lambda allow developers to write blocks of code with well-defined entry and exit points, delegating all aspects of execution to the cloud provider. Typically, these blocks of code are stateless, reading from and writing to various "state as a service" offerings (databases, message queues, persistent stores, etc.).

Standard serverless deployments are characterized by asynchronous, loosely-coupled, and event-driven processes that touch relatively small amounts of data . Consider a canonical example that Amazon describes: an image processing pipeline such that when the user uploads an image to a website, it is placed in an S3 bucket, which then triggers a Lambda to perform thumbnail generation. The Lambda may then enqueue a message that triggers further downstream processing. Most serverless applications are user facing, even if users are not directly involved in the processing pipeline.

This paper explores serverless architectures for a completely different use case: large-scale analytical data processing by data scientists. We describe Flint, a prototype Spark execution engine that is completely implemented using AWS Lambda and other services. One key feature is that we realize a pure pay-as-you-go cost model, in that there are zero costs for idle capacity. With Flint, the data scientist can transparently use PySpark without needing an actual Spark cluster, instead paying only for the cost of running individual programs.

The primary contribution of our work is a demonstration that it is indeed possible to build an analytical data processing framework using a serverless architecture. Critically, we accomplish this using cloud infrastructure that has no idle costs. It is straightforward to see how workers performing simple "map" operations can execute inside Lambda functions. Physical plans that require data shuffling, however, are more complicated: Flint takes advantage of distributed message queues to handle shuffling of intermediate data, in effect offloading data movement to yet another cloud service.

# Background and Design Goals

Our vision is to provide the data scientist with an experience that is indistinguishable from "standard" Spark. The only difference is that the user supplies configuration data to use the Flint serverless backend for execution. In this context, we explore system performance tradeoffs in terms of query latency, cost, etc.

Currently, Flint is built on AWS, primarily using Lambda and other services. All input data to an analytical query are assumed to reside in an S3 bucket, and we assume that results are written to another S3 bucket or materialized on the client machine. The AWS platform was selected because it remains the most mature of the alternatives, but in principle Flint can be re-targeted as other cloud providers have similar offerings.

One major design goal of Flint is to provide a truly pay-as-you-go cost model with no costs for idle capacity. This needs a bit of explanation: as a concrete example, Amazon Relational Database Service (RDS) requires the user to pay for database instances (per hour). This is *not* pay as you go because there are ongoing costs even when the system is idle. Therefore, this means that one obvious implementation of using RDS to manage intermediate data would violate our design goal. In general, we cannot rely on any persistent or long-running daemons.

Note that this is a challenging, but also worthwhile, design goal. In a cloud-based environment, there are a limited number of options for Spark analytics. One option is to offload cluster management completely to a cloud provider via something like AWS EMR, which starts up a Spark cluster for each user job. The downside is that a lot of time is wasted in cluster initialization.

The alternative is to manage one's own Spark clusters in the cloud (on EC2 instances). There are, of course, tools to help with this, ranging from the UI of Databrick's Unified Analytics Platform to full-fledged orchestration engines such as Netflix's Genie. Even if cluster startup and teardown were completely automated (and instantaneous, let's even say), the fact remains that the organization pays for cluster instances for the entire time the cluster is up; charges accumulate even when the cluster is idle. For large organizations, this is less of an issue as there is more predictable aggregate load from teams of data scientists, but for smaller organizations, usage is far more sporadic and difficult to estimate a priori.

In contrast, we believe that serverless analytics with pay-as-you-go pricing is compelling, particularly for *ad hoc* analytics and exploratory data analysis. This is exactly what our Flint prototype provides.

# Flint Architecture

The overall architecture of Flint is shown in Figure . At a high-level, Spark tasks are executed in AWS Lambda, and intermediate data are held in Amazon's Simple Queue Service (SQS), which handles the data shuffling necessary to implement many transformations.

To maximize compatibility with the broader Spark ecosystem, Flint reuses as many existing Spark components as possible. When a Spark job is submitted, the sequence of RDD transformations (i.e., the RDD lineage) is converted into a physical execution plan using the DAG Scheduler. The physical plan consists of a number of stages, and within each stage, there is a collection of tasks. The Task Scheduler is then responsible for coordinating the execution of these tasks. Spark provides pluggable execution engines via the `SchedulerBackend` interface: Spark by default comes with implementations for local mode, Spark on YARN and Mesos, etc. Flint provides a serverless implementation of `SchedulerBackend`; everything else remains unchanged from standard Spark. The primary advantage of this design is that we can reuse existing Spark machinery for query planning and optimization, and Flint only needs to "know about" Spark execution stages and tasks in the physical plan.

The Flint `SchedulerBackend` (hereafter "scheduler"), which lives inside the Spark context on the client machine, is responsible for coordinating Flint executors to execute a particular physical plan. The scheduler receives tasks from Spark's Task Scheduler, and for each task, our implementation extracts and serializes the information that is needed by the Flint executors. This information includes the serialized code to execute, metadata about the relationship of this task to the entire physical plan, and metadata about where the executor reads its input and writes its output. When this serialization is complete, the scheduler asynchronously launches the Flint executors on AWS Lambda, with the serialized task as part of the request. After a Flint executor has completed its task, the scheduler processes the response. Once all tasks of the current stage complete, executors for tasks of the next stage are launched, repeating until the entire physical plan has been executed.

## Flint Executor

A Flint executor is a process running inside an Amazon Lambda function that executes a task in a Spark physical plan. Since the startup latency of a Lambda invocation is small once the function has been "warmed up" (more discussion later), each Lambda instance only processes a single task. This is different from standard Spark, where executors are long-running processes.

Once a Flint executor is initialized, it first deserializes the task information from the request arguments. From the input partition metadata, the executor creates an input iterator to read from the appropriate input partition. For the first stage in a plan, this iterator will fetch a range of bytes from an S3 object. For most other stages, the input iterator will fetch from a designated SQS queue (discussed in detail below).

Once the input iterator is ready, it is passed to the deserialized function (i.e., code to execute) from the task as an argument; this yields the output iterator. If the task is in the final (result) stage of the execution plan, there are two possibilities: If the final action on the RDD is `saveAsTextFile`, outputs are materialized to another S3 bucket; otherwise, the results are materialized within the executor and passed back to the scheduler (for example, if the data scientist calls the `collect` action).

When a task is part of an intermediate stage, the execution plan requires the output to be shuffled so that all values for a key are placed in the same partition. The shuffling is part of the physical plan created by Spark; the Flint executors simply execute the task, and thus are not explicitly aware of the actual RDD transformation (e.g., if the shuffling is part of `reduceByKey` or `join`, etc.). Since the execution time of a Lambda invocation has a limit of 300 seconds, it is not possible to guarantee that the Flint executors from the previous stage are still alive to pass data to executors running tasks from the next stage. Thus, we need some external data store to deliver the intermediate output. Flint uses Amazon's Simple Queue Service (SQS) for this purpose.

Once an executor of a task belonging to an intermediate stage has computed the output iterator, the hash partition function (or custom partition function if specified) is used to decide which partition each output object will be assigned to. The executor groups objects by the destination partition in memory. However, if memory usage becomes too high during this process, the executor flushes its in-memory buffers by creating a batch of SQS messages and sending them to the appropriate queue for each partition. After all output data are sent to SQS queues, the executor terminates and returns a response containing a variety of diagnostic information (e.g., number of messages, SQS calls, etc.).

Once all tasks of the current stage are completed, executors for tasks in the next stage will be launched. These executors read from their corresponding SQS queues and aggregate data in memory. Results are passed to the iterator of the function associated with the task, as described earlier. Since we are using in-memory data structure for aggregation, memory forms a bottleneck. Due to the complexities of implementing on-disk multi-pass aggregation algorithms in the Lambda environment, we currently address this problem by increasing the number of partitions such that we do not overflow memory. This solution appears to be adequate, since it takes advantage of the elasticity provided by AWS Lambda.

Queue management is performed by the scheduler. Before the execution of each stage, the scheduler initializes the necessary partitions. Partition metadata (i.e., source and destination queues) are passed as part of the Lambda request. The scheduler also handles cleanup.

## Overcoming Lambda Limitations

The current Flint implementation supports PySpark, which counter-intuitively is easier to support than Scala Spark. The Flint `SchedulerBackend` on the client is implemented in Java, but the Flint executors in AWS Lambda are implemented in Python. This design addresses one of the biggest issues with AWS Lambda: the long cold startup time of function invocations. The first time that a Lambda is invoked (or after some idle period), AWS needs to provision the appropriate runtime container. Java Lambdas tend to have large deployment packages due to numerous dependencies, whereas Python Lambdas are significantly more lightweight; thus, they start up faster. Furthermore, in the default Spark executor implementation, to run PySpark code, data (from S3) is first read in the JVM and then passed to a Python subprocess using pipes. In Flint, we bypass this extra wrapper layer, and Python code is able to read from S3 directly. As we later show, this has significant performance advantages.

Another limitation of AWS Lambda is that execution duration per request is capped at 300 seconds. This leads to the failure of long-running tasks. In order to avoid this problem, we chain executors: if the running time has almost reached the limit, the Flint executor stops ingesting new input records. Then, the current state, including how much of the input split has been read, is serialized and returned to the scheduler, which launches a new Flint executor to continue processing the uncompleted input split from where the previous invocation left off. Since the function is already warm, the cost of using chained executors is relatively low.

A third limitation of Lambda comes from a number of resource constraints. Each invocation is limited to a maximum memory allocation of 3008 MB. Thus, it is important for the Flint executor to carefully manage in-memory data. There is a limitation of 6 MB on the size of the request payload for an invocation. This payload is used to hold the serialized task data, which is typically much smaller. However, for larger tasks we are currently implementing a workaround for this size restriction by splitting the payload into smaller pieces. These can be uploaded to S3, and the scheduler can direct the Lambda functions to fetch the relevant data to complete initialization.

# Experimental Evaluation

```latex
\begin{table*}[t]\begin{center}
\begin{tabular}{|l|p{2cm}|p{1.25cm}|p{1.25cm}||p{1.25cm}|p{1.25cm}|p{1.25cm}|}
\hline
 & \multicolumn{3}{c||}{Query Latency (s)} & \multicolumn{3}{|c|}{Estimated Cost (USD)} \\
\cline{2-7}
\textbf{} & \textbf{Flint} & \textbf{PySpark}  & \textbf{Spark}  & \textbf{Flint} & \textbf{PySpark}  & \textbf{Spark} \\
\hline
\hline
0 & 101 [93 - 109] & 211 & 188 & 0.20 & 0.41 & 0.37  \\
1 & 190 [186 - 197] & 316 & 189 & 0.59 & 0.61 & 0.37 \\
2 & 203 [201 - 205] & 314 & 187 & 0.68 & 0.61 & 0.36 \\
3 & 165 [161 - 169] & 312 & 188 & 0.48  & 0.61 & 0.36 \\
4 & 132 [122 - 142] & 225 & 189 & 0.33 & 0.44 & 0.37 \\
5 & 159 [142 - 177] & 312 & 189 & 0.45 & 0.60 & 0.37 \\
6 & 277 [272 - 281] & 337 & 191 & 0.56 & 0.66 & 0.37  \\
\hline
\end{tabular}
\vspace{0.2cm}
\caption{Query latency and cost comparisons.}
\label{tab:results}
\vspace{-0.7cm}
\end{center}
\end{table*}
```

We evaluated Flint by comparing its performance with a Spark cluster running the Databricks Unified Analytics Platform. The entire cluster comprises 11 m4.2xlarge instances (one driver and ten workers), with a total of 80 vCores (Amazon's computation unit) of processing capacity. For AWS Lambda, we allocated the maximum amount of memory possible, which is 3008 MB. The developer can also configure the maximum number of concurrent invocations; we set this to 80 to match the Spark cluster, under the assumption that one Lambda invocation roughly uses one vCore. AWS is not completely transparent about the instances running AWS Lambda; documentation refers to a "general purpose Amazon EC2 instance type, such as an M3 type" without additional details. Thus, this is the best that we can do to ensure that all conditions consume the same hardware resources. In all cases, we used the latest version of the Databricks runtime, which is based on Spark 2.3.

Our evaluations examined three different conditions: PySpark code running on Flint, PySpark code running on the Spark cluster, and equivalent Scala Spark code running on the Spark cluster. For the Spark cluster, we only measure query execution time (derived from the cluster logs) and do not include startup costs of the cluster (around five minutes). This puts Spark performance in the best possible light. We had separately examined Amazon EMR, which initializes clusters automatically per job—but for reasons unknown from available documentation, its performance (even excluding startup costs) was significantly worse than a Spark cluster we provisioned ourselves.

For evaluation, we considered a typical exploratory data analysis task described in a popular blog post by Todd Schneider . The New York City Taxi & Limousine Commission has released a detailed historical dataset covering approximately 1.3 billion taxi trips in the city from January 2009 through June 2016. The entire dataset is stored on S3 and is around 215 GB. Each record contains information about pick-up and drop-off date/time, trip distance, payment type, tip amount, etc. Inspired by Schneider's blog post, we evaluated the following queries, some of which replicate his analyses:

Line count. In this query, we simply counts the number of lines in the dataset. This evaluates the raw I/O performance of S3 under our experimental conditions.

Taxi drop-offs at Goldman Sachs headquarters, 200 West St. This query filters by geo coordinates and aggregates by hour, as follows:

```
arr = src.map(lambda x: x.split(',')) \
    .filter(lambda x: inside(x, goldman)) \
    .map(lambda x: (get_hour(x[2]), 1)) \
    .reduceByKey(add, 30) \
    .collect()
```

This is exactly the query issued in PySpark to both Flint and the Spark cluster. The Scala Spark condition evaluates exactly the same query, except in Scala. Note that Flint is able to support UDFs transparently.

For brevity, we omit code for the following queries and instead provide a concise verbal description.

Same query as above, but for Citigroup headquarters, at 388 Greenwich St.

Goldman Sachs taxi drop-offs with tips greater than \$10. Who are the generous tippers?

Cash vs. credit card payments. This query computes the proportion of rides paid for using credit cards, aggregated monthly across the dataset.

Yellow taxi vs. green taxi. This query computes the number of different taxi rides, aggregated by month.

Effect of precipitation on taxi trips, i.e., do people take the taxi more when it rains? This query aggregates rides for different amounts of precipitation.

Table  reports latency (in seconds) and estimated cost of each query (in USD) under the three different experimental conditions discussed above. For Flint, we report averages over five trials (after warm-up) and show 95% confidence intervals in brackets. The latency of PySpark and Spark exhibit little variance, and thus we omit confidence intervals (over three trials) for brevity. Estimated costs for Spark and PySpark are computed as the query latency multiplied by the per-second cost of the cluster. For Flint, we used logging information to compute the execution duration of the AWS Lambdas and the associated SQS costs.

We find that latency is roughly the same for all queries on Spark and appears to be dominated by the cost of reading from S3. This is perhaps not surprising since none of our test queries are shuffle intensive, as the number of intermediate groups is modest. Interestingly, for some queries, Flint is actually faster than Spark. The explanation for this can be found in Q0, which simply counts lines in the dataset and represents a test of read throughput from S3. Evidently, the Python library that we use (boto) achieves much better throughput than the library that Spark uses to read from S3. This is confirmed via microbenchmarks that isolate read throughput from a single EC2 instance. In our queries, the performance of Flint appears to be dependent on the number of intermediate groups, and this variability makes sense as we are offloading data movement to SQS. PySpark is much slower than Flint because every input record passes from the JVM to the Python interpreter, which adds a significant amount of overhead. In terms of query costs, Flint is in general more expensive than Spark, even for queries with similar running times (Flint has additional SQS costs). Although a direct cost conversion between Lambda and dedicated EC2 instances is difficult (the actual instance type and the multiplexing mechanism are both unknown), it makes sense that Lambda has a higher per-unit resource cost, which corresponds to the price we pay for on-demand invocation, elasticity, etc.

For the above reasons, it is difficult to obtain a truly fair comparison between Flint and Spark. Nevertheless, our experiments show that serverless analytics is feasible, though a broader range of queries is needed to tease apart performance and cost differences—for example, large complex joins, iterative algorithms, etc. However, results do suggest that data shuffling is a potential area for future improvement.

# Related Work

The origins of Flint can be traced back to a course project at the University of Waterloo in the Fall of 2016. Since then, there have been other attempts at exploring serverless architectures for data analytics. In June 2017, Databricks announced a serverless product , best described as a more flexible resource manager: administrators define a "serverless pool" that elastically scales up and down. This can be viewed as more convenient tooling around traditional Spark clusters, and is not serverless in the sense that we mean here.

In November 2017, Qubole announced an implementation of Spark on AWS Lambda . This effort shares the same goals as Flint, but with several important differences. Qubole attempted to "port" the existing Spark executor infrastructure onto AWS Lambda, whereas Flint is a from-scratch implementation. As a result, we are better able to optimize for the unique execution environment of Lambda. For example, Qubole reports executor startup time to be around two minutes in the cold start case. In addition, Qubole's implementation uses S3 directly for shuffling intermediate data, which differs from our SQS-based shuffle. Using S3 allows Qubole's executors to remain more faithful to Spark, but we believe that the I/O patterns are not a good fit for S3.

Amazon provides two data analytics services that are worth discussing: Amazon Athena (announced November 2016) and Amazon Redshift Spectrum (announced July 2017). Both are targeted at more traditional data warehousing applications and only support SQL queries, as opposed to a general-purpose computing platform like Spark. Athena offers a pay-as-you-go, per-query pricing with zero idle costs, similar to Flint, but under the covers it uses the Presto distributed SQL engine for query execution, so architecturally it is not serverless. Redshift Spectrum is best described as a connector that supports querying over S3 data; the customer still pays for the cost of running the instances that comprise the Redshift cluster itself (i.e., per hour charge, even when idle).

PyWren  is another project advocating a serverless execution model for analytics tasks, although unlike our effort PyWren does not attempt to target Spark or any specific analytics framework. Since Flint is a Spark execution engine, it supports arbitrary RDD transformations; in contrast, PyWren examines only three classes of dataflow patterns: map-only, map + monolithic reduce, and MapReduce using either S3 or Redis for shuffling (the latter is not pay as you go).

Serverless computing in general is an emerging computing paradigm and previous work has mostly focused on examining system-level issues in *building* serverless infrastructure  as opposed to designing applications. Indeed, as Baldini et al.  write, the advantages of serverless architectures are most apparent for bursty, compute-intensive workloads and event-based processing pipelines. Data analytics represents a completely different workload and Flint opens up exploration in a completely different part of the application space.

# Future Work and Conclusions

There are a number of future directions that we are actively exploring. We have not been able to conduct an experimental evaluation between Qubole's implementation and Flint, but the design choice of using S3 vs. SQS for data shuffling should be examined in detail. Each service has its strengths and weaknesses, and we can imagine hybrid techniques that exploit the strengths of both.

Robustness is an issue that we have not explored at all in this work, although to some extent the point of serverless designs is to offload these problems to the cloud provider. Executor failures can be overcome by retries, but another issue is the at-least-once message semantics of SQS. Under typical operating circumstances, SQS messages are only delivered once, but AWS documentation explicitly acknowledges the possibility of duplicate messages. We believe that this issue can be overcome with sequence ids to deduplicate message batches, as the exact physical plan is known ahead of time.

Another ongoing effort is to ensure that higher-level Spark libraries (e.g., MLlib, SparkSQL, etc.) work with Flint. To the extent that `SchedulerBackend` provides a clean abstraction, in theory everything should work transparently. However, as every developer knows, abstractions are always leaky, with hidden dependencies. We are pushing the limits of our current implementation by iteratively expanding the scope of Spark libraries and features that we use.

To conclude, we note that Flint is interesting in two different ways: First, we show that big data analytics is feasible using a serverless architecture, and that we can coordinate the data shuffling associated with analytical queries in a restrictive execution environment. Second, there are compelling reasons to prefer using our execution engine over Spark's default, particularly for *ad hoc* analytics and exploratory data analysis: the tradeoff is a bit of performance for elasticity in a pure pay-as-you-go cost model. Thus, Flint appears to be both architecturally interesting as well as potentially useful.

# Acknowledgments

Flint traces back to a serverless analytics prototype called Iris developed as part of a course project at the University of Waterloo in Fall 2016 with Jonathan Ma, Ronak Patel, and Pranjal Shah. Although Flint does not share any code with Iris, we'd like to acknowledge these individuals for their contributions to early developments of the serverless concept.


abstract: We use the Type Ia Supernova *gold* sample to constrain the parameters of dark energy models namelly the Cardassian, Dvali-Turner (DT) and generalized Chaplygin gas (GCG) models. In our best fit analysis for these dark energy proposals we consider flat and the non-flat priors. For all models, we find that relaxing the flatness condition implies that data favors a positive curvature; moreover, the GCG model is nearly flat, as required by Cosmic Microwave Background (CMB) observations.
address:  Departamento de Fı́sica, Avenida Rovisco Pais, 1049-001 Lisboa, Portugal
author: M. C. Bento, O. Bertolami, N. M. C. Santos [^1] and A. A. Sen [^2]
title: Supernovae constraints on dark energy and modified gravity models

# Introduction

Various proposals have been put forward to explain recent observations indicating that the universe is accelerating. A possible explanation is that the universe is filled with dark energy in the form of an exotic component, the generalized Chaplygin gas, with negative equation of state . The striking feature of this model is that it allows for an unification of dark energy and dark matter .

Another possible explanation for the accelerated expansion of the Universe could be the infrared modification of gravity one should expect from extra dimensional physics, which would lead to a modification of the effective Friedmann equation at late times. A concrete model has been suggested by Dvali, Gabadadze and Porrati and later generalized by Dvali and Turner . Another possibility is the modification of the Friedmann equation by the introduction of an additional nonlinear term proportional to $\rho^n$, the so-called Cardassian model .

Currently type Ia supernovae (SNe Ia) observations provide the most direct way to probe the dark energy component at low to medium redshifts. Recently, supernovae data has been analysed by various groups and it was shown that it yields relevant constraints on some cosmological parameters. In particular, it is possible to conclude that, when one considers the full supernova data set, the decelerating model is ruled out with a significant confidence level . It is also shown that one can measure the current value of the dark energy equation of state with higher accuracy and the data prefers the phantom kind of equation of state, $w_X < -1$. Furthermore, the most significant result of that analysis is that, without a flat prior, supernovae data does not favour a flat $\Lambda$CDM model at least up to $68\%$ confidence level, which is consistent with other cosmological observations. In what concerns the equation of state of the dark energy component, it has been shown in Ref. , using the same set of supernovae data, that the best fit equation of state of dark energy evolves rapidly from $w_X \simeq 0$ in the past to $w_X \sim -1$ at present, which suggests that a time varying dark energy fits the data better than the $\Lambda$CDM model.

In this paper, we analyze the Cardassian, the DT and the GCG models using so called *gold* sample SNe Ia compilation of data by Riess *et al.* ; we consider both flat and non-flat priors. For more details see Ref. .

# Observational constraints from supernovae data

The observations of supernovae measure essentially the apparent magnitude $m$, which is related to the (dimensionless) luminosity distance $D_L$ by $$m(z) = {\cal M} + 5 \log_{10} D_L(z) ~,$$ where $$D_L(z) \equiv {H_0}(1 + z) \int_0^z {{1}\over{H(z')}} dz'~.
 \label{DL}$$ Also, $${\cal M} = M + 5 \log_{10}
\left({{c/H_0}\over{1~\mbox{Mpc}}}\right) + 25~,$$ where $M$ is the absolute magnitude which is believed to be constant for all supernovae of type Ia. For our analysis, we consider the set of supernovae data recently compiled by Riess *et al.* known as the *gold* sample. The data points in this sample are given in terms of the distance modulus $\mu_{\rm obs}(z) \equiv m(z) - M_{\rm obs}(z)$ and the $\chi^2$ is calculated from $$\chi^2 = \sum_{i=1}^n \left[ {{\mu_{\rm obs}(z_i) - {\cal M}' - 5
\log_{10}D_{L \rm th}(z_i; c_{\alpha})}\over{\sigma_{\mu_{\rm
obs}}(z_i)}} \right]^2~,
 \label{chisq2}$$ where ${\cal M}' = {\cal M} - M_{\rm obs}$ is a free parameter and $D_{L \rm th}(z; c_{\alpha})$ is the theoretical prediction for the dimensionless luminosity distance of a supernova at a particular distance, for a given model with parameters $c_{\alpha}$. The errors $\sigma_{\mu_{\rm obs}}(z)$ take into account the effects of peculiar motions. Minimization of the $\chi^2$, with respect to ${\cal M}'$, $\Omega_{m}$, $\Omega_k$ and the respective model parameter(s) leads to the results summarized in Table . The best fit value for ${\cal M}'$ is 43.3 for all models.

| **Cardassian model** | $\Omega_m$ | $n$      | $\Omega_k$ | $\chi^2$ |
|:---------------------|:-----------|:---------|:-----------|:---------|
| Flat Prior           | $0.49$     | $-1.4$   | $-$        | $173.7$  |
| Non-Flat Prior       | $0.21$     | $-3.1$   | $0.47$     | $173.2$  |
| **DT model**         | $\Omega_m$ | $\beta$  | $\Omega_k$ | $\chi^2$ |
| Flat Prior           | $0.51$     | $-19.2$  | $-$        | $174.7$  |
| Non-Flat Prior       | $0.24$     | $-60.0$  | $0.43$     | $174.0$  |
| **GCG model**        | $A_s$      | $\alpha$ | $\Omega_k$ | $\chi^2$ |
| Flat Prior           | $0.93$     | $2.8$    | $-$        | $174.2$  |
| Non-Flat Prior       | $0.97$     | $4.0$    | $0.02$     | $174.5$  |

Best fit parameters for the Cardassian, DT and GCG models, considering flat and non-flat priors.

# Cardassian model

We first consider the Cardassian model ; in this model, the universe is composed only of radiation and matter and the increasing expansion rate is given by $$\label{FriedCmodel} H^2= {{8 \pi}\over {3 M_{\rm Pl}^2}} \left(
\rho + b \rho^n \right) - {{k} \over {a^2}}$$ where $M_{\rm Pl} = 1.22 \times 10^{19}$GeV is the $4$-dimensional Planck mass, $b$ and $n$ are constants, and we have added a curvature term to the original Cardassian model. The new term dominates only recently, hence in order to get the recent acceleration in the expansion rate, $n < 2/3$ is required.

At present, the universe is matter dominated and Eq. () can be rewritten as $$\label{FriedCmodel2} \left({{H} \over {H_0}}\right)^2= \Omega_{m}
(1+z)^3+\Omega_k (1+z)^2 \nonumber \\
+ (1-\Omega_{m}-\Omega_k)(1+z)^{3n}~,$$ where $H_0$ is the present value of the Hubble constant and $\Omega_k=-{{k} \over {a_0^2 H_0^2}}$ is the present curvature parameter. Notice that the case $n=0$ corresponds to the $\Lambda$CDM model.

For the flat case, we have only two parameters and their best fit values are $\{\Omega_{m},n\}=\{0.49,-1.4\}$. In Fig. we show the 68$\%$ and 95$\%$ confidence contour plots, where it is clear that the $\Lambda$CDM model is excluded at a 95$\%$ confidence level.

If we relax the flat prior, we find that the best fit values are $\Omega_k = 0.47$, $\Omega_m = 0.21$ and $n=-3.1$. Moreover (see Fig. ) the case $n=0$ is again excluded at $95\%$ confidence level.

# Dvali-Turner model

The second model we consider is the one proposed by Dvali & Turner , where the Friedmann equation is modified by the addition of a new term which may arise in theories with extra dimensions

$$H^2 \, -  \, {H^{\beta} \over r_c^{2 - \beta}} \, = \, {8\pi \over
3 M_{\rm Pl}^2} \rho - {{k} \over {a^2}}~,$$ where $r_c$ is a crossover scale which sets the scale beyond which the laws of the 4-dimensional gravity breakdown and become 5-dimensional and we have introduced a curvature term.

If we assume that the universe is matter dominated the Friedmann expansion law can be written as $$\label{FriedDTmodel} \left({ {H}\over{H_0}} \right)^2 = \Omega_{m}
(1+z)^3 + (1-\Omega_{m}-\Omega_k) \left({{H}\over{H_0}}
\right)^\beta \nonumber \\
+ \Omega_k (1+z)^2 ~.$$

Notice that $\beta$ is the only parameter of the model: for $\beta=0$ the new term behaves like a cosmological constant and the case $\beta=1$ corresponds to the Dvali-Gabadadze-Porrati (DGP) model . The requirement that the new term does not interfere with the formation of large-scale structure leads to the bound $\beta \leq 1$.

From Fig. , it is clear that $\beta$ is very weakly constrained and can become arbitrarily large and negative. Moreover, both the $\Lambda$CDM model ($\beta=0$) and the DGP model ($\beta=1)$, are strongly disfavoured. Fixing $\beta=1$ (DGP model), we get $\Omega_{m} = 0.17$ .

If we relax the flat prior, we find that the best fit results are for $\{\Omega_{m}, \Omega_k, \beta\}= \{0.24, 0.43, -60,0\}$. As we can see from the contour plots shown in Fig. , $\beta$ can become arbitrarily large and negative, if we allow $\Omega_m$ to be large. Moreover, both $\Lambda$CDM and DGP models are disfavoured at $95\%$ C.L.

# Generalized Chaplygin gas model

Finally, we consider the generalized Chaplygin gas model, which is characterized by the equation of state $$p_{ch} = - {A \over \rho_{ch}^\alpha}~, \label{rhoGCG}$$ where $A$ and $\alpha$ are positive constants. For $\alpha=1$, the equation of state is reduced to the Chaplygin gas scenario . Integrating the energy conservation equation with the equation of state (), one gets $$\rho_{ch} = \rho_{ch0} \left[A_{s} + {(1-A_s) \over
a^{3(1+\alpha)}}\right]^{1/(1+\alpha)}~,$$ where $\rho_{ch0}$ is the present energy density of GCG and $A_s
\equiv A/\rho_{ch0}^{(1+\alpha)}$. Hence, $\rho_{ch}$, interpolates between a dust dominated phase, $\rho_{ch} \propto a^{-3}$, in the past and a de-Sitter phase, $\rho_{ch} = -p_{ch}$, at late times. This property makes the GCG model an interesting candidate for the unification of dark matter and dark energy. Notice that $\alpha = 0$ corresponds to the $\Lambda$CDM model.

The Friedmann equation for a non-flat unified GCG model is given by $$\left({ {H} \over {H_0} }\right)^2  =
\left(1-\Omega_{k}\right)\left[A_{s} +
(1-A_s)(1+  z)^{3(1+\alpha)}\right]^{1/(1+\alpha)}
+  \Omega_{k}(1+z)^{2}~~.
\label{FriedGCGmodel}$$

This model has been thoroughly scrutinized from the observational point of view; for a CMB power spectrum compatibility analysis see e.g. Ref. and for a previous supernovae data analysis see Ref. and references therein. The $68\%$ and $95\%$ confidence level contours for the flat case are shown in Fig. . Notice that the $\Lambda$CDM model is consistent at $95\%$ C.L although it is ruled out at $68\%$ C.L.

When we relax the condition of flat prior, the best fit model becomes very close to flat ($\Omega_k = 0.02$) which is a a new result. The confidence contours for this case are shown in Fig. 6.

# Conclusions

We performed a likelihood analysis of the latest type Ia supernovae data for three models: the modified gravity Cardassian and Dvali-Turner models and the generalized Chaplygin gas model of unification of dark energy and dark matter. We find that SNe Ia most recent data allows, in all cases, for non-trivial constraints on model parameters as summarized in Table . We find that, for all models, relaxing the flatness condition implies that data favors a positive curvature and the GCG model is nearly flat in this case. The fact that the *gold* sample of supernovae data prefers a flat GCG model, which is consistent with CMB observations, leads us to conclude that the GCG is a better choice among the three alternative models that we have considered.

# References

[^1]: Present address: Institut für Theoretische Physik, Universität Heidelberg, Philosophenweg 16, 69120 Heidelberg, Germany

[^2]: Present address: Department of Physics and Astronomy, Vanderbilt University, Nashville TN37235, USA


author: Moon Duchin
title: Gerrymandering metrics:
  How to measure? What's the baseline?

# What is a districting plan?

For the purposes of this brief discussion, I need to begin by specifying redistricting as a math problem in some way; that is, by formalizing a districting plan as an appropriate kind of mathematical object. I'll propose a way to do this that is completely uncontroversial: start with the smallest units of population that are to be the building blocks of a plan—these might be units given by the Census, like blocks, block groups, or tracts, or they might be units given by the state, like precincts or wards. [^1] Represent those population units as nodes or vertices in a graph, and connect two of them if the units are geographically adjacent.

For instance, here is a map of Wisconsin, and with it I have drawn a graph of its 1,409 census tracts. You certainly can't see all the ones in Milwaukee by looking at this picture, because the graph is too dense there, which illustrates that plotting the graph in this way (with the vertices at the centers of the tracts) also shows you where the population is clustered.

Armed with this, we can say that a (contiguous) *districting plan* is a partition of the vertices in the graph of a state's population into some number of subsets called *districts*, such that each district induces a connected subgraph.[^2] For instance, Wisconsin currently has eight congressional districts and 99 state assembly districts, so if they were made from census-tract units, then the former districts would have 100-200 nodes each while the latter would have only 10-20 nodes.[^3]

Our goal when we redistrict is to find a partition that meets a list of criteria. Some of those are universal and apply to the whole country, like having nearly equal populations in the districts and complying with the federal Voting Rights Act, and some are specified by states, such as guidance about shapes of districts or about how much to allow the splitting of counties and cities. Part of what makes redistricting so hard is that many of these rules are vague, and they often represent conflicting priorities.

The rest of this note will be devoted to outlining three intellectually distinct but not mutually exclusive strategies for measuring partisan gerrymandering. The first two are **only** suited for partisan gerrymandering, but the third is more flexible and can be used for other kinds of measurements of a plan, like racial bias or competitiveness. For each approach we should track the norm and the baseline: how does the metric correspond to a notion of fairness? and what's the basis of comparison against which a plan is assessed?

# Partisan symmetry

Partisan symmetry is a principle for districting plans that has been articulated and championed by Gary King, Bernie Grofman, Andrew Gelman, and several other prominent scholars. (See and its references.) At its heart is a certain normative principle (or statement of how fair plans *should* behave): how one party performs with a certain vote share should be handled symmetrically if the other party received the same vote share. That is, if Democrats got $60\%$ of the vote and, with that, won $65\%$ of the seats in the election, then if Republicans had earned $60\%$ of the vote, they too should have received $65\%$ of the seats.

To visualize this, let's build a *seats-votes plot*. On the $x$-axis we'll record $V$, the proportion of votes won by party $A$. On the $y$-axis will be $S$, the proportion of seats in the electoral body won by $A$. So a single statewide election is represented by one point on this grid; for instance $(V,S)=(.6, .65)$.

The problem is that a single data point does not tell you enough to understand the properties of the districting plan as a plan. A standard way to extend this point to a curve is to use the model called *uniform partisan swing*: look at the results district by district, and add/subtract the same number of percentage points to party $A$'s vote share in each district. As you keep adding to $A$'s vote share, you eventually push the share past $50\%$ in some districts, causing those districts to flip their winner from $B$ to $A$. And as you subtract, you eventually push districts towards $B$. Thus this method creates a curve that is step-shaped, showing a monotonic increase in the proportion of seats for $A$ as the proportion of votes for $A$ rises.

In the figure, we see that the Minnesota election has a seats-votes curve that is very nearly symmetric about the center point $(.5,.5)$. On the other hand, Ohio's curve is very far from symmetric. Rather, it looks like Ohio Republicans can secure $75\%$ of the congressional representation from just $50\%$ of the vote, and that just $42\%$ of the vote is enough for them to take a majority of the congressional seats.

A partisan symmetry standard would judge a plan to be more gerrymandered for producing a more asymmetrical seats-votes curve, flagging a plan if the asymmetry is sufficiently severe. There are many ways that a mathematician could imagine using a bit of functional analysis to quantify the failure of symmetry, but there are also a few elementary and easy-to-visualize scores: for instance, look at how far the curve is from the center point $(.5,.5)$, either in vertical displacement or in horizontal displacement, on reasoning that any truly symmetric plan must award each party half the seats if the vote is split exactly evenly. Or compare one party's outcome with a given vote share to that for the other party if it had the same share.[^4]

In the (substantial) literature on partisan symmetry scores, you will sometimes see the vertical displacement called *partisan bias* (e.g., in ) and the horizontal displacement called the *mean/median score*.

# Efficiency gap

Efficiency gap is a quite different idea about measuring partisan skew, both in its conceptual framing and in which plans it picks out as gerrymanders. However, it does have a whiff of symmetry about it: it begins with the normative principle that a plan is fair if the two parties "waste" an equal number of votes.

In order to parlay a certain given number of party-$A$ voters into the maximum possible number of seats for $A$, an extreme gerrymanderer would want to distribute $A$ voters *efficiently* through the districts: you'd win as many districts as you can by narrow margins, and you wouldn't put any of your voters at all in the districts won by the other side, because they're not contributing towards your representation there. By this logic, there are two ways for a party to waste votes. On one hand, votes are wasted where there is an unnecessarily high winning margin—for this model, say every vote over $50\%$ is wasted. On the other hand, all losing votes are wasted votes. Efficiency gap is the quantity given by the following simple expression: just add up the statewide wasted votes for party $A$ by summing over districts, subtract the statewide wasted votes for party $B$, and divide by the total number of votes in the state. Let's call this number $EG$. Note that it is a signed score, and that $-.5\le EG \le .5$ by construction.[^5] By the logic of the definition, a totally fair plan would have $EG=0$. This score was first devised by political scientist Eric McGhee and was made into the centerpiece of a multi-pronged legal test by McGhee and law professor Nick Stephanopoulos in their influential 2015 paper. For legislative races, they propose $|EG|= .08$ as the threshold, past which a plan would be presumptively unconstitutional.

Happily, this test is very easily represented on a seats-votes plot such as we introduced in the previous section.[^6] The permissibility zone (derived from the $EG$ formula and shown in Figure ) turns out to be a strip of slope two in the seats-votes space; any election that produces an outcome falling outside this zone is flagged as a gerrymander. That the slope is two means that a certain "seat bonus" is effectively prescribed for the winning side: as the authors of the standard put it, "To produce partisan fairness, in the sense of equal wasted votes for each party, the bonus should be a precisely twofold increase in seat share for a given increase in vote share." This has the funny property that elections that produce directly proportional outcomes are often flagged as problematic.[^7] For instance, the point $(.65,.65)$ marked in the figure, where a party has earned $65\%$ of the vote and converted it to $65\%$ of the seats, is seen as a gerrymander in favor of the other side! Quantitatively, that's because this case has $EG=.15$, far larger than the threshold. Conceptually, it's because the party has received an inadequate seat bonus by the lights of the efficiency gap.

# Sampling

Finally, I want to sketch a new approach to redistricting analysis that has started to crystallize only in the last five or so years. It draws on a very well-established random walk sampling theory whose growth has accelerated continuously since its early development in the 1940s.[^8] The scientific details for the application to gerrymandering are still coalescing, but the idea is incredibly promising and has profound conceptual advantages that should cause it to fare well in courts. This idea is to use algorithmic sampling to understand the space of all possible districting plans for a given state.

Remember our goal: we seek to split up a large, finite graph into some number of districts. What you see in this picture is a very small graph being split up into four districts, represented by the different colors. First, we constrain the search space with requirements for valid plans, such as contiguity of the pieces, compactness of their shapes, keeping population deviation under $1\%$, maintaining the current number of majority-minority districts, and so on. (This will depend on the laws in place in the state we are studying.[^9]) A sampling algorithm takes a random walk around the space of all valid partitions: starting with a particular districting plan, flip units from district to district, thousands, millions, billions, or trillions of times.

Searching in in this way, such as with a leading method called Markov chain Monte Carlo, or MCMC, you can sample many thousands of maps from the chains produced by random flips. Each one is a possible way that you could have drawn the district lines. Call this big collection of maps your *ensemble* of districting plans.

What can you do with a large and diverse ensemble of plans? This finally gives us a good way to address the baseline problem that always looms over attempts to adjudicate gerrymandering. That is, it gives us a tool we can use to decide whether plans are skewed relative to other possible plans with the same raw materials. The norm undergirding the sampling standard is that districting plans should be constructed *as though* just by the stated principles.

The computer sampling methods could even be used to craft a new legal framework: *Extreme outliers are impermissible*. (See Figure .) How extreme? That would require some time and experience to determine, just as population deviation standards have taken some time to stabilize numerically in response to the corresponding legal framework *One person, one vote*.

The great strength of this method is that it is sensitive to the particularities, legal and demographic, of each state that it is used to analyze. If a state has specific rules in its constitution or in state law—examples include North Carolina's "whole county provision," Wisconsin's quirky rules for district contiguity, Arizona's preference for competitive races, incumbent protection in Kansas, Colorado's guidance to minimize the sum of the district perimeters—the sampling can be carried out subject to those constraints or priorities. And just as importantly, it addresses a major critique that can be leveled at both of the previous approaches: why is it reasonable to prefer seats-votes symmetry, or to aim at equal vote wastage, when populations themselves are clustered in highly asymmetrical ways? For instance, imagine a state in which every household has 3 Republicans and 2 Democrats. (Of course this is highly unrealistic, but it's an extreme case of a state with a very uniform distribution of partisan preferences.) Then no matter where you draw the lines, every single district will be $60\%$ Republican, which means Rs win $100\%$ of the seats, corresponding to the point $(.6,1)$ on the seats-votes plot. One can easily verify that there is literally *no plan at all* that doesn't have a sky-high partisan bias[^10] or that gets the efficiency gap below $.3$. On the other hand, the sampling method will reveal an ensemble in which all plans are made up of 60–40 districts, and thus will show a particular plan with that composition to be completely typical and therefore permissible along partisan lines. It seems intuitively unreasonable for $60\%$ of the votes to earn all of the seats, but this method reveals that the political geography of this state demands it.

# Summary

As mentioned earlier, these three approaches can be used in concert. For instance, one can use any evaluation axis with a sampling ensemble, say efficiency gap (or mean-median score) instead of partisan outcome. So you can mix and match these approaches. Nonetheless, each has a different normative principle at its core and they would produce quite different redistricting outcomes if they were to be adopted at the center of a new legal framework. Let's review some pros and cons.

For **partisan symmetry**, it is really easy to make the case for fairness: it sounds eminently reasonable that the two parties should be treated the same by the system. Partisan symmetry uses up-to-date statistics and political science and has a lot of professional consensus behind it. On the other hand, it has been critiqued by the court as too reliant on speculation and counterfactuals, mainly because of how it arrives at conclusions on how a plan would have performed at different vote levels.[^11] And it does not center on the question of how much advantage the line drawers have squeezed from their power, because it lacks a baseline of how much symmetry a politically neutral agent could reasonably be expected to produce, or even an agent who took symmetry as a goal. Crucially, it is not at all clear that it is easy or even feasible to draw a map that will maintain partisan symmetry across several elections in a Census cycle.

An interesting and attractive feature of **efficiency gap** is that it seems to derive, rather than prescribe, a permissible range in that seats/votes plot. It offers a single score and a standard threshold, and it is relatively easy to run. [^12] The creators of the $EG$ standard did about the best possible job of creating what the courts seemed to be demanding: a single judicially manageable indicator of partisan gerrymandering. The problem is that gerrymandering is a fundamentally multi-dimensional problem, so it is manifestly impossible to convert that into a single number without a loss of information that is bound to produce many false positives or false negatives for gerrymandering. To illustrate the dimension issue, imagine that we are at your house and you ask me where I live. It is impossible to reasonably communicate the location of my house to you with a single number. If you let me give you two numbers, I can give you latitude and longitude, say, but practically speaking just one number won't do.

Finally I have described the **sampling** approach and **outlier analysis**, and I've argued that the strength of this approach is that it is sensitive to not only the law, as we've seen, but also to the political geography of each state—for instance, Wisconsin Democrats are densely arranged in Milwaukee proper, ringed by heavily Republican suburbs, but in Alaska Dems are spread throughout the rural parts of the state—which might have hard-to-measure effects on just how possible it is to split up the votes symmetrically or efficiently. Outlier analysis doesn't measure a districting plan against an all-purpose ideal, but against actual splittings of the state, holding the distribution of votes constant. In the next ten years, I expect to see explosive scientific progress on characterizing the geometry and topology of the space of districting plans, and on understanding the sampling distributions produced by our algorithms.

[^1]: A districting plan normally won't go below the census block level, because then population needs to be estimated. The units in which the election outcomes are recorded are called VTDs, or voting tabulation districts, which typically correspond to precincts or wards. These are natural units to build a plan from if you want to study its partisan properties.

[^2]: It is generally reasonable to also require that no district is wholly surrounded by another district.

[^3]: That is, if the districts were made out of whole tracts. In fact, they are typically made out of finer pieces, like precincts.

[^4]: If the seats-votes curve is denoted $f(V)$, then this comparison amounts to $P(V)=\left|f(V)- \left[ 1- f(1-V) \right] \right|$. It is natural, for instance, to evaluate this at $V=V_0$, the actual vote share in a given election, but most authors don't commit to this.

[^5]: This is true because the total wasted votes in the state, and indeed in each district, add up to half of the votes cast.

[^6]: Note that throughout this section we are leaning on the simplifying assumptions that all districts have equal turnout, there are only two parties, and all races are contested by both sides. These are varyingly realistic assumptions.

[^7]: As mentioned above, $EG$ is proposed as one part of a multi-pronged legal test, so high $EG$ alone wouldn't doom a plan. But it is obviously still relevant to understand the systematic features of the score and the norms behind its construction.

[^8]: Diaconis's excellent survey reviews successful applications of MCMC in chemistry, physics, biology, statistics, group theory, and theoretical computer science.

[^9]: The process of interpreting and operationalizing rules to create scores certainly bears scrutiny. A successful implementation will have to demonstrate robustness of outcomes across choices made when scoring.

[^10]: In the simple model, the seats-votes curve is a step function with a big jump at $V=1/2$. For more granularity, you could instead imagine a map in which one district has 39% D and all others have percentages clustered around 41%, also producing a high partisan bias score for no very damning reason. Compare MN-2016 from Figure .

[^11]: As Justice Kennedy wrote: "The existence or degree of asymmetry may in large part depend on conjecture about where possible vote-switchers will reside. Even assuming a court could choose reliably among different models of shifting voter preferences, we are wary of adopting a constitutional standard that invalidates a map based on unfair results that would occur in a hypothetical state of affairs." LULAC v. Perry 126 S. Ct. 2594 (2006)

[^12]: The small print for efficiency gap: you have to worry about which election data to use, and how to impute outcomes in uncontested races, which leaves a little bit of room for the possibility of dueling experts, but by and large it is a very manageable standard.