text:
# What are possible applications of deep learning to research mathematics?

With no doubt everyone here has heard of deep learning, even if they don't know what it is or what it is good for. I myself am a former mathematician turned data scientist who is quite interested in deep learning and its applications to mathematics and symbolic reasoning. There has been a lot of progress recently, and while it is exciting to machine learning experts, the results so far are probably not useful for research mathematicians. My question is simple:

Are there areas of research math, that if one had access to a fully trained state-of-the-art machine learning model (like the ones I will describe below), it would make a positive impact in that field?

While math is mostly about proofs, there is also a need sometimes for computation, intuition, and exploration. These are the things that deep learning is particularly good at. Let me provide some examples:

## Good intuition or guessing

Charton and Lample showed that Transformers, a now very standard type of neural network, are good as solving symbolic problems of the form $$\mathit{expr}_1 \mapsto \mathit{expr}_2$$ where $$\mathit{expr}_1$$ and $$\mathit{expr}_2$$ are both symbolic expressions, for example in their paper $$\mathit{expr}_1$$ was an expression to integrate and $$\mathit{expr}_2$$ was its integral. The model wasn't perfect. It got the right answer about 93-98% of the time and did best on the types of problems it was trained on. Also, integration is a 200 year old problem, so it is hard to outcompete a state-of-the-art CAS.

However, there are some things which make this interesting. Symbolic integration is important, difficult, and (somewhat) easy to check that the solution is correct by calculating the derivative (and checking symbolically that the derivative is equivalent to the starting integrand). Also it is an area where “intuition” and “experience” can definitely help, since a trained human integral solver can quickly guess at the right solution. Last it is (relatively) easy to compute an unlimited supply of training examples through differentiation. (This paper also uses other tricks as well to diversify the training set.)

Are there similar problems in cutting edge mathematics, possibly in algebra or combinatorics or logic where one would like to reverse a symbolic operation that is easy to compute in one direction but not the other?

## Neural guided search

Some problems are just some sort of tree or graph search, such as solving a Rubik's cube. A neural network can, given a scrambled cube, suggest the next action toward solving it. A good neural network would be able to provide a heuristic for a tree or graph search and would prevent exponential blow-up compared to a naive brute-force search. Indeed, a paper in Nature demonstrated training a neural network to solve the Rubik's cube from scratch this way with no mathematical knowledge. Their neural network-guided tree search, once trained, can perfectly solve a scrambled cube. This is also similar to the idea behind AlphaGo and its variants, as well as the idea behind neural formal theorem proving—which is really exciting, but also not up to proving anything useful for research math.

Puzzle cubes and board games are not cutting edge math, but one could imagine more interesting domains where just like a Rubik's cube one has to manipulate one expression into another form through a series of simple actions, and the ability to do that reliably would be of great interest. (Note, the neural guided tree search I've described is still a search algorithm and much slower than a typical cube solving algorithm, but the emerging field of program synthesis could possibly one day soon learn from scratch a computer program which solves the Rubik's cube, as well as learn computer programs to solve more interesting math problems.)

## Neural information retrieval

Suppose you have a database of mathematical objects (say, integer sequences, finite groups, elliptic curves, or homotopy groups as examples) and you want a user to be able to look up an object in this database. If that object is in the database, you would like the user to find it. If it is not, you would like the user to find similar objects. The catch is that "similar" is hard to define. Deep learning provides a good solution. Each object can be associated with an embedding, which is just a vector in, say, $$\mathbb{R}^{128}$$. The measure of similarity of two objects is just the inner product of their embeddings. Moreover, there are a number of techniques using self-supervised machine learning to construct these embeddings so that semantically similar objects have similar embeddings. This has already shown a lot of promise in formal theorem proving as premise selection where one wants to pick the most relevant theorems from a library of theorems to use in the proof of another theorem.

For example, I think such a neural database search could reasonable work for the OEIS, where one can use a neural network to perform various prediction tasks on an integer sequence. The inner layers of the trained network will compute a vector embedding for each sequence which can be used to search through the database for related sequences.

## Geometric intuition

Neural networks are pretty good at image recognition and other image tasks (like segmentating an image into parts). Are there geometry tasks that it would be useful for a deep learning agent to perform, possibly in dimensions 4 or 5, where human geometric intuition starts to fail us since we can't see in those dimensions. (It would be hard to make, say a convolutional neural network work for a 4 dimensional image directly, but I could imagine representing a 3D surface embedded in 4D as say a point cloud of coordinates. This could possibly work well with Transformer neural networks.)

Neural networks are very flexible when it comes to the choice of input and output, as well as the architecture, so don’t let the specific examples above constrain your thinking too much. All you need are the following things:

1. A type of mathematical object. One that you care about. It should be representable in some finite way (as a formula, an initial segment of a sequence, an image, a graph, a computer program, a movie, a list of properties).
2. A task to perform on your operation. It can be well specified or fuzzy. It can be solvable, or (like integration) only partially solvable. It can be classifying your objects into finitely many buckets. It could be computing some other related object or property of the object. It could be finding the next element in a sequence. It could be coming up with a prediction or conjecture of some sort. It could be turning that object into a some 2D cartoon image even, just to think outside the box.
3. Lots of training data. Either you need to be able to synthetically generate a lot of training examples as in the integration example above, or like OEIS have a large dataset of 10s of thousands or examples (more examples is always better). Clean data is preferred but neural networks handle messy data very well. Another “data free” solution is reinforcement learning like in the Rubik’s Cube example or AlphaGoZero, where the agent learns to explore the problem on its own (and generates data through that exploration).
4. Patterns in the data, even if you can’t see what they are. Your task should be one where there are patterns which help the machine learning agent solve the problem. (For example, I’m not convinced that factoring large integers would be a good task.)
5. Motivation. Why would this be useful to the field? What purpose would having this trained model have? Would it make it easier to conjecture facts, explore new areas of math, wrap ones head around a bunch of confusing formulas? Or do you have a way to turn a learned heuristic into a proof, such as with a search algorithm (as in the Rubik’s cube example above) or by checking the solution (as in the integration example above)?
• I'm one of the authors of the lean-gptf paper. :) I'm very encouraged by the progress in machine learning on formal mathematics libraries, but I think it has a long way to go to help work-a-day mathematicians. On the other hand, I think there are probably more focused applications of deep learning to specific areas of mathematics that could have an impact right now, or relatively soon. Apr 14, 2021 at 13:15
• Does numerical solution of PDEs count? arxiv.org/abs/1904.07200 Apr 14, 2021 at 16:33
• "While math is mostly about proofs" Objection! :-) Apr 14, 2021 at 22:41
– J W
Apr 15, 2021 at 19:41
• Proofs are an important part of mathematics, but mathematics is not mostly about proofs, far from it. See, for example, terrytao.wordpress.com/career-advice/… Apr 16, 2021 at 15:25

In the context of algebraic geometry, neural networks have become useful tools in the study of Calabi-Yau manifolds. The computation of their topological invariants, metrics and volumes is of particular interest for applications in physics (string theory). Recent contributions include

For a more general overview, see Machine-Learning Mathematical Structures

We review, for a general audience, a variety of recent experiments on extracting structure from machine-learning mathematical data that have been compiled over the years. Focusing on supervised machine-learning on labeled data from different fields ranging from geometry to representation theory, from combinatorics to number theory, we present a comparative study of the accuracies on different problems. The paradigm should be useful for conjecture formulation, finding more efficient methods of computation, as well as probing into certain hierarchy of structures in mathematics.

• Have these been used for any particularly interesting applications in physics? Apr 14, 2021 at 15:54
• This is a great example! I was expecting only to get ideas for future research (and that is still what I’m looking for) and not already published results, so this is very motivating. Could you possibly elaborate on the task being performed here? I don’t know much about this area, but it seems that in the second example the input to the NN is a matrix of integers representing a class of manifolds and the output is an integer hodge number from 1 to 24 of that class. Is that correct? What about the first example? Apr 14, 2021 at 16:18
• I found this description (page 11 and following) quite helpful. Apr 14, 2021 at 19:33
• @CarloBeenakker This is really general. From that paper: "We emphasize again that the computing a topological invariant of any manifold (appropriately embedded as an algebraic variety) can be cast into the form of [a simple machine learning training problem]. We turned to CY because of their being readily available [data], similar experiments should be carried out for general problems in geometry." (Although I don't know enough about this area to say if it is surprising or useful.) Apr 14, 2021 at 22:20
• I added that overview paper to the answer box (since this is not (or not yet) community wiki I refrained from making a separate answer) Apr 15, 2021 at 6:05

I have some thoughts on a level of generality that is a bit higher than the question asks for:

One obstacle that faces applications of supervised machine learning to predict properties of mathematical objects is that in many fields of mathematics, such as number theory, we tend to expect that properties of the nice mathematical objects we study will either be

• given by explicit formulas, or
• quasirandom and hard to predict.

If this expectation is correct, then machine learning researchers are in a bit of a bind - they will either discover nothing or something trivial. Of course, mathematicians are fallible and our expectations are certainly not always correct.

This suggests one approach would be to use neural networks to search for properties that are unexpectedly easy to predict. This would be a somewhat thankless task as you would usually find nothing of interest, but when you do find something it would be a counterintuitive new phenomenon, which could hopefully by human analysis turned into a new formula for something.

It is crucial in this setting to have a good understanding of existing quasirandom models of the object in question, to know what trivial bounds your prediction is trying to beat. (This has been a pitfall for some attempts to apply machine learning, or just classical statistics, to pure mathematics.)

I am particularly excited about bringing techniques from puzzles and games to pure math, as in the neural guided search section of the question. This is because neural networks on games are some of the only networks to not just achieve human performance on tasks, and not just achieve superhuman performance, but to achieve superhuman performance by introducing new ideas which human practitioners were able to learn from and incorporate into their own strategies.

Since the goal of mathematics is the production of ideas, this is very heartening.

So we're looking for games where one must apply a sequence of moves, following some rules, to try to reach some result. (I don't know many examples of adversarial games in pure mathematics, so I'm describing 1-player games.)

Formal theorem proving is an example of this, already discussed in Steve Huntsman's answer.

I believe Kirby calculus is a game or puzzle of this sort, with the goal of showing two 3-manifolds or 4-manifolds are diffeomorphic by a finite series of combinatorial moves, that is used in current research (to test whether a newly constructed smooth structure on a 4-manifold is exotic or diffeomorphic to the standard structure). One challenge might be finding a good way to represent the diagrams that a network can work with efficiently.

• I agree that Kirby calculus is a good candidate for machine learning, but it should be emphasized that it's only good for showing that two things are the same (often in unexpected ways). So you can show that e.g. a potential counterexample to the smooth 4d Poincare conjecture is actually standard, but you'll never be able to use it to show that it is a counterexample. Apr 14, 2021 at 16:53
• The reason I want to look for problems with a sequence of steps is because I really like the AlphaZero algorithm that combines machine learning with tree search, and think it's very powerful. This algorithm, at least in its current form, relies on a sequence of choices in time, where the algorithm considers multiple choices and evaluates their effects. Apr 14, 2021 at 17:19
• A possible example of an adversarial game in pure mathematics is an Ehrenfeucht–Fraïssé game. Apr 14, 2021 at 17:20
• @WillSawin Does this capture your idea of a 1-player game? en.wikipedia.org/wiki/Reachability_problem Apr 14, 2021 at 17:33
• I see. It would be very surprising to me if a deep learning algorithm could rediscover the formula for the constant appearing in the Artin primitive root conjecture or Bateman-Horn conjecture without being told to look for infinite products over primes. Of course, since these formulas are already available it might be hard to convince anyone that a computer found them again even if one of them did. Apr 14, 2021 at 18:06

In the category of guessing, there is the Ramanujan Machine. This project got off on the wrong foot with the research mathematics community because their initial announcement made overblown claims (such as claiming novelty for some conjectures/theorems that weren't new), but it is my belief that the general concept is sound. Along similar lines, perhaps it's time to revisit Graffiti with modern neural nets. In his paper On Conjectures of Graffiti (Ann. Discrete Math. 38 (1988), 113–118), Siemion Fajtlowicz described a computer program for generating conjectures about finite graphs. Most of its conjectures were either false, trivial, or known, but it did come up with some novel conjectures that were interesting enough for graph theorists to spend time proving them and publishing the proofs.

In the category of guided search, people have tried to use neural networks to improve the performance of SAT solvers; see for example the work on NeuroSAT. This seems like a promising area for further research.

• Well, if most of the conjectures it come up with is false then I don’t really see the point. I can hire a monkey to type on my laptop all day and maybe after a few weeks he would come up with the statement of Riemann hypothesis. Apr 15, 2021 at 7:23
• I remember having heard about this project some time ago, and while I forgot much about it since that time, I am pretty sure it has nothing to do with deep learning. Apr 15, 2021 at 7:25
• @Heavensfall If it took only a few weeks to come up with the Riemann hypothesis then I would gladly sift through the junk to find the gold. Apr 15, 2021 at 13:15
• @ThomasBaruchel Yes, perhaps I should have been clearer that neither the Ramanujan Machine nor Graffiti uses deep learning. I was just picking two specific areas where computers have historically come up with interesting conjectures, and suggesting that possibly better algorithms would do even better. Apr 15, 2021 at 13:21

Neural networks might help to speed up computations in the monster group $$\mathbb{M}$$, which is the largest finite sporadic simple group. Such a network could be in some sense a (rather large) cousin of the neural network dealing with Rubik's cube mentioned by the OP.

Elements of $$\mathbb{M}$$ are usually represented as words of sparse matrices in $$\mbox{GL}_n(\mathbb{F}_k)$$, $$196882 \leq n \leq 196884, k = 2,3$$. There is an effective algorithm for checking equality of two such words, see [1]. Reduction of a word to a shorter word may take several minutes on a computer, see e.g. [2] for an overview. I'm currently working on the acceleration of the reduction of such words. I plan to exploit some geometric information contained in the images of certain vectors in $$\mathbb{F}_k^n$$. As far as I know, nobody has used this information before. (For experts: I focus on the images of vectors called 2A-axes). Here a neural network might be better at learning how to use this information than I am.

The mathematical benefits of such a project are:

1. Regarding computations, the monster group is the most difficult finite simple group to deal with. If we can compute in the monster group then we can compute in all finite groups, provided we have enough information about that group and enough computer memory.

2. We can probably finish the classification of the maximal subgroups of the monster group.

References

[1] R. Wilson. Computing in the monster. In Group, Combinatorics & Geometry, Durham 2001, 327–337. World Scientific Publishing, 2003.

[2] R. A. Wilson. The Monster and black-box groups.

Some recent work on neural formal theorem proving (already mentioned in the question, but the examples give a sense of the state of the art):

• Also see TacticToe (HOL4), Tactitian (Coq), CoqGym/ASTactic (Coq), HOList/DeepHOL (HOL Light), Holoprasm (Metamath), GPT-f (Metamath), Lean GPT-f (Lean) for more state of the art in this area. Apr 14, 2021 at 13:21
• And all of Josef Urban's work. Apr 14, 2021 at 13:22
• While I think such work provides a lot of motivation and encouragement, I don't think it is currently useful to research math and I don't think it will be for a while. However, I think there are probably more specific applications of machine learning to specific areas of mathematics that could be of value right now if we find them. Apr 14, 2021 at 13:23
• @JasonRute I think formalization of math that is close to research-level, like much of what Kevin Buzzard and his collaborators have been doing, is a valid and potentially important area of research math. As far as I know they don't use any neural methods, but at the rate machine learning approaches improve, isn't it reasonable to guess these things could be useful relatively soon? Apr 14, 2021 at 15:46
• @WillSawin, I haven't been clear. I greatly value Buzzard's work and his predecessors. I played a small role in Hale's formalization of the Kepler Conjecture, and a much larger role in lean-gptf, a recent neural theorem proving tactic for Lean (Kevin's prover of choice). What I want to emphasize here is that we don't have to solve automatic theorem proving (a REALLY hard problem) to use AI to solve outstanding math problems right now. I also don't think lean-gptf and such will currently solve new theorems or create new insights, but neural tools focused on specific areas of math will. Apr 14, 2021 at 17:02

This predates deep learning, but we should not forget that there has already been some progress in graph theory by recognizing patterns (OP: "patterns in the data") and forming conjectures.

• Hansen, Pierre, and Gilles Caporossi. "AutoGraphiX: An automated system for finding conjectures in graph theory." Electronic Notes in Discrete Mathematics 5 (2000): 158-161. DOI.

"Up to now it [AutoGraphiX] has refuted 9 conjectures of Graffiti and suggested over 50 novel conjectures, 15 of which have been proved and none disproved."

Just posted (29Apr2021): A.Z. Wagner, "Constructions in combinatorics via neural networks." arXiv abs:

"We demonstrate how by using a reinforcement learning algorithm, the deep cross-entropy method, one can find explicit constructions and counterexamples to several open conjectures in extremal combinatorics and graph theory."

As requested, now a separate post.

• And not just this type of thing, here's a sample from a student in my department: paperswithcode.com/author/matthias-fresacher Learning Erdős-Rényi Random Graphs via Edge Detecting Queries Apr 15, 2021 at 1:29
• It is disconcerting that their first praise for this automated system is the way it refutes conjectures from a different automated system. Apr 19, 2021 at 9:16
• @MattF. And now Wagner's paper refutes a conjecture by AutoGraphiX (which was previously, independently, less efficiently refuted by a human mathematician, the authors point out). It's the circle of life! I would actually defend this - if we have automatic conjecture generators and other systems that can automatically refute them, then by combining them we should obtain automatic generation of highly plausible conjectures. May 1, 2021 at 21:35
• The third example that you have just added does actually involve neural networks, and thus seems to be a better fit for the question than your other two. It seems worth posting a new answer, or editing your answer to focus more on it. May 1, 2021 at 21:38

Adam Wagner has a new paper on arXiv (29 Apr 2021), "Constructions in combinatorics via neural networks," whose Abstract is:

"We demonstrate how by using a reinforcement learning algorithm, the deep cross-entropy method, one can find explicit constructions and counterexamples to several open conjectures in extremal combinatorics and graph theory. Amongst the conjectures we refute are a question of Brualdi and Cao about maximizing permanents of pattern avoiding matrices, and several problems related to the adjacency and distance eigenvalues of graphs."

Will Sawin commented here that "Wagner's paper refutes a conjecture by AutoGraphiX" (and deserved to be in an answer of its own).

Timothy Gowers discussed this on Twitter, summarizing that "the rough idea of the program is to design a suitable reward function, usually very simple, for how good an attempted counterexample is, and let the magic of reinforcement learning do the rest".

Neural networks are also just starting to be used in knot theory!

One of the largest unsolved parts of the field is finding the structure of the smooth Knot Concordance Group. Doing so requires a firm understanding of many knot invariants, chief of which are the $$\tau$$ and $$s$$ invariants of Ozsváth, Szabó, and Rasmussen. These are powerful invariants, both of which are derived from the intrinsic geometry of the knot in question, yet they are very difficult to compute for complicated knots.

The problem of computing these invariants is very conducive to the use of neural networks: there is a large training set (all knots where the computation has already been carried out) and a root in the geometry of the object. Lastly, I would be remiss not to mention that the calculation of these invariants is part of a large scale computational strategy for finding a counterexample to the Smooth 4-dimensional Poincaré conjecture. This is commonly regarded as the largest remaining question in low dimensional topology.

• Is the suggestion that a neural network could be trained to guess certain knot invariants without calculation? 2 days ago
• Yes! In fact, I think this was actually put into practice in the work of Mark C. Hughes, found here: arxiv.org/pdf/1610.05744.pdf 2 days ago
• Neat! I am glad to see it working in practice. It looks like neural network example finding is going to become an increasingly powerful research tool in the coming years. 2 days ago
• I am intrigued by the way you phrased your comment about the smooth 4D Poincaré conjecture. Do most experts suspect that it is false? yesterday
• From my experience, there is an even split among low dimensional topologists. In the subset of knot theorists, it seems more skewed towards the belief that it is false. The reason why: the Smooth 4-dimensional Poincaré conjecture can be disproved by constructing a knot that is smoothly slice in a homotopy $4$-sphere, but not smoothly slice in $S^4$. The $\tau$ invariant is known to obstruct sliceness on ALL homotopy 4-spheres, but there is no such result for the $s$ invariant. Since there are an infinite number of knots, it seems likely that there’s SOME knot out there can provide a disproof! 18 hours ago

There has been some recent efforts in utilizing neural networks to approximate solutions of different types of PDEs. The key advantage of this approach is the possibility of tackling extremely high-dimensional problems, where traditional numerical approach involving discretization proves infeasible as the number of grid points scales exponentially with dimension.

Deep learning approaches sidestep the curse of dimensionality by converting the PDE problem into e.g. minimizing an energy functional https://arxiv.org/abs/1710.00211 or a stochastic optimal control problem https://arxiv.org/abs/2102.11379, then solve the related ERM problem via Monte Carlo sampling, whose convergence is independent of dimension.

• Anil Ananthaswamy did an interesting article about this topic on Quanta Magazine: quantamagazine.org/… Apr 27, 2021 at 13:47

Full disclosure: This is a copy-and-paste of my answer to a question over on CrossValidated (stats Stack Exchange).

See the 2019 preprint Machine Learning meets Number Theory: The Data Science of Birch-Swinnerton-Dyer by Alessandretti, Baronchelli & He. Here is the Abstract:

Empirical analysis is often the first step towards the birth of a conjecture. This is the case of the Birch-Swinnerton-Dyer (BSD) Conjecture describing the rational points on an elliptic curve, one of the most celebrated unsolved problems in mathematics. Here we extend the original empirical approach, to the analysis of the Cremona database of quantities relevant to BSD, inspecting more than 2.5 million elliptic curves by means of the latest techniques in data science, machine-learning and topological data analysis.

Key quantities such as rank, Weierstrass coefficients, period, conductor, Tamagawa number, regulator and order of the Tate-Shafarevich group give rise to a high-dimensional point-cloud whose statistical properties we investigate. We reveal patterns and distributions in the rank versus Weierstrass coefficients, as well as the Beta distribution of the BSD ratio of the quantities. Via gradient boosted trees, machine learning is applied in finding inter-correlation amongst the various quantities. We anticipate that our approach will spark further research on the statistical properties of large datasets in Number Theory and more in general in pure Mathematics.

• This is, in my opinion, a great example of machine learning / statistics work which wastes effort by not incorporating pre-existing mathematical knowledge and heuristics for the topic area. More generally, when working with any dataset, it's important to understand where the data comes from and whether it consists of a biased sample from a larger population. In this case, the elliptic curves in the LMFDB are, by construction, elliptic curves of small conductor (or smallish prime conductor, or highly smooth conductor). This heavily influences the statistics. Apr 17, 2021 at 14:42
• Whole bunch scholar.google.com/…. Apr 17, 2021 at 23:11
• @WillSawin It sounds like a great example of machine learning being thrown at things by people without pausing to understand the proper practice of statistics (Speaking as someone who has friends and colleagues in my department who do theoretical statistics including machine learning) Apr 19, 2021 at 0:32

One application that we urgently need is a "smart" catered TeX-math search engine (eg.an interesting one is https://approach0.xyz/search/ ).

• achieving a collaboration with the people in arxiv to have the engine search through the TeX code of math papers. (So maybe even coming up with some template of math-TeX glossary that we should follow if we want to ease searchability).
• So this would require an engine that is flexible and even present us with search-results that are close but from different areas, establishing interesting bridges.
• I imagine the AI would also be useful here in forming a loose family of theorems and definitions based on topic. Thus giving us a sense of the various directions in math.

Another interesting application would be to help in PDEs with sharpening the various constants. I imagine a really smart AI would be great for running through a wide range of candidate functions and having the cost function just be based on the sharpening of the constant.

• Good idea! The crawlers used in approach0.xyz is open source, so people could eventually add one for arXiv: github.com/approach0/a0-crawlers Dec 7, 2021 at 2:53


text:
# 8.1: Cell Lysis

Source: BiochemFFA_8_1.pdf. The entire textbook is available for free from the authors at http://biochem.science.oregonstate.edu/content/biochemistry-free-and-easy

To separate compounds from cellular environments, one must first break open (lyse) the cells. Cells are broken open, in buffered solutions, to obtain a lysate. There are several ways of accomplishing this.

• Osmotic shock and enzymes: One way to lyse cells is by lowering the ionic strength of the medium the cells are in. This can cause cells to swell and burst. Mild surfactants may be used to disrupt membranes. Most bacteria, yeast, and plant tissues are resistant to osmotic shocks, because of the presence of cell walls, and stronger disruption techniques are usually required. Enzymes may be useful in helping to degrade the cell walls. Lysozyme, for example, is very useful for breaking down bacterial walls. Other enzymes commonly employed include cellulase (plants), proteases, mannases, and others.
• Mechanical disruption: Mechanical agitation may be employed in the form of beads that are shaken with a mixture of cells. In this method, cells are bombarded with tiny, glass beads that break the cells open. Sonication (20-50 kHz sound waves) provides an alternative type of agitation that can be effective. The method is noisy, however, and generates heat that can be problematic for heat-sensitive compounds.
• Pressure disruption: Another means of disrupting cells involves using a “cell bomb”. In this method, cells are placed under very high pressure (up to 25,000 psi) and then the pressure is rapidly released. The rapid pressure change causes dissolved gases in cells to be released as bubbles which, in turn, break open cells.
• Cryopulverization: Cryopulverization is often employed for samples having a tough extracellular matrix, such as connective tissue, seed, and cartilage. In this technique, tissues are frozen using liquid nitrogen and then impact pulverization (typically, grinding, using a mortar and pestle or a powerful electric grinder) is performed. The powder so obtained is then suspended in the appropriate buffer.

Whatever method is employed to create a lysate, crude fractions obtained from it must be further processed via fractionation.

This page titled 8.1: Cell Lysis is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Kevin Ahern, Indira Rajagopal, & Taralyn Tan.

format: plain


text:
# Tag Info

## New answers tagged celestial-mechanics

0

Is there a step in your code that takes an inverse trig function? Each inverse trig function has two answers, a positive and a negative. Calculators and presumably program functions probably just take the positive automatically. I made this mistake once in calculating a gravity assist trajectory for a class problem and your description reminded me of my ...

2

I will simplify this problem by assuming that the only forces come from Newtonian gravity and by limiting the masses of the moons to much smaller values than that of the planets, such that the moons exert a much smaller gravitational forces on all other bodies and therefore can be neglected; so the only sources of gravitational forces are the two planets. ...

0

I suspect that they were lucky that their predictions agreed with reality so closely, but any prediction was going to have Neptune roughly (perhaps very roughly) in the same direction as Uranus, during the times when it affects Uranus the most. So I suspect their calculations meaningfully ruled out large swathes of sky, which improved odds of finding it.

4

Although this may not be what you're looking for... They weren't "simply lucky." In fact, they didn't use Bode's law at all- they used calculations based on Neptune's supposed gravitational effect on Uranus. In fact, had the two used Bode's law, they would never have found Neptune, as the Bode "law" would predict a completely different location. (This is ...

0

The only factor of $\pi$ in the problem comes from the final integral you have to do, which in dimensionless form is $$\int_0^1 \sqrt{\frac{u}{1-u}} du = \frac{\pi}{2}$$ This integral is pretty hard, so if you did it quickly (which I think you did, since you didn't mention any painful integrals here), then you made a mistake here.

5

How “large” is a Lagrange point? L1, L2 and L3 are essentially zero size cause they're never stable. They're still useful cause an orbital near L1, L2 or L3 doesn't require a lot of energy to stay in that general area. so we can use L1, 2 or 3 for not quite stable orbits that don't require much energy adjustment. L1 Halo orbits are used too, not ...

1

Actually, the orbit of the Earth around the Sun is influenced by all the planets and every other gravitating object in the solar system. But their gravitational influences are relatively small compared to the Sun's, and it becomes computationally unwieldily and even impossible to account for the orbital motions of more than two and at most three mutually ...

Top 50 recent answers are included


text:
Principle of measurable choice

Consider the following principle of measurable choice:

Let $$X,Y$$ be complete separable metric spaces and $$E$$ a closed $$\sigma$$-compact subset of $$X\times Y$$. Then $$\pi_1(E)$$ is a Borel set in $$X$$ and there exists a Borel function $$\varphi:\pi_1(E)\to Y$$ whose graph is contained in $$E$$. (Here $$\pi_1$$ denotes the projection of $$X\times Y$$ on $$X$$).

Proof.

Since $$E$$ is $$\sigma$$-compact we can write $$E=\cup_{i=1}^\infty C_i$$ with each $$C_i$$ compact in $$X\times Y$$. Then $$\pi_1(E)=\cup_{i=1}^\infty \pi_1(C_i)$$ with each $$\pi_1(C_i)$$ compact in $$X$$ since $$\pi_1$$ is continuous. Compact subsets of metric spaces are closed, hence Borel. Therefore $$\pi_1(E)$$ is a countable union of Borel sets in $$X$$, hence Borel.

Fix a countable dense subset $$\{y_n:n\in\mathbb{N}\}$$ in $$Y$$. Define $$\varphi_1:\pi_1(E)\to Y$$ by the rule $$\varphi_1(x)=y_{n_1(x)}$$, where $$n_1(x)$$ is the smallest $$n$$ such that $$E\cap \big[\{x\}\times \bar{B}_{1/2}(y_n)\big]\neq \emptyset \quad\quad\quad (1)$$

where $$\bar{B}_{1/2}(y_n):=\{y\in Y: d(y,y_n)\}\leq 1/2\}$$. This is well-defined, since $$x\in \pi_1(E)$$ implies $$(x,y)\in E$$ for some $$y\in Y$$, and by density there exists $$n$$ such that $$d(y_n,y)<1/2$$. Hence the set of $$n$$ satisfying $$(1)$$ is not empty.

Suppose inductively that $$\varphi_k:\pi_1(E)\to Y$$ has been defined for some $$k\geq 1$$. Define $$\varphi_{k+1}:\pi_1(E)\to Y$$ by the rule $$\varphi_{k+1}(x)=y_{n_{k+1}(x)}$$, where $$n_{k+1}(x)$$ is the smallest $$n$$ such that $$E\cap \big[\{x\}\times \bar{B}_{1/2^{k+1}}(y_n)\big]\neq \emptyset \quad \text{and} \quad d(y_n,\varphi_k(x))\leq 1/2^{k-1}\quad\quad\quad (2)$$

This is well-defined, since by definition of $$\varphi_k(x)$$ there exists $$y\in Y$$ such that $$(x,y)\in E\cap \big[\{x\}\times \bar{B}_{1/2^k}(\varphi_k(x))\big]$$, and by density there exists $$n$$ such that $$d(y_n,y)<1/2^{k+1}$$. Then $$(x,y)\in E\cap \big[\{x\}\times \bar{B}_{1/2^{k+1}}(y_n)\big]$$ and by the the triangle inequality $$d(y_n,\varphi_k(x))\leq d(y_n,y)+d(y,\varphi_k(x))\leq 1/2^{k+1}+1/2^k<1/2^{k-1}$$

so the set of $$n$$ satisfying $$(2)$$ is not empty.

Question.

At this point in the proof the author says that a simple induction argument shows that each $$\varphi_k$$ is Borel. This is where am having issues.

Since the range of each $$\varphi_k$$ is contained in $$\{y_n:n\in\mathbb{N}\}$$, it suffices to show that each preimage $$\varphi^{-1}_k(y_n)$$ is Borel in $$\pi_1(E)$$.

Any ideas on how to show it? Thanks for your help.

EDIT. I made some progress below. Any feedback is very appreciated!

Define the following correspondence :

$$\phi:X\to \mathcal P(Y), \quad \phi(x)=\big\{y\in Y: (x,y)\in E\big\}$$

Note that $$\phi(x)\neq\emptyset$$ if and only if $$x\in\pi_1(E)$$. Let $$B$$ a closed set in $$Y$$, and define $$E(B)$$ by

$$E (B):=\big\{x\in X : \phi(x)\cap B\neq \emptyset\big \}=\pi_1\big[(X\times B) \cap E \big]$$

I claim that $$E(B)$$ is Borel in $$\pi_1(E)$$. Indeed $$(X\times B) \cap E=\cup_{i=1}^\infty (X\times B) \cap C_i$$. For each $$i$$, $$(X\times B) \cap C_i$$ is a closed subset of the compact set $$C_i$$ in $$X\times Y$$, and is thus compact in $$X\times Y$$. It follows (as above) that $$\pi_1\big[(X\times B) \cap E \big]=\cup_{i=1}^\infty \pi_1 \big[(X\times B) \cap C_i\big]$$ is a countable union of compact sets in the metric space $$X$$, hence Borel in $$X$$. Clearly, $$\pi_1\big[(X\times B) \cap E \big]\subset \pi_1( E)$$, and so we conclude that $$E(B)$$ is Borel in $$\pi_1(E)$$.

Now let $$A_n=E(B_n)$$ with $$B_n=\bar{B}_{1/2}(y_n)$$ for each $$n$$. Since each $$B_n$$ is closed in $$Y$$, each $$A_n$$ is Borel in $$\pi_1(E)$$ by the previous claim. Moreover, we see that

$$\varphi_1^{-1}(y_n)=A_n\setminus \cup_{i=1}^{n-1}A_i \quad\quad\quad (3)$$

for each $$n$$, and so each preimage is Borel in $$\pi_1(E)$$. It follows that $$\varphi_1$$ is Borel measurable.

Now assume inductively that $$\varphi_k$$ is Borel measurable for some $$k\geq 1$$. Let $$A_n=E(B_n)$$ with $$B_n=\bar{B}_{1/2^{k+1}}(y_n)$$ for each $$n$$. As before each $$A_n$$ is Borel in $$\pi_1(E)$$. Let

$$C_n=A_n\cap \varphi_{k}^{-1}\big[\bar{B}_{1/2^{k-1}}(y_n)\big]$$ for each $$n$$. Since $$\bar{B}_{1/2^{k-1}}(y_n)$$ is closed in $$Y$$ and $$\varphi_k$$ is Borel measurable by assumption, we have that each $$C_n$$ is Borel in $$\pi_1(E)$$. Moreover we have

$$\varphi_{k+1}^{-1}(y_n)=C_n\setminus \cup_{i=1}^{n-1}C_i \quad\quad\quad (4)$$

for each $$n$$, and so each preimage is Borel in $$\pi_1(E)$$. It follows that $$\varphi_{k+1}$$ is Borel measurable.

By induction it follows that each $$\varphi_k$$ is Borel measurable. Note that in $$(3)$$ and $$(4)$$ I assumed each $$y_n$$ to be distinct. The case of a finite dense subset can be handled in the same way.

• May I know this is from which book? Aug 8, 2021 at 16:14
• @user284331 It is the first theorem from this AMS paper: jstor.org/stable/2039503 . Aug 8, 2021 at 16:19
• Can you show that $\varphi_1 (x)$ is Borel? Aug 8, 2021 at 16:52
• @pseudocydonia I made an attempt. Do you think its ok? Aug 9, 2021 at 16:35
• @user284331 I tried to answer in the EDIT section of my post. Do you think this is correct? Aug 9, 2021 at 19:23

For completeness I will finish the proof of the theorem. We have constructed a sequence of Borel functions $$\varphi_k:\pi_1(E)\to Y$$. The next step is to show that this sequence is uniformly Cauchy:

Let $$m>n$$. Then, by the triangle inequality,

$$d(\varphi_m(x),\varphi_n(x))\leq d(\varphi_m(x),\varphi_{m-1}(x))+\dots+d(\varphi_{n+1}(x),\varphi_n(x)) \leq \frac{1}{2^{m-2}}+\dots+\frac{1}{2^{n-1}}=\sum_{i=n}^{m-1}\frac{1}{2^{i-1}}$$

where the second inequality follows from the definition of $$\varphi_k$$ in $$(2)$$ above. Since $$\sum_{i=1}^{\infty}\frac{1}{2^{i-1}}<\infty$$, for any given $$\epsilon>0$$ there exists $$N$$ such that $$\sum_{i=N}^{\infty}\frac{1}{2^{i-1}}<\epsilon$$. Then $$m>n\geq N$$ implies $$d(\varphi_m(x),\varphi_n(x))<\epsilon$$. It follows that $$(\varphi_k)$$ is uniformly Cauchy.

From $$(\varphi_k)$$ uniformly Cauchy and the fact that $$Y$$ is a complete metric space, it follows that $$(\varphi_k)$$ is uniformly convergent to some function $$\varphi:\pi_1(E)\to Y$$. We now use the fact that the pointwise limit of a sequence of measurable functions taking values in a metric space (with its Borel $$\sigma$$-algebra) is again measurable (see here). Therefore $$\varphi$$ is Borel measurable.

It remains to show that the graph of $$\varphi$$ is contained in $$E$$. Consider the distance function on $$X\times Y$$ defined by $$z\mapsto d[E,z]=\inf\{d(w,z) : w\in E\}$$. This function is continuous. Since

$$(x,\varphi_k(x))\to (x,\varphi(x)) \quad \text{as} \quad k\to \infty$$

we obtain $$d[E,(x,\varphi_k(x))]\to d[E,(x,\varphi(x))] \quad \text{as} \quad k\to \infty$$ for all $$x\in \pi_1(E)$$. Moreover, the definition of $$\varphi_k$$ in $$(1),(2)$$ above implies that $$d[E,(x,\varphi_k(x))]\leq\frac{1}{2^k}\to 0$$ as $$k\to\infty$$, and so we conclude that $$d[E,(x,\varphi(x))]=0$$ for all $$x\in \pi_1(E)$$. As $$E$$ is closed, this implies that $$(x,\varphi(x))\in E$$ for all $$x\in \pi_1(E)$$, as desired.

Remark: Only the completeness and separability of $$Y$$ was needed.


text:
• 9
• 16
• 15
• 12
• 9

# Issue with dynamically loaded DLL and null function pointers

This topic is 2949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys, I'm going absolutely mad trying to get my function pointers to work correctly - I can load the DLL, but the function pointers always return an unused value no matter what I do with them, or how I rewrite them. You're looking at many, many hours of frustration, reading, debugging, experimenting and generally getting nowhere. Here's a version with the unecessary gubbins thrown out; Usage (directory and functionName are appropriate and correct strings)
	HINSTANCE hinstLib;

DWORD error = GetLastError();

typedef string(*GetString)();

#ifndef ASEXPORT
#define DLLIMPORTOREXPORT dllimport
#else
#define DLLIMPORTOREXPORT dllexport
#endif

extern "C"__declspec(dllexport) string GetString();

Not that GetLastError returns 0 (completed successfully). Any ideas on what I should be looking at? I've tried writing this in quite a few different ways, so there must be something fundamentally wrong somewhere.

##### Share on other sites
What's the definition of "string"? Does it fail if you use LPWSTR instead of string?

##### Share on other sites
Edit: Clarification.

I just used non-specific string types for the purposes of example.

The real strings in the application are std::string, but have been converted using c_str() when used in the windows function calls. For the record, I'm using the multi-byte character set.

Thanks,

Luke

##### Share on other sites
Are you using that dll header for both the importing and exporting of the functions? Because when you forward declared the GetString function in the dll header you wrote it as:
extern "C"__declspec(dllexport) string GetString();

instead of using the macro that differs on if you are importing or exporting, i.e. like this:

extern "C"__declspec(DLLIMPORTOREXPORT) string GetString();


text:
# Incentive compatibilty conditions for multi-item auctions

In this paper by Myerson on optimal single item auctions, the incentive compatibility condition is shown to be equivalent to the following simpler conditions on the auction - (i) the allocation probability being monotonic in bid (ii) the form of the payment rule.

Is there a similar characterization for multi-item auctions? Any reference regarding this would be helpful.

Let $$x$$ be the vector of willingness-to-pay. Define $$U(x) = \max_z \{ q(z)x - m(z)\}$$ as the equilibrium utility of type $$x$$. The incentive compatibility (I am quoting Krishna now) "implies for all $$x$$, the probability vector $$q(x)$$ is a subgradient of the payoff function $$U$$, which is convex, at the point $$x$$. In other words, the vector $$q(x)$$ is perpendicular to the hyperplane that supports the function $$U$$ at $$x$$ — the graph of the function $$U$$ lies above the hyperplane." He goes on to show that $$U(x) = U(0) + \int_0^1 q (t \cdot x) x d t,$$ where instead of directly integrating over the type $$x$$ you integrate over $$t\in (0,1)$$.


text:
## Kubuntu launch menu no longer takes keyboard input

Ever since I updated to 20.10 I can no longer search for applications in the KDE launch menu. The keyboard works fine for anything else and no amount of clicking on the search bar makes it take input.

## visas – How many days it takes to receive a passport by an express courier return?

I have applied for a UK visa in Paris and I am wondering whether I should choose the express courier return service or not. I have already been troubled a lot by Covid-19 and I want to receive the passport as soon as possible after the decision has been made. However, I am afraid the TLSContact courier service will take too long, or perhaps it may not be something to trust very well. For those who know, how many days it usually takes for such a service to deliver a passport?

## applications – I installed a large app & it won’t install but takes my storage! now I have full storage but haven’t the app?

I’ll be grateful if someone help me! I installed a large app (1.25 G a game) but it won’t install because of my low storage it won’t install said app not installing just like this; but take my storage! now I have full storage but haven’t the app I already cleared the game app and restart my phone but didn’t worked…
I use ES filemanager & always check my storages; before installing that app my storage 79% but now 92% I already searched my internal-storage for any tail of the game but it was nothing.
Btw I have to say I did something like this before and it fixed by itself I think after a little time Im not sure already… ➡My own files pictures, videos ets CAN’T BE 92% its about 600mbs my interal-storage is shown 10.50G & except this I have 2.65Gb installed apps
I have sd card 64G too.
!!!???

## I am trying to understand a python function that takes a list and rearranges the elements in the list

I am trying to understand what `change += change >= i` does in this python code.
The purpose of this code is to take a list and return it but with rearranged element positions.

``````import random
def random_shuffle (lst):
len1 = len(lst)
for i in range(len1):
change = random.randrange(len1 - 1)
change += change >= i
lst (i), lst(change) = lst(change), lst(i)
return lst
``````

## visas – How many days it takes to recieve a passport by an express courier return?

I have applied for the UK visa in Paris and I am wondering whether I should choose the express courier return service or not. I have already been troubled a lot by Covid-19 and I want to recieve the passport as soon as possible after the decesion has been made. However, I am afraid the TLSContact courier service will take too long or perhaps it may not be something to trust very well. For those who know, how many days it usually takes for such a service to deliver a passport?

## number theory – A Diophantine Equation-like Problem that takes consecutive integer values

Let $$(a,b)$$ denote all integers between $$a$$ and $$b$$.

For $$c_1,c_2inmathbf{Q}setminus {0}$$, define
$$begin{equation*} f(x,y)=frac{xy}{c_1x+c_2y} quad text{for}; (x,y)neq(0,0)quadtext{and};; f(0,0)=0. end{equation*}$$
on a set $$Ssubset (a,b)times(c,d)$$ including $$(0,0)$$, for some integers $$a,b,c,d$$. The lattice points set $$S$$ satisfies:

(1) $$f(S)=(u,v)$$ for some integers $$u,v, v-ugeq 2$$, namely $$f(x,y)$$ is an integer for all $$(x,y)in S$$ and the range consists of consecutive integers with at least three of them;
(2) The projection of $$S$$ onto $$x,y-$$axis are $$(a,b)$$ and $$(c,d)$$, respectively;
(3) If $$(x_1,y_1),(x_2,y_2)in S$$, then $$x_1y_2=x_2y_1neq 0$$ never happens.

I suspect that the parameters $$c_1,c_2,a,b,c,d,S,u,v$$ as above do not exist, but have no idea disproving it. Can anyone give some ideas for it? Thanks a lot.

## PayPal just gave 346 million people a new way to buy Bitcoin. Do you have what it takes to ride the next big wave?

Are you ready to to take a ride on the next big bubble on the internet and on the stock market?

## multi classing – Does a PF2e spellcaster who takes multiclass dedications into other spellcasting classes, and related spellcasting feats, gain more spell slots?

Ezren is a level 10 evocation wizard, and hence would have spell slots of the following levels:

``````+-------------+-----------------+
| Spell level | Number of slots |
+-------------+-----------------+
|           1 |               4 |
|           2 |               4 |
|           3 |               4 |
|           4 |               4 |
|           5 |               4 |
+-------------+-----------------+
``````

However, at level 2 Ezren took the Sorcerer multiclass dedication. At level 4 he took Basic Sorcerer Spellcasting, and Bloodline Breadth at level 8.

How many spell slots does Ezren have in a given day? Is it:

``````+-------------+-----------------+
| Spell level | Number of slots |
+-------------+-----------------+
|           1 |               6 |
|           2 |               6 |
|           3 |               6 |
|           4 |               4 |
|           5 |               4 |
+-------------+-----------------+
``````

Because at level 8, spellcasting archetype feats grant an additional spell slot of first, second and third level, AND the bloodline breadth feat increases each of these by one?

Or do these sources of spell slots not stack for some reason? Coming from fifth edition, a wizard who multiclasses sorcerer still has the same number of spell slots as a pure wizard, so I’d like to clarify my understanding here.

## dnd 5e – What is damage you do vs. damage a creature takes? (and Dark One’s Blessing)

The Warlock ability Dark One’s Blessing says (emphasis mine)

Starting at 1st level, when you reduce a hostile creature to 0 hit points, you gain temporary hit points equal to your Charisma modifier + your warlock level (minimum of 1).

Is there a general ruling on who or what is the author of damage? Most spells and attacks are written to describe how the target takes damage, rather than how the attacker does damage. I think it is safe to assume that an attack you make or a spell you cast is you doing damage, but I am unsure on how to rule in a more abstract example, such as forcing an interaction with a damaging environment.

Consider the following hypotheticals. None of them are my specific question, but serve to illustrate what I am trying to come to terms with. My question is whether there is a general underlying principle in the game that assigns authorship to damage.

For example, suppose oil has been spread on the floor and a hostile creature chooses to cross it. My warlock throws a lit torch into the oil and the DM requires an attack roll. The subsequent fire reduces the creature to 0hp. Does the warlock get to use Dark One’s Blessing?

Suppose the same warlock lights a nearby patch of oil on the floor and the DM does not require an attack roll. A hostile creature later chooses to enter the burning oil and is reduced to 0hp. Does the warlock get to use the ability? Did he reduce the creature to 0hp, or did the fire? Does it matter that the creature chose to enter the fire through its own movement – if the warlock had been able to use a spell or action to force the movement, would the answer be different?

Finally, consider three warlocks who all have initiative before a target. One throws a flask of oil on the floor, one throws a torch that ignites the oil, and one uses a shove attack to move a hostile creature into the space where the flaming oil is / will be. Which warlock(s) get to use Dark One’s Blessing? Does their order matter? That is, is it a different answer if the shove moves the creature to the space where the oil will be, vs. to a space where the flame already is?

Possibly related: If my familiar is forced through my action to drop a rock while over a target, is it considered an attack?

## files – ExtensionDiscovery::scanDirectory() takes too long

I have been debugging a bit an issue on our platform and I notice that our scanDirectory takes, from time to time, way to long, more than 100seconds.
I have been looking at the default.settings.php and I noticed

``````/**
* The default list of directories that will be ignored by Drupal's file API.
*
* By default ignore node_modules and bower_components folders to avoid issues
* with common frontend tools and recursive scanning of directories looking for
* extensions.
*
* @see file_scan_directory()
* @see DrupalCoreExtensionExtensionDiscovery::scanDirectory()
*/
\$settings('file_scan_ignore_directories') = (
'node_modules',
'bower_components',
'vendor',
);
``````

I found that out that our sites/default directory is the one to blame.
Can I just add it here? Or should I include the subdirectories(fx sites/default/files)?

I am really surprised about this one. Been working with drupal years now and I see this first time!


text:
# fatf.utils.data.segmentation.QuickShift¶

class fatf.utils.data.segmentation.QuickShift(image, segmentation_mask=None, ratio=0.2, kernel_size=4, max_dist=200)[source]

Wraps the quickshift segmentation algorithm implemented in scikit-image.

New in version 0.1.1.

This class provides an interface for the quickshift segmentation implemented by the skimage.segmentation.quickshift function.

For the documentation see the specification of the fatf.utils.data.segmentation.Segmentation abstract class. The initialisation parameters specific to the quickshift segmenter are documented below. The parameter values for ratio, kernel_size and max_dist are by default set to the values used by the official LIME implementation.

Parameters
rationumber, optional (default=0.2)

Balances color-space proximity and image-space proximity. Higher values give more weight to color-space. Between 0 and 1.

kernel_sizenumber, optional (default=4)

Width of Gaussian kernel used in smoothing the sample density. Higher means fewer clusters.

max_distnumber, optional (default=200)

Cut-off point for data distances. Higher means fewer clusters.

Attributes
segments

Retrieves the segments.

Raises
TypeError

The ratio, kernel size or max dist parameter is not an integer.

ValueError

The ratio parameter is outside of the 0–1 range.

Methods

 grayout_segments([segments_subset, mask, image]) Grays out a selected subset of segments in the RGB image. highlight_segments([segments_subset, mask, …]) Highlights image segments by translucently colouring them. mark_boundaries([mask, image, colour]) Marks segment boundaries atop the image used to initialise this class. merge_segments(segments_grouping[, inplace, …]) Merges segments based on the provided grouping. number_segments([segments_subset, mask, …]) Plots segment numbers on top of the image. set_segments(segments) Manually overwrites the segmentation with custom segments.
grayout_segments(segments_subset=None, mask=False, image=None)[source]

Grays out a selected subset of segments in the RGB image.

The graying out can either be applied on top of the image or segmentation mask (mask=True) used to initialise this class. Alternatively, an external RGB image of the same dimensions can be supplied. By default all the segments are grayed out; a selected subset of segments can be grayed out by providing the segments_subset parameter.

Parameters
segments_subsetintiger or list(integer), optional (default=None)

A number of a specific segment or a list of segments to be grayed out. By default (None) all the segments are grayed out.

If True, gray out the segmentation mask; if False, gray out the image (default).

imagenumpy.ndarray, optional (default=None)

If provided, this image will be grayed out instead of the one used to initialise this segmenter.

Returns
image_grayscalenumpy.ndarray

A numpy array holding the image with the selected subset of segments grayed out.

Raises
IncorrectShapeError

The the height or width the image array does not agree with the dimensions of the class image or the image is not RGB.

RuntimeError

The class has been initialised with a black-and-white or grayscale image.

TypeError

The mask parameter is not a boolean. The segments_subset parameter is neither None, an integer, or a list of integers; one of the segment ids in this list is not an integer.

ValueError

One of the segment ids provided via segments_subset is invalid for the class segmentation, the list of segments is empty or some of its elements are duplicated.

highlight_segments(segments_subset=None, mask=False, image=None, colour=None)[source]

Highlights image segments by translucently colouring them.

The highlighting can either be applied on top of the image or segmentation mask (mask=True) used to initialise this class. Alternatively, an external image of the same dimensions can be supplied. By default all the segments are highlighted; a selected subset of segments can be highlighted by providing the segments_subset parameter. The segments are highlighted with different colours by default (colour=None); alternatively, a single colour can be supplied with the colour parameter. It is also possible to specify a unique colour for each segment by setting colour to a list of RGB triplets; in this case the list must have the same length as the number of segments being highlighted.

Parameters
segments_subsetintiger or list(integer), optional (default=None)

A number of a specific segment or a list of segments to be highlighted. By default (None) all the segments are highlighted.

If True, highlight the segmentation mask; if False, highlight the image (default).

imagenumpy.ndarray, optional (default=None)

If provided, this image will be highlighted instead of the one used to initialise this segmenter.

colourtuple(integer, integer, integer) or list(tuple(integer, integer, integer)), optional (default=None)

If provided, the regions will be highlighted with a single RGB colour or each segment will be highlighted with its unique colour. By default (None) every segment receives a unique colour.

Returns
image_highlightednumpy.ndarray

A numpy array holding the image with the selected subset of segments highlighted.

Raises
IncorrectShapeError

The the height or width the image array does not agree with the dimensions of the class image.

TypeError

The mask parameter is not a boolean. The colour parameter is neither of None, a tuple or a list of tuples; or one of its elements is not an integer. The segments_subset parameter is neither None, an integer, or a list of integers; one of the segment ids in this list is not an integer.

ValueError

If colour is provided as a list, the list is either empty or the number of colours provided is not the same as the number of segments chosen to be highlighted. A colour is not a 3-tuple or one of its elements is outside of the 0–255 range. One of the segment ids provided via segments_subset is invalid for the class segmentation, the list of segments is empty or some of its elements are duplicated.

mark_boundaries(mask=False, image=None, colour=None)[source]

Marks segment boundaries atop the image used to initialise this class.

The boundaries can either be overlaid on top of the image or segmentation mask (mask=True) used to initialise this class. Alternatively, an external image of the same dimensions can be supplied.

Note

If the image is grayscale, it will be converted to RGB to display the segment boundaries.

Parameters

If True, plot the segment boundaries on top of the segmentation mask; if False, plot the segment boundaries atop the image.

imagenumpy.ndarray, optional (default=None)

If provided, the segment boundaries will be overlaid atop this image instead of the one used to initialise this segmenter.

colourtuple(integer, integer, integer), optional (default=None)

If provided, the segment boundaries will be plotted with this RGB colour.

Returns
marked_imagenumpy.ndarray

A numpy array holding the image with overlaid segment boundaries.

Raises
IncorrectShapeError

The the height or width the image array does not agree with the dimensions of the class image.

TypeError

The mask parameter is not a boolean. The colour parameter is neither a tuple nor a None; or one of its elements is not an integer.

ValueError

The colour parameter is not a 3-tuple, one of its elements is outside of the 0–255 range.

merge_segments(segments_grouping, inplace=True, segments=None)[source]

Merges segments based on the provided grouping.

The merging can either be applied to the segmentation stored in the class to a segmentation passed as a parameter (segments). By default (inplace=True) the segmentation stored in the class will be updated to the merged segmentation.

Parameters
segments_groupinglist(integer) or list(list(integer))

A collection or a set of collections of segment ids to be merged.

inplaceboolean, optional (default=True)

If True, overwrite the segmentation stored in the class.

segmentsnumpy.ndarray, optional (default=None)

If provided, the merging will be performed on this segmentation instead of the one stored in the class.

Returns
merged_segmentsnumpy.ndarray

A 2-dimensional numpy array holding the merged segmentation.

Raises
IncorrectShapeError

The segments array is not 2-dimensional. The the height or width the segments array does not agree with the dimensions of the segmented image.

TypeError

The segments array is either a structured numpy array or it is not an integer-valued array. The inplace parameter is not a boolean. The segments grouping is not a list of integers or lists. One of the segment ids is not an integer.

ValueError

The unique elements of the segments array do not form a continuous sequence starting at 1. The segments grouping is an empty lists or the list has duplicates. One of the segment ids is invalid or appears across different groupings.

number_segments(segments_subset=None, mask=False, image=None, colour=None)[source]

Plots segment numbers on top of the image.

The numbering can either be overlaid on top of the image or segmentation mask (mask=True) used to initialise this class. Alternatively, an external image of the same dimensions can be supplied. By default all the segments are numbered; a selected subset of segments can be numbered by providing the segments_subset parameter. The colour of the numbers can be specified via the colour parameter by passing an RGB triplet.

Note

The numbers may not be printed within the bounds of their respective segments when these are not convex.

Parameters
segments_subsetintiger or list(integer), optional (default=None)

A number of a specific segment to be numbered or a list of segments to be numbered. By default (None) all the segments are numbered.

If True, number the segmentation mask; if False, number the image (default).

imagenumpy.ndarray, optional (default=None)

If provided, this image will be numbered instead of the one used to initialise this segmenter.

colourtuple(integer, integer, integer), optional (default=None)

If provided, the numbers will be plotted with this RGB colour.

Returns
numbered_imagenumpy.ndarray

A numpy array holding the image with the selected subset of segments numbered.

Raises
IncorrectShapeError

The the height or width the image array does not agree with the dimensions of the class image.

TypeError

The mask parameter is not a boolean. The colour parameter is neither a tuple nor a None; or one of its elements is not an integer. The segments_subset parameter is neither None, an integer, or a list of integers; one of the segment ids in this list is not an integer.

ValueError

The colour parameter is not a 3-tuple, one of its elements is outside of the 0–255 range. One of the segment ids provided via segments_subset is invalid for the class segmentation, the list of segments is empty or some of its elements are duplicated.

property segments

Retrieves the segments.

set_segments(segments)[source]

Manually overwrites the segmentation with custom segments.

segments must be a non-structured, 2-dimensional, integer-valued numpy array with a continuous sequence of unique elements starting at 1, which indicate the segment assignment of each pixel. The dimension of segments must agree with the width and height of the segmented image.

Note

The same can be achieved by directly setting the self.segments with my_segmenter.segments = segments. (A dedicated setter method takes care of validating the correctness of segments.)

Parameters
segmentsnumpy.ndarray

A 2-dimensional numpy array representing a segmentation.

Raises
IncorrectShapeError

The segments array is not 2-dimensional. The the height or width the segments array does not agree with the dimensions of the segmented image.

TypeError

The segments array is either a structured numpy array or it is not an integer-valued array.

ValueError

The unique elements of the segments array do not form a continuous sequence starting at 1.


text:
# Write 35 divided by 7 in three different ways. What is the quotient?

do they mean 35 divided by 5= 7 , 35 divided by 7= 5 or by sign?

1. 👍
2. 👎
3. 👁
4. ℹ
5. 🚩

1. They mean 35 ÷ 7 = 5

It can be written as I did above.
It can be written as you did above: 35 divided by 7 = 5
It can be written as a fraction: 35/7 = 5

1. 👍
2. 👎
3. ℹ
4. 🚩
2. 35/7, 35 ÷ 7, and 35 x (1/7) would be three ways. (There are more)

The quotient is 5.

1. 👍
2. 👎
3. ℹ
4. 🚩
3. 17 divided by 17 ans

1. 👍
2. 👎
3. ℹ
4. 🚩
4. 17 divided by 35

1. 👍
2. 👎
3. ℹ
4. 🚩
5. Write 35 divided by 7 in three different ways ? What is the quotient?

1. 👍
2. 👎
3. ℹ
4. 🚩


text:
# Prove that if B is symmetric, then ||B|| is the largest eigenvalue of B.

Question

Prove that if B is symmetric, then ||B|| is the largest eigenvalue of B.


text:
# Matrices

• Nov 19th 2009, 10:44 AM
Matrices

Im trying to evaluate the following, but not sure if i'm going wrong,could someone please check this.

Evaluating 2A + 3B

Where

$A = \left(\begin{array}{cc}3&7\\4&-1\\-5&2\end{array}\right)$ $B = \left(\begin{array}{cc}-5&-3\\10&6\end{array}\right)$

To evaluate i use the scalar multiplication?

so:

2A becomes = $\left(\begin{array}{cc}6&14\\8&-2\\-10&4\end{array}\right)$

and

3B becomes= $\left(\begin{array}{cc}-15&9\\30&18\end{array}\right)$

So my dillema is, i cant add these together can i because the incorrect rows to columns - or am i thinking this through to much?

• Nov 19th 2009, 10:57 AM
masters
Quote:

Im trying to evaluate the following, but not sure if i'm going wrong,could someone please check this.

Evaluating 2A + 3B

Where

$A = \left(\begin{array}{cc}3&7\\4&-1\\-5&2\end{array}\right)$ $B = \left(\begin{array}{cc}-5&-3\\10&6\end{array}\right)$

To evaluate i use the scalar multiplication?

so:

2A becomes = $\left(\begin{array}{cc}6&14\\8&-2\\-10&4\end{array}\right)$

and

3B becomes= $\left(\begin{array}{cc}-15&9\\30&18\end{array}\right)$

So my dillema is, i cant add these together can i because the incorrect rows to columns - or am i thinking this through to much?


text: We gives a short proof of the inequality, which we call (*1) here, right after inequality (14) in [KT01], where they did not gives much details in the paper. We need the following Lemma. **Lemma 10:** In Euclidean space $\mathbb{R}^n$, we denote by $B(x,r)$ the ball centered at $x$ with radius $r$. If $$\sup_{x} \int_{B(x,1)} \abs{f(y)} dy < \infty,$$ then $$\int_{B(x_0,1)^c} \f{1}{\abs{x_0-y}^{n+1}}\abs{f(y)} dy \leq c \sup_{x} \int_{B(x,1)} \abs{f(y)} dy,$$ for all $x_0\in \mathbb{R}^n$ and some constant $c>0$ independent of $x_0$. **//Proof://** We prove the case when $n=1$, the general case can be proved similarly but a little bit sophisticated. WLOG, we assume that $x_0=0$. $$\begin{split} \int_{B(0,1)^c} \f{1}{\abs{y}^2} \abs{f(y)} dy &= \sum_{k=1}^\infty \int_{B(\pm 2k ,1)} \f{1}{\abs{y}^2} \abs{f(y)} dy ~\\ &\leq \sum_{k=1}^\infty \f{1}{(2k-1)^2}\cdot 2\sup_{x} \int_{B(x,1)} \abs{f(y)}dy ~\\ &\lesssim \sup_{x} \int_{B(x,1)} \abs{f(y)}dy. \end{split}$$ **Remark:** Since Lebesgue measure is doubling measure, we can prove Lemma 10 with cubes. We split the space $\mathbb{R}^n$ into many congruent cubes, and then apply similar arguments as for the case $n=1$. === Proof of (*1) By definition, we have $$\begin{split} V\grad\Pi f = \int_0^t \grad\Pi S(s)f(t-s)ds ~\\ =\int_0^t \int k(y,s)f(x-y,t-s)dyds \end{split}$$ === References [KT01] H. Koch and D. Tataru, Well-posedness for the Navier-Stokes equations, Adv. Math. 157, 22-35 (2001)


text:
DX11 Problem with displaying Cube in DX11

Recommended Posts

Cranberry    147

Hey Guys,

I'm developing a game using DirectX 11, so I started of by creating the basic structure and tried to render a simple cube.

The problem is that the cube is somehow stretched vertically over the window and the colors (red for top / blue for bottom) are mixed:

I checked everything via the Graphics Debugger and all the values seem to be okay, but the cube already looks strange in the vertex shader:

I thought there might be a problem with the projection matrix but it looks okay to me:

m_ProjectionMatrix = XMMatrixPerspectiveFovLH(0.25f*3.14159265359, (float)m_pWindow->GetHeight() / (float)m_pWindow->GetWidth(), 1.0f, 1000.0f);

Has anyone had the same problem or does anybody know how I could solve this problem?

Cranberry

Edited by Cranberry

Share on other sites
MJP    19755

Are you setting the viewport properly?

Share on other sites
Cranberry    147
D3D11_VIEWPORT viewPort;
viewPort.TopLeftX = 0.0f;
viewPort.TopLeftY = 0.0f;
viewPort.Width = static_cast<float>(pWindow->GetWidth());
viewPort.Height = static_cast<float>(pWindow->GetHeight());
viewPort.MinDepth = 0.0f;
viewPort.MaxDepth = 1.0f;

Looks fine to me.

MJP    19755

Share on other sites
Cranberry    147

cbuffer cbPerObject
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
};

struct VertexIn
{
float3 Pos : POSITION;
float4 Color : COLOR;
};

struct VertexOut
{
float4 PosH : SV_POSITION;
float4 Color : COLOR;
};

VertexOut VS(VertexIn vin)
{
VertexOut vout;
vout.PosH = mul(float4(vin.Pos, 1.0f), worldMatrix);
vout.PosH = mul(vout.PosH, viewMatrix);
vout.PosH = mul(vout.PosH, projectionMatrix);
vout.Color = vin.Color;
return vout;
}

float4 PS(VertexOut pin) : SV_TARGET
{
return pin.Color;
}

Yeah I transpose all three of them.

Here's my Render function, maybe you can spot a mistake:

void Game::Render()
{
m_pRenderSystem->PreRender();

//Set geometry buffers
UINT stride = sizeof(Vertex);
UINT offset = 0;

m_pRenderSystem->GetDeviceContext()->IASetVertexBuffers(0, 1, &m_pCubeVertexBuffer, &stride, &offset);
m_pRenderSystem->GetDeviceContext()->IASetIndexBuffer(m_pCubeIndexBuffer, DXGI_FORMAT_R32_UINT, 0);

//Set constant buffer
D3D11_BUFFER_DESC cbPerObjectDesc;
cbPerObjectDesc.Usage = D3D11_USAGE_DYNAMIC;
cbPerObjectDesc.ByteWidth = sizeof(cbPerObject);
cbPerObjectDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
cbPerObjectDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
cbPerObjectDesc.MiscFlags = 0;
cbPerObjectDesc.StructureByteStride = 0;

m_pRenderSystem->GetDevice()->CreateBuffer(&cbPerObjectDesc, 0, &m_cbPerObject);

D3D11_MAPPED_SUBRESOURCE mappedResource;
cbPerObject* dataPtr;
unsigned int bufferNumber;

dataPtr = (cbPerObject*) mappedResource.pData;

XMMatrixTranspose(m_WorldMatrix);
XMMatrixTranspose(m_ViewMatrix);
XMMatrixTranspose(m_ProjectionMatrix);

dataPtr->worldMatrix = m_WorldMatrix;
dataPtr->viewMatrix = m_ViewMatrix;
dataPtr->projectionMatrix = m_ProjectionMatrix;

m_pRenderSystem->GetDeviceContext()->Unmap(m_cbPerObject, 0);

// Set the position of the constant buffer in the vertex shader.
bufferNumber = 0;

// Finanly set the constant buffer in the vertex shader with the updated values.
m_pRenderSystem->GetDeviceContext()->VSSetConstantBuffers(bufferNumber, 1, &m_cbPerObject);

//Draw cube
m_pRenderSystem->GetDeviceContext()->DrawIndexed(36, 0, 0);

m_pRenderSystem->PostRender();
}

Share on other sites
ongamex92    3255

vout.PosH = mul(float4(vin.Pos, 1.0f), worldMatrix);
vout.PosH = mul(vout.PosH, viewMatrix);
vout.PosH = mul(vout.PosH, projectionMatrix);

and

XMMatrixTranspose(m_WorldMatrix);

Should give you the deriered multiplication order. (im not in touch with XMMath)

Share on other sites
MJP    19755

XMMatrixTranspose will return the transpose of the matrix, it won't modify the matrix that's passed in as its argument. So you either need to assign the result to a temporary variable, or assign the result directly to your mapped constant buffer data.

As the above poster suggested, you can tell the shader compiler to expect row-major matrices which will allow you to skip the annoying transpose step in your C++ code. To do this you can use the pragma that he mentioned, or you can add "row_major" to the declaration of the matrix in your HLSL constant buffer definition. There are also flags that you can pass to fxc.exe or D3DCompile that will achieve the same thing.

Share on other sites
Cranberry    147

Thank you so much!

I was thinking of the old D3DXTransposeMatrix which modified the matrix via a reference.

Create an account

Register a new account

• Similar Content

• By isu diss
I'm trying to code Rayleigh part of Nishita's model (Display Method of the Sky Color Taking into Account Multiple Scattering). I get black screen no colors. Can anyone find the issue for me?

• By Endurion
I have a gaming framework with an renderer interface. Those support DX8, DX9 and latest, DX11. Both DX8 and DX9 use fixed function pipeline, while DX11 obviously uses shaders. I've got most of the parts working fine, as in I can switch renderers and notice almost no difference. The most advanced features are 2 directional lights with a single texture
My last problem is lighting; albeit there's documentation on the D3D lighting model I still can't get the behaviour right. My mistake shows most prominently in the dark side opposite the lights. I'm pretty sure the ambient calculation is off, but that one's supposed to be the most simple one and should be hard to get wrong.
Interestingly I've been searching high and low, and have yet to find a resource that shows how to build a HLSL shader where diffuse, ambient and specular are used together with material properties. I've got various shaders for all the variations I'm supporting. I stepped through the shader with the graphics debugger, but the calculation seems to do what I want. I'm just not sure the formula is correct.
This one should suffice though, it's doing two directional lights, texture modulated with vertex color and a normal. Maybe someone can spot one (or more mistakes). And yes, this is in the vertex shader and I'm aware lighting will be as "bad" as in fixed function; that's my goal currently.
• By Mercesa
Hey folks. So I'm having this problem in which if my camera is close to a surface, the SSAO pass suddenly spikes up to around taking 16 milliseconds.
When still looking towards the same surface, but less close. The framerate resolves itself and becomes regular again.
This happens with ANY surface of my model, I am a bit clueless in regards to what could cause this. Any ideas?
In attached image: y axis is time in ms, x axis is current frame. The dips in SSAO milliseconds are when I moved away from the surface, the peaks happen when I am very close to the surface.

Edit: So I've done some more in-depth profiling with Nvidia nsight. So these are the facts from my results
Count of command buffers goes from 4 (far away from surface) to ~20(close to surface).
The command buffer duration in % goes from around ~30% to ~99%
Sometimes the CPU duration takes up to 0.03 to 0.016 milliseconds per frame while comparatively usually it takes around 0.002 milliseconds.
I am using a vertex shader which generates my full-screen quad and afterwards I do my SSAO calculations in my pixel shader, could this be a GPU driver bug? I'm a bit lost myself. It seems there could be a CPU/GPU resource stall. But why would the amount of command buffers be variable depending on distance from a surface?

Edit n2: Any resolution above 720p starts to have this issue, and I am fairly certain my SSAO is not that performance heavy it would crap itself at a bit higher resolutions.

• In DirectX 11 we have a 24 bit integer depth + 8bit stencil format for depth-stencil resources ( DXGI_FORMAT_D24_UNORM_S8_UINT ). However, in an AMD GPU documentation for consoles I have seen they mentioned, that internally this format is implemented as a 64 bit resource with 32 bits for depth (but just truncated for 24 bits) and 32 bits for stencil (truncated to 8 bits). AMD recommends using a 32 bit floating point depth buffer instead with 8 bit stencil which is this format: DXGI_FORMAT_D32_FLOAT_S8X24_UINT.
Does anyone know why this is? What is the usual way of doing this, just follow the recommendation and use a 64 bit depthstencil? Are there performance considerations or is it just recommended to not waste memory? What about Nvidia and Intel, is using a 24 bit depthbuffer relevant on their hardware?
Cheers!

• By gsc
Hi! I am trying to implement simple SSAO postprocess. The main source of my knowledge on this topic is that awesome tutorial.
But unfortunately something doesn't work... And after a few long hours I need some help. Here is my hlsl shader:
float3 randVec = _noise * 2.0f - 1.0f; // noise: vec: {[0;1], [0;1], 0} float3 tangent = normalize(randVec - normalVS * dot(randVec, normalVS)); float3 bitangent = cross(tangent, normalVS); float3x3 TBN = float3x3(tangent, bitangent, normalVS); float occlusion = 0.0; for (int i = 0; i < kernelSize; ++i) { float3 samplePos = samples[i].xyz; // samples: {[-1;1], [-1;1], [0;1]} samplePos = mul(samplePos, TBN); samplePos = positionVS.xyz + samplePos * ssaoRadius; float4 offset = float4(samplePos, 1.0f); offset = mul(offset, projectionMatrix); offset.xy /= offset.w; offset.y = -offset.y; offset.xy = offset.xy * 0.5f + 0.5f; float sampleDepth = tex_4.Sample(textureSampler, offset.xy).a; sampleDepth = vsPosFromDepth(sampleDepth, offset.xy).z; const float threshold = 0.025f; float rangeCheck = abs(positionVS.z - sampleDepth) < ssaoRadius ? 1.0 : 0.0; occlusion += (sampleDepth <= samplePos.z + threshold ? 1.0 : 0.0) * rangeCheck; } occlusion = saturate(1 - (occlusion / kernelSize)); And current result: http://imgur.com/UX2X1fc
I will really appreciate for any advice!

• 21
• 15
• 18
• 10
• 18


text:
# Math Help - Reduction Formula

1. ## Reduction Formula

Hey there, I've been struggling with this one for quite a while; so much so that I created an account on here so that I could ask for some help

I(n) = integral of ((e^sinx)(cosx)(sin^n x))

I need to show that it comes down to I(n) = e - n I(n-1)

The integral doesn't have any limits, but I'm pretty sure I need to integrate by parts, but I've tried all the different combinations for u and dv/dx and haven't gotten anywhere.

Thanks for the help

2. ## Re: Reduction Formula

First make the substitution y= sin(x). What does that integral become? Now use integration by parts.

3. ## Re: Reduction Formula

Originally Posted by HallsofIvy
First make the substitution y= sin(x). What does that integral become? Now use integration by parts.
Wow I never even thought of doing a substitution on a reduction formula question. I've been used to doing it by parts.

Yh that really simplifies things, thanks

4. ## Re: Reduction Formula

Originally Posted by HallsofIvy
First make the substitution y= sin(x). What does that integral become? Now use integration by parts.
I get to I(n) = (y^n)(e^y) - n I(n-1)

In order for me to prove what I need to, I must show that (y^n)(e^y) = e which I'm pretty sure isn't the case. Any tips on what I can do?

Thanks

5. ## Re: Reduction Formula

Ivanstefanov will write a c/c++ program/project for \$5, only on fiverr.com

I will write a C/C++ program/project.
I'm writing programs from more than 10 years also studied at the university ,math and computer science.I'm glad to help you with all i can for your homework ,assignment or project you want to write.


text:
# Randomness

Remember when you first started programming here? Perhaps you wanted to draw a lot of circles on the screen. So you said to yourself: “Oh, I know. I’ll draw all these circles at random locations, with random sizes and random colors.” In a computer graphics system, it’s often easiest to seed a system with randomness. In these lessons, however, we’re looking to build systems modeled on what we see in nature. Defaulting to randomness is not a particularly thoughtful solution to a design problem—particularly the kind of problem that involves creating an organic or natural-looking simulation.

With a few tricks, we can change the way we use random() to produce “non-uniform” distributions of random numbers. This will come in handy throughout this course as we look at a number of different scenarios. When we examine genetic algorithms, for example, we’ll need a methodology for performing “selection”—which members of our population should be selected to pass their DNA to the next generation? Remember the concept of survival of the fittest? Let’s say we have a population of monkeys evolving. Not every monkey will have an equal chance of reproducing. To simulate Darwinian evolution, we can’t simply pick two random monkeys to be parents. We need the more “fit” ones to be more likely to be chosen. We need to define the “probability of the fittest.” For example, a particularly fast and strong monkey might have a 90% chance of procreating, while a weaker one has only a 10% chance.

Let’s pause here and take a look at probability’s basic principles. First we’ll examine single event probability, i.e. the likelihood that a given event will occur.

If you have a system with a certain number of possible outcomes, the probability of the occurrence of a given event equals the number of outcomes that qualify as that event divided by the total number of all possible outcomes. A coin toss is a simple example—it has only two possible outcomes, heads or tails. There is only one way to flip heads. The probability that the coin will turn up heads, therefore, is one divided by two: 1/2 or 50%.

Take a deck of fifty-two cards. The probability of drawing an ace from that deck is:

number of aces / number of cards = 4 / 52 = 0.077 = ~ 8%

The probability of drawing a diamond is:

number of diamonds / number of cards = 13 / 52 = 0.25 = 25%

We can also calculate the probability of multiple events occurring in sequence. To do this, we simply multiply the individual probabilities of each event.

The probability of a coin turning up heads three times in a row is:

(1/2) * (1/2) * (1/2) = 1/8 (or 0.125)

…meaning that a coin will turn up heads three times in a row one out of eight times (each “time” being three tosses).

Want to review probability before continuing? Study compound events and dependent probability.

There are a couple of ways in which we can use the random() function with probability in code. One technique is to fill an array with a selection of numbers—some of which are repeated—then choose random numbers from that array and generate events based on those choices.

Running this code will produce a 40% chance of printing the value 1, a 20% chance of printing 2, and a 40% chance of printing 3.

We can also ask for a random number (let’s make it simple and just consider random decimal values between 0 and 1) and allow an event to occur only if our random number is within a certain range. Check out the example below, and keep clicking restart until the randomly picked number is finally less than the threshold:

This method can also be applied to multiple outcomes. Let’s say that Outcome A has a 60% chance of happening, Outcome B, a 10% chance, and Outcome C, a 30% chance. We implement this in code by picking a random number and seeing into what range it falls.

• between 0.00 and 0.60 (60%) –> Outcome A

• between 0.60 and 0.70 (10%) –> Outcome B

• between 0.70 and 1.00 (30%) –> Outcome C

Click the restart button to see how often you get different outcomes:

We could use the above methodology to create a random walker that tends to move to the right. Here is an example of a Walker with the following probabilities:

• chance of moving up: 20%

• chance of moving down: 20%

• chance of moving left: 20%

• chance of moving right: 40%

This "Natural Simulations" course is a derivative of "The Nature of Code" by Daniel Shiffman, used under a Creative Commons Attribution-NonCommercial 3.0 Unported License.


text:
# Change line spacing for normal text, but not in tabular or verse

\usepackage{setspace}
\doublespacing

I used above two lines to change the spacing in my document. This changes the spacing of the entire document.

My requirement is to change the line spacing in paragraphs only. I want to leave the verse and table environments as they are. I just want to change the paragraphs. I did not put paragraphs in any environment. Do I need to do that as well?

-
Are you actually referring to the table environment (a float environment) or do you mean tabular (producing the actual table)? If the latter is the case, please edit your question accordingly. You can use backticks  to mark your inline code as I did in my edit. And perhaps you could change the title to something more specific, e.g. "Change line spacing for normal text, but not in tabular/table or verse". –  doncherry Aug 20 '11 at 12:43

\documentclass{article}

\usepackage{etoolbox}
\usepackage[doublespacing]{setspace}

\AtBeginEnvironment{verse}{\singlespacing}
\AtBeginEnvironment{tabular}{\singlespacing}

\usepackage{lipsum}% just for blindtext

\begin{document}

\lipsum[1]

\begin{verse}
\lipsum[1]
\end{verse}

\lipsum[1]

\begin{tabular}{p{10cm}}
\lipsum[1]
\end{tabular}

\lipsum[1]

\end{document}

This patches the verse and tabular environment to use a \singlespacing at their beginning. The table environment isn't affected by [doublespacing] and thus doesn't need any patching, but you probably want to use tabular.

-
If the tabular isn't wrapped in the table environment (which it probably isn't for Aku's document) this won't work, and you'll have to patch the tabular environment in the same way you did the verse environment. –  Alan Munn Aug 20 '11 at 12:30
@Alan: Ah, thanks, that answer the question I just asked on your answer :). I'll edit my answer. –  doncherry Aug 20 '11 at 12:31
I am very new to TeX, this is the error I am getting ! Undefined control sequence. l.6 \AtBeginEnvironment {verse}{\singlespacing} –  Aku Aug 20 '11 at 13:55
@Aku: Did you put \usepackage{etoolbox} in your preamble? etoolbox is the package that provides the environment-patching command. –  doncherry Aug 20 '11 at 14:09
@Aku: Actually, if you used exactly what you wrote in your comment here, then there's an unnecessary space in between \AtBeginEnvironment and {verse}{\singlespacing} that might cause the error. Remove this space and try again. –  doncherry Aug 20 '11 at 14:15

You can redefine the verse and tabular environments to make them single spaced:

\let\oldtabular\tabular
\let\endoldtabular\endtabular
\renewenvironment{tabular}
{\bgroup\singlespacing\oldtabular}%
{\endoldtabular\egroup}
\let\oldverse\verse
\let\endoldverse\endverse
\renewenvironment{verse}
{\bgroup\singlespacing\oldverse}%
{\endoldverse\egroup}

-
Does tabular actually need redefinition? In my quick test it wasn't affected by the changed line spacing. –  doncherry Aug 20 '11 at 12:30
Yes. The double spacing option of setspace makes table single spaced, but not tabular itself. –  Alan Munn Aug 20 '11 at 12:31

To locally change the line spacing in your document, use the environments singlespace, onehalfspace and doublespace provided by the setspace package. So, for instance:

\documentclass{article}

\usepackage{setspace}
\doublespacing

...

\begin{document}

...

\begin{singlespace}
...
\end{singlespace}

...

\end{document}

-
I have a book more than 1000 pages long. Paragraphs comes alternatively after a verse and table. Paragraphs is essentially explanation of verse. Is there any easier way to do this? –  Aku Aug 20 '11 at 12:06
Using the \preto or \appto macro provided by the etoolbox package, you can easily redefine \verse and \endverse to include \singlespace and \endsinglespace, respectively. Of course, you can also do this for other environments that shouldn't be typeset with \doublespacing. –  mhp Aug 20 '11 at 12:25
Or even better (as suggested in the answer of @doncherry): Use the \AtBeginEnvironment macro of the etoolbox` package. –  mhp Aug 20 '11 at 12:32


text:
## LSU Historical Dissertations and Theses

#### Title

Tournaments and Ideal Class Groups.

1992

Dissertation

#### Degree Name

Doctor of Philosophy (PhD)

#### Department

Mathematics

Jurgen Hurrelbrink

#### Abstract

In a series of papers published in the 1930's, L. Redei and H. Reichardt established a method for determining the 4-rank of the narrow ideal class group of a quadratic number field, essentially by finding the rank over ${\bf F}\sb2$ of a $\{0,1\}$-matrix determined by applying the Kronecker symbol to the prime divisors of the field discriminant. When this field is of the form ${\bf Q}(m\sp{1\over2}),$ with $m={\pm}p\sb1{\cdots}p\sb{n},$ each $p\sb{i}\equiv3$ (mod 4) prime, this matrix takes a form similar to that of the adjacency matrix for a tournament graph. Also, in this case we can find the 4-rank of the ideal class group in the ordinary sense. In Chapter 1, we introduce this method. In Chapter 2, we explain in detail the equivalence of Redei's method to a more modern one, and give some useful results concerning the ranks of anti-symmetric matrices over ${\bf F}\sb2.$ In Chapter 3, we use matrices to give precise ranges for the 4-rank of the ideal class group in our situation, establish conditions for maximal 4-rank, and give a partial verification of a previous result relating the 4-rank of a real and corresponding imaginary quadratic extension. We conclude with some results concerning circulant tournaments and their matrices.

74

COinS


text:
Thursday, March 21, 2013

1Inner product spaces, self adjoing operators, eigenvalues and eigenvectors¶

$V$ inner product space over $\mathbb{C}$

$<\mathbf{v},\mathbf{w}>$ hermitian inner product ($<v,w> = \bar{<w,v>}$ etc)

$T: V \rightarrow V$ self adjoint linear transformation operator if and only if $<\mathbf{v},T\mathbf{w}> = <T\mathbf{v},\mathbf{w}>$ all $\mathbf{v},\mathbf{w} \in V$ (corresponds to Hermitian matrices)

In a finite dimensional space the matrix can be diagonalized with orthonormal vectors

Hypotheses: Standard basis orthonormal with respect to the complex inner product

Consider $<\mathbf{v},T_{A}\mathbf{w}> = (\mathbf{v})^{t}\bar{(A\mathbf{w})} = (v)^{t}\bar{A}\bar{\mathbf{w}} = (\bar{A}^t\mathbf{v})^{t}(\mathbf{w})$

A Hermitian means $\bar{A}^t = A$ so $T_A$ is self adjoint when $A$ is hermitian.

Theorem $V$ inner product space over $\mathbb{C}$

$T: \ V \rightarrow V$ self adjoint linear transformation (operator)

$\lambda$ eigenvalue of $T$ and $\mathbf{v} \neq \mathbf{0}$ an eigenvector for $\lambda$

Conclusion $\lambda is a real number i.e. \lambda = \bar{\lambda}$

Proof Let $\mathbf{v}$ be this eigenvector, then $T\mathbf{v} = \lambda\mathbf{v}, \mathbf{v} \neq \mathbf{0}$

• self adjoint $<T\mathbf{v},\mathbf{v}>$

• eigenvector for $\lambda <\lambda\mathbf{v},\mathbf{v}>$

$\to$ inner product properties

\begin{aligned} \lambda <\mathbf{v},\mathbf{v}> &= <\mathbf{v},\mathbf{v}>\lambda \\ \text{hence} \quad (\lambda - \bar{\lambda} < \mathbf{v}, \mathbf{v}> &= 0 \neq <\mathbf{v},\mathbf{v}> \\ \lambda - \bar{\lambda} &= 0 \\ \lambda &= \bar{\lambda}\quad \text{ i.e. }\lambda \text{ real} \end{aligned}

Theorem $V$ inner product spaces over $\mathbb{C}$

$T: V \rightarrow V$ self adjoint

$\mathbf{0} \neq \mathbf{v_1}$ eigenvector for $T$ and $\lambda_1$

$\mathbf{0} \neq \mathbf{v_2}$ eigenvector for $T$ and $\lambda_2$

Conclusion $\lambda_1$ and $\lambda_2$ implies $<\mathbf{v_1},\mathbf{v_2}> = 0$

Test $<T\mathbf{v_1},\mathbf{v_2}> = <\mathbf{v_1},T\mathbf{v_2}>$

Hence $<\lambda_1\mathbf{v_1},\mathbf{v_2}> = <\mathbf{v_1},\lambda_{2}\mathbf{v_2}>$

Recall $\lambda_1,\lambda_2$ are real.

Aside:

\begin{aligned} \lambda_1 < \mathbf{v_1}, \mathbf{v_2}> &= < \mathbf{v_1}, \mathbf{v_2}> \bar{\lambda_2} \\ (\lambda_1 - \bar{\lambda_2}) < \mathbf{v_1}, \mathbf{v_2}> &= 0 \qquad \text{ but } \bar{\lambda_2} = \lambda_2 \text{ and } \lambda_1 - \lambda_2 \neq 0 \\ \text{ forcing } < \mathbf{v_1}, \mathbf{v_2}> &= 0\end{aligned}

Now assume dim $V = n < \infty$

Eigenvalue of $A$ such that $(A-\lambda I)$ is not invertible i.e. $det A-\lambda{I}$ = 0

$det(A-\lambda{I}) = \sum$ sign $\sigma$ product of entries on a generalized diagonal

$\begin{bmatrix} a_{11} - \lambda & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} - \lambda & \ldots & a_{2n} \\ \ldots & \ldots & \ldots & \ldots \\ a_{m1} & a_{m+1 \ 1} & \ldots & a_{mn} -\lambda \end{bmatrix} = (a_{11} - \lambda)(a_{22} - \lambda \ldots (a_{nn} - \lambda)$ etc

Hence $\mathrm{det}(A-\lambda{I})$ is a polynomial of degree exactly $n = dim V in \lambda$

Definition $\mathrm{Trace} A = a_{11} + a_{22} + \ldots + a_{nn}$

Note constant term in $det(A-\lambda{I}) = 0$ is $\mathrm{det} A (set \lambda = 0)$

2Gauss’s fundamental theorem of algebra¶

If $f(\lambda)$ is a polynomial of degree $n > 0 \in \lambda$ then there is $r \in \mathbb{C}$ such that $f(r)=0$.

Factor Theorem then implies $f(\lambda) = (\lambda-r_1) \ldots (\lambda - r_n)$

$f(r) = 0 \rightarrow f(\lambda) = (\lambda - r)q(\lambda)$

$2x^{2} + 3x + 4 \\ f(r) = 0 \\ \text{ then } f(\lambda) = (\lambda - r)q(\lambda) + \rho(\lambda)$

Definition: $A$ is $n\times n, \ n < \infty$

$X_A(\lambda) = det(\lambda{I}-A) = (-1)^{n}det(A-\lambda I)$

$X_A(\lambda) = \lambda^{n} - (traceA)\lambda^{n-1}$ + other terms degree between one and $n-2 + (-1)^{n}\mathrm{det} A$

Theorem $V$ finite dimensions $(dimV - n < \infty)$ inner product space over $\mathbb{C}$

Conclusion there is an arthonormal basis of $V$ consisting entirely of eigenvectors of $A$

There is a unitary matrix $P$ such that $P^{-1}AP = \begin{pmatrix} \lambda_1 & 0 \\ 0 & \lambda_n \end{pmatrix}$

Unitary: $\bar{P}^t = P^{-1}$ continuous on $P$ and orthonormal basis

Proof: Let $E_{\lambda_j}$ = eigenspaces for the eigenvector $\lambda_j$ of $A$ (then $dimE_{\lambda_j} \geq 1$)

Claim (proof later) $\mathbf{v}$ an eigenvector for $\lambda$

Then $\mathbf{v^{\perp}}$ is an inveriant subspace under the linear transformation induced on $V$ by $A$.

Extend $\{\mathbf{v} = \mathbf{v_1}\}$ to an orthonormal basis of V, say $\{\mathbf{v_1},\mathbf{v_2}, \ldots \mathbf{v_n}\}$

Then $\{\mathbf{v_2}, \ldots \mathbf{v_n}\}$ and $\{\mathbf{v_2}, \ldots \mathbf{v_n}\}$ is an orthonormal basis of $\mathbf{v_1}^+$

$A$ then induces a self adjoint linear transformation on $\mathbf{v_{1}^{\perp}}$

Induction there is an orthonormal basis of eigenvectors for $\mathbf{v_{1}^{\perp}}$ say $\{\hat{\mathbf{v_2}} \ldots \hat{\mathbf{v_n}} \}$

Our required orthonormal basis of eigenvectors is then $\{ \frac{\mathbf{v_1}}{\|v_1\|}, \hat{\mathbf{v_2}}, \ldots ,\hat{\mathbf{v_n}} \}$

this proves a and b follows exactly.

Proof of claim: re $\mathbf{v^{\perp}}, \mathbf{v} \neq 0$ eigenvector for $\lambda$

$T$ self adjoint (corresponding to hermitian $A$)

$\mathbf{w} \in \mathbf{v^{\perp}} \to <\mathbf{v},\mathbf{w}> = 0$ but $<\mathbf{v},T\mathbf{w}> = <T\mathbf{v},\mathbf{w}> = <\lambda\mathbf{v},\mathbf{w}>$ ($<T\mathbf{v},\mathbf{w}>$ self adjoint)

Hence we have shown $\mathbf{v}$ eigenvector of self adjoint $T$

$\mathbf{w} \in \mathbf{v^{\perp}} \to T\mathbf{w} \in \mathbf{v^{\perp}}$

Hermitiam matrices in a self adjoint matrix are equivalent to $$w_1,w_2 \in v^{\perp} \qquad <w_1,Tw_2> = <Tw_1,w_2> \qquad Tw_1 \in v^{\perp} \qquad Tw_2 \in v^{\perp}$$

Recall eigenspace of $\lambda E_{\lambda} = \{ \lambda{v} \in V | T\mathbf{v} = \lambda\mathbf{v}$

Note In our case $\mathrm{dim} E_\lambda = \text{ multiplicity of } \lambda$ and $V = E_{\lambda_1}\bigoplus \ldots \bigoplus E_{\lambda_k}$