text:
Sigma Models on Riemann Surfaces

+ 9 like - 0 dislike
78 views

I'm interested in knowing whether sigma models with an $n$-sheeted Riemann surface as the target space have been considered in the literature. To be explicit, these would have the action \begin{align*} S=\frac{1}{2}\int d^2x\, \left(\partial_a R\partial^a R+R^2\partial_a \theta {\partial}^a\theta\right), \end{align*} where $R$ and $\theta$ represent radial and angular coordinates on the target space respectively. Also, $\theta\sim \theta+2\pi n$ for an $n$-sheeted Riemann surface.

Has anyone seen anything like this? One thing that I would be particularly happy to see is a computation of the partition function.

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user Matthew

recategorized Apr 24, 2014
Tip: You might get better/more focused/useful answers if you disclose what literature you are reading.

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user Qmechanic
Maybe closed strings on spacetimes with compactified dimensions qualify. See e.g any introductory string theory text that makes mention of T-duality.

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user alexarvanitakis
@Qmechanic thanks for the suggestion, I didn't have any specific literature in mind; I guess I just meant literature in the broader sense.

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user Matthew
@alexarvanitakis I don't think that works. In that case the target space is $S^1\times \mathbf{R}^{25}$, which is a quotient of $\mathbf{R}^{26}$. The target space that I have in mind isn't a quotient of the plane.

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user Matthew
Oh right, the target space is supposed to be a Riemann surface. Sorry. This should be interesting then...

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user alexarvanitakis

+ 2 like - 0 dislike

One usually considers Ricci-Flat target spaces for string propagation. If one doesn't care about the conformal anomaly, then given that one can think of an n-sheeted Riemann surface as given by the quotient of the Poincare upper half plane by some Fuchsian group. A first step to your question then is to compute the partition function for the sigma model with the Poincare upper half plane as the target space. The upper half plane can be be modeled by the coset space $PSL(2,\mathbb{R})/SO(2)$. Thus it might suffice to look at the WZW model for this coset space. Such cosets were considered in the context of CFT's for two-dimensional blackholes in the early 90's (the action there contains additional fields to cancel the conformal anomaly). The paper by Witten titled "On string theory and black holes" (http://inspirehep.net/record/314576) might be a good starting point. The next step would be consider orbifolding by the Fuchsian group but that is another story.

(This is not really an answer but an approach to the question.)

This post imported from StackExchange Physics at 2014-04-01 15:54 (UCT), posted by SE-user suresh
answered Feb 14, 2014 by (1,535 points)
+ 2 like - 0 dislike

If C and C' are two Riemann surfaces, then a non-constant holomorphic function f : C' -> C is necessarely a ramified covering. This means that the study of two-dimensional sigma models of target a Riemann surface C is related to the study of (ramified) coverings of C.

Example of physical interest: If G is a connected Lie group, usual Chern-Simons theory is a QFT of gauge group G on a 3-dimensional M. If M is divided in two pieces by a Riemann surface C, then the classical phase space of the theory is given by the moduli space of flat G-bundles on C. In http://math.ucr.edu/home/baez/qg-winter2005/group.pdf, Dijkgraaf and Witten replace G by a finite group to obtain a "Chern-Simons theory with finite gauge group" on M. If G is finite group, a flat G-bundle on C is the same thing than a covering of C of group G. In this way, one is naturally driven to study some two-dimensional TQFTs which appears as sigma models of target C.

Something related: in http://arxiv.org/abs/math/0411037, Bryan and Pandharipande have solved some of these two-dimensional TQFT. This work shows the relevant of sigma-models of target a Riemann surface to a maybe more physical theory: a sigma-model of target a Calabi-Yau 3-fold X.If X contains a Riemann surface C which is isolated, that means which can not be deformed in X, then the holomorphic world-sheet instantons of the sigma-model of target X (whose counts are the Gromov-Witten invariants of X) localize around C to the holomorphic world-sheet instantons of the sigma model of target C. To understand this sigma-model is a first step in the study of the sigma model of target X.

answered Apr 24, 2014 by (4,175 points)
edited Apr 24, 2014 by 40227

 Please use answers only to (at least partly) answer questions. To comment, discuss, or ask for clarification, leave a comment instead. To mask links under text, please type your text, highlight it, and click the "link" button. You can then enter your link URL. Please consult the FAQ for as to how to format your post. This is the answer box; if you want to write a comment instead, please use the 'add comment' button. Live preview (may slow down editor)   Preview Your name to display (optional): Email me at this address if my answer is selected or commented on: Privacy: Your email address will only be used for sending these notifications. Anti-spam verification: If you are a human please identify the position of the character covered by the symbol $\varnothing$ in the following word:p$\hbar$ysics$\varnothing$verflowThen drag the red bullet below over the corresponding character of our banner. When you drop it there, the bullet changes to green (on slow internet connections after a few seconds). To avoid this verification in future, please log in or register.


text:
#### LoewyFactor

\documentstyle[12pt]{article}
\input{latlib}
\parindent 0mm
\pagestyle{empty}
\topmargin 0mm
\footheight 0cm
\footskip 0mm
\textheight 275mm

\begin{document}
\begin{large}
\vspace*{3mm}
\centerline{\fbox{\parbox{8cm}{\Large\bf UserFunction LoewyFactor} }}

\vspace*{1mm}\noindent{\bf LoewyFactor}$(u:LODE(RATF Q,y,x)$
The single argument $u$ is a linear homogeneous differential equation of any order. Its  coefficients are rational functions in the independent variable and may contain in addition one or more parameters. The meaning of the parameters is as follows.

$C$: Coefficient type.

$y$: Dependent variable.

$x$: Independent variable.

\noindent{\bf Specification.}
The irreducible of the largest completely reducible right factor is returned.

\vspace*{1mm}\noindent{\bf Examples.} The input is given in {\em Reduce} algebraic mode syntax. The output for each minisession is returned in a separate window.

\5{\tt LoewyFactor x**2*Df(y,x,2)+x**2*Df(y,x)-2*y;}

\hspace*{10mm}\fbox{\parbox{12cm}{

The differential equation:

\vspace*{1mm}
$y''+y'-\Frac{2}{x^{2}}y = 0$

Equation is  completely reducible. The Loewy factor:

\vspace{1mm}
$Lclm(D-\Frac{1}{x-2}+\Frac{1}{x},\hspace*{1mm} D+1-\Frac{1}{x+2}+\Frac{1}{x})y=0$ }}

\vspace{5mm}\noindent{\bf LoewyFactor}$(u:LDFMOD(C,zs,xs,O))$
The single argument $u$ has the type $LDFMOD$ which abbreviates
{\em LinearDifferentialFormModule}, it represents a system of linear homogeneous partial differential equations. The meaning of its parameters is as follows.

$C$ determines the type of the coefficients.

$zs=\{z_1,z_2,\ldots \}$ denotes the dependent variables in decreasing order.

$xs=\{x_1,x_2,\ldots \}$ denotes the independent variables in decreasing order.

$O:LEX|GRLEX$ determines the applied term ordering.

\vspace*{1mm}\noindent{\bf Specification.}
The Loewy factor of $u$ is returned.

\vspace*{1mm}\noindent{\bf Examples.} The input is given in {\em Reduce} algebraic mode syntax. The output for each minisession is returned in a separate window.

\5{\tt sys:=\{Df(sigma,x,2)+y*Df(sigma,y)+Df(sigma,x),

\hspace*{15mm} Df(sigma(x,y)-Df(sigma,y),

\hspace*{15mm} Df(sigma,y,2)+3/y*Df(sigma,y);\} }

\5{\tt T==LDFMOD(RATF Q,\{sigma\},\{y,x\},GRLEX)|;}

\5{\tt LoewyFactor(sys|T|);}

\hspace*{10mm}\fbox{\parbox{12cm}{
The given Janet basis:

\vspace{1mm}
$<\sigma_{x,x}+y\sigma_y+\sigma_x,\sigma_{x,y}-\sigma_y, \sigma_{y,y}+\Frac{3}{y}\sigma_y>$

The Loewy factor:

\vspace{1mm}   $Lclm(\partial_x+1,\partial_y>,\partial_x-1,\partial_y+\frac{2}{y}>,<\partial_x,\partial_y>)\sigma$. }}

\vspace*{3mm}
{\bf Related Functions} LoewyDecomposition.

\vspace*{5mm}

{\bf References}

A.~Loewy, {\em \"{U}ber vollst\"{a}ndig reduzible lineare homogene Differentialgleichungen}, Mathematische Annalen {\bf 56}, 89-117 (1906)

F. Schwarz, {\em Solving Second Order Linear Differential Equations}, CRC Press, 2007.

\end{large}
\end{document}

##### User Interface Functions

Go back to parent

format: plain


text:
# Smart bracelet for habit breaking

#### 001FJ

##### New Member
Hello!

I need help for a cool project idea!

I am a mechanical engineer based in Toronto and I have an idea for a “smart bracelet”. You see, I have trichotillomania (hair pulling disorder), and I want to make a smart bracelet that buzzes or vibrates or flashes when I lift my hand to pull my hair out. I want to make a smart bracelet similar to the Keen bracelet by HabitAware.

-The idea is to make a DIY smart bracelet that’s open to the public and won’t cost more than $50 to make yourself. But let’s not worry about this now because that’s the long term goal. -The bracelet will help bring awareness when people try to pull their hair out or bite their nails. The idea is that the buzz / vibration / flashing will condition them to be aware of their habit to help them stop. -I am a mechanical engineer and I have a 3D printer so I can do the mechanical aspect (housing, strap, etc) Again, that’s for the next stage, for now I need help with the electronics part. -I am handy with soldering and assembling things but I know very little about electronics / circuit boards / programming / sensor, etc. I can do it if someone guides me step by step. So please be patient with me! -For now I need to buy hardware: sensor(s), buzzer, LED light, battery, etc. And I need someone to guide me into making a schematic. Can someone help out with starting? -For now I prefer if there is not microprocessor / programming. I just want a simple circuit to test the idea. Any help or ideas are much appreciated! #### tvtech ##### Well-Known Member Most Helpful Member I honestly don't know if this is possible without using a Microprocessor because the thing needs to be trained to react..... #### DrG ##### Active Member This is not a trivial project. The "smart" aspects are an integral part of that product, but at some point, detection of the behavior does take place. I would ask you to consider some of what goes into a simpler fitness bracelet and a home-built bracelet. After a cursory look at the advert, it seems likely that there is a good deal of proprioceptive detection going on...and it is centered around the arm that is wearing the bracelet. Another words, you measure the position of the bracelet (as it is being worn)...maybe not just the position, but also the path to get to the position. Think about that...you are tracking hand/arm movements as well as possible and maybe including clenching or tensing of muscles...all dimensions you can think of. Next is the training. You have to identify the pattern involved and be able to discriminate that pattern from all others so as to specificlly target the behavior. Once you have generalized a "class" of patterns that fit the target behavior, you have to constantly track all behaviors and evaluate whether or not they belong in the class of the target behavior and then operate the vibrator (which is probably the only trivial part). Add to that the BLE aspects and now you get an idea of why they are priced as they are...and I don't know how well they work. Would they be able to detect the difference between nail biting and covering your mouth with your hand when you cough? To look into and understand accelerometers is necessary, but hardly sufficient and, frankly, I need someone to guide me into making a schematic. That is more than a tall order. For now I prefer if there is not microprocessor / programming. I just want a simple circuit to test the idea. I just do not see that happening. I hate to discourage you, but I think you need to get much deeper into the technical definition of the problem. To put it another way, you need to develop a switch that operates a buzzer, except this is not a switch that you press with your finger, it is one that is triggered by detection of the target behavior. Starting there, what sensors do you need to understand and incorporate into your "simple circuit"? Perhaps you could start with detecting when your arm is raised or lowered. I would suggest that you look at the two links that I provided and start thinking about all that is involved in those. Maybe, you could find the patent (if one was filed) for that device to get some background on what they are doing. Maybe research prosthetic devices and aids that are used in rehabilitation that might be detecting positions of limbs, even incorporating EMG...I don't know. It s certainly interesting and challenging. edited to fix link Last edited: #### Pommie ##### Well-Known Member Most Helpful Member Would a mercury switch and a vibrator motor work? Mike. #### narkeleptk ##### Active Member Pommie, wouldn't that vibrate when ever you move your arm around? #### DrG ##### Active Member Reading a little more, they may be using a gesture sensor (along with accelerometers) - that is actually a pretty cool way of doing it, I think. #### Pommie ##### Well-Known Member Most Helpful Member Pommie, wouldn't that vibrate when ever you move your arm around? So, when should it vibrate? I figured if your lower arm was vertical then you're either picking your nose/teeth, pulling hair, adjusting your glasses etc. How do you design a system that differentiates? Mike. #### tvtech ##### Well-Known Member Most Helpful Member So, when should it vibrate? I figured if your lower arm was vertical then you're either picking your nose/teeth, pulling hair, adjusting your glasses etc. How do you design a system that differentiates? Mike. With a system that can learn as in a Microprocessor based one. The thing fits on your wrist. No levers and cogs and etc. #### DrG ##### Active Member So, when should it vibrate? I figured if your lower arm was vertical then you're either picking your nose/teeth, pulling hair, adjusting your glasses etc. How do you design a system that differentiates? Mike. That is the crux of the biscuit. So, a gesture sensor + an accelerometer + ? + training. Something like that, but how well it discriminates is unclear. #### 001FJ ##### New Member Thank you for all the replies! You all have good ideas. If I have to incorporate a microprocessor then so be it. After reading further online it seems that the smart bracelets out there can't differentiate between a bad habit or just steering the car. So here is an idea: the bracelet has two parts. The main part is the bracelet, and the other part acts as an activator. The activator can be installed on the collar as a pin, or attached to the glasses. Whenever the bracelet gets within range of the activator then the bracelet warns (buzz / vibrates / flashing light). So it kind of works like a metal detector concept. Pro's of this concept: 1) The hand is free to go wherever it may except close to the head (e.g. no hair pulling) or mouth (e.g. no nail biting). You control where the limit of the hand is by where you place the Activator. 2) There is no learning necessary for the bracelet (easier to make b/c no programming or much easier programming than learning; and might be cheaper to make too). What do you think of this idea? Any ideas? Last edited: #### DrG ##### Active Member Thank you for all the replies! You all have good ideas. If I have to incorporate a microprocessor then so be it. After reading further online it seems that the smart bracelets out there can't differentiate between a bad habit or just steering the car. So here is an idea: the bracelet has two parts. The main part is the bracelet, and the other part acts as an activator. The activator can be installed on the collar as a pin, or attached to the glasses. Whenever the bracelet gets within range of the activator then the bracelet warns (buzz / vibrates / flashing light). So it kind of works like a metal detector concept. What do you think of this? Now, you are getting to the technical part of the problem definition. Look up hall effect sensor...but also realize how difficult it is to differentiate pulling your hair from touching your hair. Also, look into a gesture sensor because that could well be the first stage. Like I said, this is not trivial. #### 001FJ ##### New Member How about the activator be an RFID chip (no battery necessary), and the bracelet be the RFID sensor? #### tvtech ##### Well-Known Member Most Helpful Member Little sensors on each fingernail, plus a sensing band around your head. All talking to the wrist control HQ. Using high frequency signal, short distance technology. No antenna needed. OK. That's solved. #### 001FJ ##### New Member Little sensors on each fingernail, plus a sensing band around your head. All talking to the wrist control HQ. Using high frequency signal, short distance technology. No antenna needed. OK. That's solved. The idea was for the bracelet to be the sensor, and have a collar pin as an RFID chip. I don't think people want to wear a band on their head when they are at work, haha! #### DrG ##### Active Member Just a few thoughts... Simple proximity detection could be tried, but work that through....there are different ways to implement proximaty detection, but thinking it through, can you discriminate 2 inches from 1.5 inches or 6 inches? That is an important consideration. Additionally, proximity of the bracelet on your wrist to the sensor on your collar is not the same as detecting when you are pulling your hair. Would it be close enough to be of any value - would there be a large number of obnoxious false alarms? I remember an early behavior modification technique (please note that I am not, have never been, and will never be a clinician) where the technology was wearing a rubber band on your wrist. When you had an intrusive thought, you were supposed to snap the rubber band and the the brief, sharp pain was intended to harmlessly reset your brain, so to speak. Consider a matrix of IR detectors in the band and the complementary processing. A type of "gesture sensor", if you will. Mounted in a stationary location, you can detect a hand wave. With the proper sensors and processor and programming, you can wave your hand and it can discriminate a lower-left to upper-right wave, or a middle wave left-to-right or right-to-left. Those are available to everybody and relatively cheaply. I think, but I don't know, that they are using something like that, except the gesture sensor is on the wrist and the "wave" is relative to the stationary head. That and an accelerometer. That is what I think might be going on at the sensor end. Last week (while playing with an LCD and avoiding finishing an actuator project), I went and purchased a little camera for a Jetson Nano. This camera is off-the-shelf and ~$25 - I am sure you can get them cheaper. Running one of their demos (canned but you build it and can modify and so on), I took this picture less than an hour ago:

That blurry thing in the lower left is the camera. I am holding a remote control up to it and you see what the camera records on the screen. The software accurately identifies what it is (see what is written on the screen), AND, I can move the remote around in several positions and it still accurately identifies it as a remote.

It is an example of deep learning, AI, better known as "classifying things)...cue nsaspook to post the pic of blueberry muffins versus chihuahua puppies

What I am getting at is this: a camera on the wrist band. The targets are pictures, as, or shortly before, hair pulling or thumb sucking or whatever the behavior. Once trained, the software is constantly evaluating the camera output and comparing it to the targets and alerting when a set likelihood of the target is reached. Mind you, it might not discriminate holding your hand to your mouth when coughing from thumb-sucking but it could come mighty close.

Yeah, it is a lot of processing in a small amount of space and with a large power demand....but I am of the mind that proof of concept is a good place to start.

#### 001FJ

##### New Member
Just a few thoughts...

Simple proximity detection could be tried, but work that through....there are different ways to implement proximaty detection, but thinking it through, can you discriminate 2 inches from 1.5 inches or 6 inches? That is an important consideration. Additionally, proximity of the bracelet on your wrist to the sensor on your collar is not the same as detecting when you are pulling your hair. Would it be close enough to be of any value - would there be a large number of obnoxious false alarms?

I remember an early behavior modification technique (please note that I am not, have never been, and will never be a clinician) where the technology was wearing a rubber band on your wrist. When you had an intrusive thought, you were supposed to snap the rubber band and the the brief, sharp pain was intended to harmlessly reset your brain, so to speak.

Consider a matrix of IR detectors in the band and the complementary processing. A type of "gesture sensor", if you will. Mounted in a stationary location, you can detect a hand wave. With the proper sensors and processor and programming, you can wave your hand and it can discriminate a lower-left to upper-right wave, or a middle wave left-to-right or right-to-left. Those are available to everybody and relatively cheaply. I think, but I don't know, that they are using something like that, except the gesture sensor is on the wrist and the "wave" is relative to the stationary head. That and an accelerometer. That is what I think might be going on at the sensor end.

Last week (while playing with an LCD and avoiding finishing an actuator project), I went and purchased a little camera for a Jetson Nano. This camera is off-the-shelf and ~\$25 - I am sure you can get them cheaper. Running one of their demos (canned but you build it and can modify and so on), I took this picture less than an hour ago:

View attachment 119883

That blurry thing in the lower left is the camera. I am holding a remote control up to it and you see what the camera records on the screen. The software accurately identifies what it is (see what is written on the screen), AND, I can move the remote around in several positions and it still accurately identifies it as a remote.

It is an example of deep learning, AI, better known as "classifying things)...cue nsaspook to post the pic of blueberry muffins versus chihuahua puppies

What I am getting at is this: a camera on the wrist band. The targets are pictures, as, or shortly before, hair pulling or thumb sucking or whatever the behavior. Once trained, the software is constantly evaluating the camera output and comparing it to the targets and alerting when a set likelihood of the target is reached. Mind you, it might not discriminate holding your hand to your mouth when coughing from thumb-sucking but it could come mighty close.

Yeah, it is a lot of processing in a small amount of space and with a large power demand....but I am of the mind that proof of concept is a good place to start.
I like that! I have some friends who are decent at electronics so I will ask them, because I have no idea where to start!

The problem with cameras is that they need light to work. Driving at night is a very tempting time to pull one's hair. My wife is American and when we go see her family it's a 12hrs drive, so you can imagine how much hair is pulled out in 12hrs of night driving!

#### DrG

##### Active Member
I like that! I have some friends who are decent at electronics so I will ask them, because I have no idea where to start!

The problem with cameras is that they need light to work. Driving at night is a very tempting time to pull one's hair. My wife is American and when we go see her family it's a 12hrs drive, so you can imagine how much hair is pulled out in 12hrs of night driving!
IR camera

#### gophert

##### Well-Known Member
That is the crux of the biscuit.
Keep using phrases like that and you'll get the "'Super' Senior Man" moniker.

#### DrG

##### Active Member
Keep using phrases like that and you'll get the "'Super' Senior Man" moniker.
That phrase is from the song, Apostrophe, by F. Zappa. In Grad school, I once used the question, "What is the crux of the biscuit?" in an Freshman Intro Psych class that I had to teach. It was multiple-choice and the outcome was a greater-than-chance frequency of the "correct" answer. Of course, every one got the answer scored correct - for some reason the Freshman brain liked the idea and I would use it with some regularity even though it had almost no effect.

Now, you have to move on from the "senior man" obsession before that is all you can think about and someone finds you wandering the streets, barely clothed and muttering "senior man", "senior man" (reference Seinfeld, gym teacher, Costanza...can'tstandya)...I don't want to be seeing the Youtube phone video on Fox News!


text:
## 12 Sep A short introduction to Grobner bases for commutative algebra

Grobner bases, an important tool in both commutative and non-commutative algebra serve many purposes including it’s main purpose to study the structure of $A/I$, where $A$ is a K algebra and $I subset A$ is an ideal. Grobner bases can also be thought as an even more strong analogue to Euclidean algorithm for algebras with more than one generators. In this article, we will give a brief introduction to this theory in commutative case with examples.

Click here to download the full article.

, ,


text:
please show works and details.

Image text transcribed for accessibility: Assuming the standard MIPS procedure calling conventions, if we see ail instruction of the form lw $t0. 4($fp). the program is most likely (5pts) Accessing the return address Accessing one of its own local variables Accessing a local variable belongmg to its caller Accessing its fifth argument None of the above


text:
# How do you factor x^(4n) - y^(4n)?

May 12, 2016

$\left({x}^{2 n} + {y}^{2 n}\right) \left({x}^{n} + {y}^{n}\right) \left({x}^{n} - {y}^{n}\right)$

#### Explanation:

Note that both ${x}^{4 n}$ and ${y}^{4 n}$ are squared terms:

• ${x}^{4 n} = {\left({x}^{2 n}\right)}^{2}$
• ${y}^{4 n} = {\left({y}^{2 n}\right)}^{2}$

With this knowledge, we will factor this expression as a difference of squares:

• ${\textcolor{red}{a}}^{2} - {\textcolor{b l u e}{b}}^{2} = \left(\textcolor{red}{a} + \textcolor{b l u e}{b}\right) \left(\textcolor{red}{a} - \textcolor{b l u e}{b}\right)$

Thus, we see that

${x}^{4 n} - {y}^{4 n}$

$= {\left(\textcolor{red}{{x}^{2 n}}\right)}^{2} - {\left(\textcolor{b l u e}{{y}^{2 n}}\right)}^{2}$

$= \left(\textcolor{red}{{x}^{2 n}} + \textcolor{b l u e}{{y}^{2 n}}\right) \left(\textcolor{red}{{x}^{2 n}} - \textcolor{b l u e}{{y}^{2 n}}\right)$

Notice that we can factor $\left({x}^{2 n} - {y}^{2 n}\right)$ in the same way:

${x}^{4 n} - {y}^{4 n} = \left({x}^{2 n} + {y}^{2 n}\right) \left({x}^{2 n} - {y}^{2 n}\right)$

$= \left({x}^{2 n} + {y}^{2 n}\right) \left({\left({x}^{n}\right)}^{2} - {\left({y}^{n}\right)}^{2}\right)$

$= \left({x}^{2 n} + {y}^{2 n}\right) \left({x}^{n} + {y}^{n}\right) \left({x}^{n} - {y}^{n}\right)$


text:
# Shortest way to strip the commas from column n given a .csv file/input

Ok, so the input here is going to be a .csv file and so is the output. Now, given a .csv file/input like so

"apple","banana","apple,banana","orange"
"grape","orange","grape,orange","sprout"
# 0       1        2              3

strip out all commas for a given nth column's entries (index starts at 0). So, for the input above, the program would output a .csv file like so for n = 2:

"apple","banana","applebanana","orange"
"grape","orange","grapeorange","sprout"

If the particular column's entries do not have commas, then it does nothing. Could have any allowable/manageable number of columns, and if you somehow find that creating a program that takes more than one argument, say, a, b, c, ..., z like this

program(a=1,b=4,c=65, ..., z=0, mycsv.csv)

for respective columns 2, 5, and 66, which all strip out commas for each, to be shorter, then do that.

Shortest code measured in bytes wins, and it doesn't have to be a file that is output/input.

• Are double quotes allowed in a field? If yes, how are they escaped? – Arnauld Sep 24 '16 at 21:26
• This feels like a homework challenge under the guise of code-golf – Matt Sep 24 '16 at 22:55
• How can we accept the file as input? string array? file name? whatever suits us? – Matt Sep 24 '16 at 22:56
• Please clarify which characters can appear in the input fields. A test case that has commas outside the column we have to modify would also be helpful. – Dennis Sep 25 '16 at 15:25
• Does it has to be zero based? E.g. If the language or approach is 1-based? – Christian Rondeau Sep 27 '16 at 21:00

# 05AB1E, 27 bytes

U|vy“","“©¡vyNXQi","-}})®ý,

Explanation

U                           # store index in X
|v                         # for each line
y“","“©¡                 # split on ","
v          }     # for each in the split list
yNXQi","-}      # if it's index equals X, remove any commas
)    # wrap in list
®ý, # merge on "," and print

Try it online!

## JavaScript (ES6), 9593 90 bytes

Takes the content of the CSV file as its first parameter and the column index as its second parameter, with currying syntax.

let f =

s=>n=>s.split(/("[^"]*")/).map(c=>(c<' '?(k=0,c):k++-n*2?c:c.split,.join),k=-1).join

console.log(f(
"apple","banana","apple,banana","orange"
"grape","orange","grape,orange","sprout"
)(2));

• The question says it must take a file as input. – DanTheMan Sep 24 '16 at 22:30
• @DanTheMan - This is apparently not required anymore. – Arnauld Sep 25 '16 at 0:27
• Are the s= and the parens in the regex necessary? – ETHproductions Sep 25 '16 at 0:46
• @ETHproductions - My bad. The s= was left from a previous attempt. Thanks for noticing. I don't think I can get rid of the parens in the split, though. – Arnauld Sep 25 '16 at 0:49
• Oh, I didn't realize that you could capture groups in the split argument! That's a cool feature. – ETHproductions Sep 25 '16 at 1:24

# Ruby, 80 bytes

require'csv'
->n,x{CSV.read(x).map{|a|a[n].delete!',';a.to_csv(force_quotes:1)}}

A lambda that takes n and a file path argument, and returns a list of CSV rows.

• Would .tr!?,,'' work? – m-chrzan Sep 25 '16 at 19:26

# Python 2, 129126125989694 92 bytes

lambda n,f:''.join(c*((r[:i].count('"')-n*2)*','!=c)for r in open(f)for i,c in enumerate(r))

This is a lambda expression; to use it, prefix lambda with s=.

Iterates through each character of each line, filtering characters based on whether it's a comma and it's in a double-quoted string.

Now doesn't use the csv module at all!

Example run:

>>> s=lambda n,f:''.join(c*((r[:i].count('"')-n*2)*','!=c)for r in open(f)for i,c in enumerate(r))
>>> print s(2, 'test.csv')
"apple","banana","applebanana","orange"
"grape","orange","grapeorange","sprout"

# Sh + GNU Sed GNU Sed, 36 28 + 1 bytes

Run with -r flag.

### Explanation

• qq starts recording macro q
• /\v"(,"|$)<cr> searches for the next ending quote or end if line. Preceded by the input column number, it finds the nth occurrence • vF" visually selects the previous quote • ":s/\%V,//<cr> substitutes in the visual selection (\%V) every comma by nothing • <cr> goes to the next line • @qq@q makes the macro recursive, stops it and then play it until the end of the file. ### Gotchas • If a column only contains commas, it will be detected as a column end and will break. This is a gray zone, I will adapt the answer is the question adds this to the test cases. # Haskell, 56 bytes n!x=Math.FFT.Base.adjust(filter(/=','))n.read$'[':x++"]"

Without adjust you'd have to do something crazy like this:

n#(a,b)|a==n|filter(/=',')b|1<2=b; .. (n#)=<<zip ..

# R, 59 bytes

 function(f,n){x=read.csv(f,h=0);x[,n]=gsub(",","",x[,n]);x}

A simple function that takes f, the location of the csv file, and n, the column number to replace. Reads in the file, removes all commas from the nth column, returns the resulting data frame. R indexes from 1, not from 0.

# PHP, 81 bytes

while($r=fgetcsv(STDIN)){$r[$n=argv[1]]=strtr($r[$n],",","");fputcsv(STDOUT,$r);}

Run with php -r '<code>' <n> < <csvsource> > <csvtarget>.


text:
# With what probability does nuclear fusion occur at energies far below the Coulomb barrier?

Even at the core of the sun, the temperature of $\sim 10^7$ K only results in $kT\sim1$ keV, which is about a thousand times less than the electrical potential energy of $\sim1$ MeV needed in order to bring two hydrogen nuclei to within the ~1 fm range of the strong nuclear force. Therefore nuclear fusion reactions can only occur inside the sun, or in any other normal star, through the process of quantum-mechanical tunneling. The low probability of this tunneling, along with the need for a weak interaction in order to fuse two protons into a deuterium nucleus, are the two factors that make stars have lifetimes billions of years long.

How is the tunneling probability calculated?

-
–  Ben Crowell Aug 12 '13 at 16:28

The WKB approximation states that in one dimension, the tunneling probability $P$ can be approximated as

$\ln P=-\frac{2\sqrt{2m}}{\hbar}\int_a^b \sqrt{V-E} dx$ ,

where the limits of integration $a$ and $b$ are the classical turning points, $m$ is the reduced mass, the electrical potential $V$ is a function of $x$, and $E$ is the total energy. Setting $V=kq_1q_2/x$, we have for the integral

$I=\int_a^b \sqrt{V-E} dx$

$=\frac{kq_1k_2}{\sqrt{E}}\int_{A}^1\sqrt{u^{-1}-1} du$ ,

where $A=a/b$. The indefinite integral equals $-u\sqrt{u^{-1}-1}+\tan^{-1}\sqrt{u^{-1}-1}$, and for $A\ll 1$ the definite integral is then $\pi/2$. The result is

$\ln P=-\frac{\pi kq_1q_2}{\hbar}\sqrt{\frac{2m}{E}}$ .

This result was obtained in Gamow 1938, and $G=-(1/2)\ln P$ is referred to as the Gamow factor or Gamow-Sommerfeld factor.

The fact that the integral $\int_A^1\ldots$ can be approximated as $\int_0^1\ldots$ tells us that the right-hand tail of the barrier dominates, i.e., it is hard for the nuclei to travel through the very long stretch of $\sim 1$ nm over which the motion is only mildly classically forbidden, but if they can do that, it's relatively easy for them to penetrate the highly classically forbidden region at $x\sim1$ fm. Surprisingly, the result can be written in a form that depends only on $m$ and $E$, but not on $a$, i.e., we don't even have to know the range of the strong nuclear force in order to calculate the result.

The generic WKB expression depends on $E$ through an expression of the form $V-E$, which might have led us to believe that with a 1 MeV barrier, it would make little difference whether $E$ was 1 eV or 1 keV, and fusion would be just as likely in trees and houses as in the sun. But because the tunneling probability is dominated by the tail of the barrier, not its peak, the final result ends up depending on $1/\sqrt{E}$.

Because $P$ increases extremely rapidly as a function of $E$, fusion is dominated by nuclei whose energies lie in the tails of the Maxwellian distribution. There is a narrow range of energies, known as the Gamow window, in which the product of $P$ and the Maxwell distribution is large enough to contibute significantly to the rate of fusion.

Gamow and Teller, Phys. Rev. 53 (1938) 608

-
$P$ is a probability per collision? What constitutes collision in plasma? And why not go a bit further than Gamow and produce reactivity rate $\langle \sigma v \rangle$ averaged over thermal distribution? –  user23660 Aug 12 '13 at 16:27
@user23660: Yes, $P$ is the probability per collision (or per barrier assault). I think it should probably be interpreted as the chance of success when the two nucleons approach each other in an s-wave collision, which I think occurs about as often as you would expect based on the simple geometrical cross-section. (This is all a bit fuzzy because the result is derived in a one-dimensional approximation.) And why not go a bit further than Gamow and produce reactivity rate ⟨σv⟩ averaged over thermal distribution? That would be cool to see -- maybe you could do it as a separate Q&A? –  Ben Crowell Aug 12 '13 at 16:34
I mean in 1D collision (classically) is when E=V and 1D approximation works. But in 3D we have mostly glancing collisions and classically $E > V$ nearly always. –  user23660 Aug 12 '13 at 16:36
@user23660: The standard way of generalizing to three dimensions is to use a radial Schrodinger equation, in which the potential has a centrifugal barrier added to it. That results in a different integral, with a term appearing in it that looks like $l(l+1)/r^2$ and that reduces the probability. But for $l=0$ (s-wave), this term vanishes. The generalization of WKB to the radial wave equation is discussed here: galileo.phys.virginia.edu/classes/752.mf1i.spring03/WKB.pdf –  Ben Crowell Aug 12 '13 at 16:43
Of course! Thanks. Now on to how to obtain the rate of collisions with an impact parameter $b$ and center of mass energy E. –  user23660 Aug 12 '13 at 17:01


text:
# The (simple) intuition of the Bernoulli distribution's variance

Hi again!

Today is going to be a short post that briefly discusses a simple intuition that I stumbled across after plotting the variance of the Bernoulli distribution. I thought it neatly captured some intuition, and I feel its worth sharing.

I’ll walk you through the steps we need to get to this intuition (it’s not bad, I promise). So, from the top, then.

Let’s start with a random variable, $X$ that can take on a binary value, i.e. $X \in \{0, 1\}$. The probability that $X$ takes on a value of 0 or 1 is:

where $\theta$ is a parameter we can control and is in the range $\theta \in (0, 1)$. Put differently, we can think of $\theta$ as a measure of how biased a coin is. The larger the value of $\theta$, the greater the probability of observing a 1, and the smaller the probability of observing a 0.

We can encode this logic in a single expression with a little bit of creativity:

This is identical to our earlier expression above (feel free to plug-in values to verify) but contained in a single, neat expression.

## The Expected Value

The following is stock-standard affair, but we’ll go through the steps for the sake of thoroughness.

The expected value of a (discrete) random variable is defined as:

(i.e. the sum of each outcome multiplied by the probability of observing that outcome 1)

For the Bernoulli distribution, that gives us the following:

Ah-ha! Our expected value of a random variable with a Bernoulli distribution is our bias parameter, $\theta$ 2.

## Variance

Same steps as before, but this time we’ll be calculating the variance. The variance of a (discrete) random variable is defined as:

So, given our parameters, the variance for the Bernoulli distribution can be expressed as:

Next, we can plug-in our previously-calculated mean:

and away we go…

## The magic

At this point, this may seem kind of arbitrary. But let’s plot our calculated variance of the Bernoulli distribution (remember: the domain of $\theta$ is $(0, 1)$ ).

That’s rather interesting, right? No, not the fact that it’s a parabola (the equation for the variance should’ve given that away). But rather that the intuition regarding a biased coin is captured entirely by this single curve!

Let me explain. $\theta$ controls the bias of our coin, as we know from earlier. If we know the coin is entirely biased to one side (eg. $\theta =0$ or $\theta = 1$), then there is no uncertainty about the outcome - hence the variance is zero. Conversely, if we have an unbiased coin (when $\theta = 0.5$), we know the least about the potential outcome, and so your variance is at its maximum.

This might not be rocket science 3 to people who’re very familiar with statistics, but the intuition encoded in that variance plot was a unexpectedly delightful observation that captures more intuition about the behaviour of a Bernoulli distribution than simply looking at the maths. And that’s always a win in my book.

Till next time.

## Footnotes

1. This is a rather neat intuition in and of itself.

2. This isn’t something that may have been immediately clairvoyant upon first inspection. It certainly wasn’t for me, even though in hindsight (after computing the math), it appears rather obvious. Intuition in the probability domain remains a curious thing.

3. or brain surgery, for that matter.


text:
# sarah

Most popular questions and responses by sarah
1. ## Language Arts

In the multi-draft reading process what does a reader look for in the third reading? *This is a question from Connexus, and I really need help D:

2. ## Drama

In act 1 scene 2 of a christmas carol scrooge and marley, why does scrooge object to people enjoying christmas?

3. ## english

Which of the following is the best definition of a drama? a. a story with props b. a story with a happy ending c. a story written to be preformed by actors d. a story in which the main character eventually fails I think it's D, can anyone check me? Thanks

4. ## Physics

A grasshopper leaps into the air from the edge of a cliff at a 50 degree angle. He reaches a maximum height 6.74 cm above the top of the cliff and travels a total horizontal distance of 1.06 m. How tall is the cliff and what is the initial speed of the

5. ## Physics

A 1000 kg car pushes a 2000 kg truck that has a dead battery. When the drive steps on the accelerator, the drive wheels of the car push against the ground with a force of 4500 N. a) What is the magnitude of the force of the car on the truck? b) what is the

6. ## Math -- Algebra

Why Are Mr. and Mrs. Number so Happy?

7. ## Physics

a model of a helicopter rotor has four blades, each 3.40 m in length from the central shaft to the tip of the blade. The model is rotated in a wind tunnel at 550 rev/min. A) what is the linear speed, in m/s of the blade tip? B.) what is the radial

8. ## Physics

In the figure, a chain consisting of five links, each of mass 0.100 kg, is lifted vertically with constant acceleration of magnitude a = 2.50 m/s2. Find the magnitudes of (a) the force on link 1 from link 2, (b) the force on link 2 from link 3, (c) the

9. ## Physics

A track star in the long jump goes into the jump at 12 m/s and launches herself at 20.0° above the horizontal. How long is she in the air before returning to Earth? (g = 9.81 m/s2)

10. ## chem

A voltaic cell consists of a strip of cadmium metal in a solution of Cd(NO3)2 in one beaker, and in the other beaker a platinum electrode is immersed in a NaCl solution, with Cl2 gas bubbled around the electrode. A salt bridge connects the two beakers.

11. ## artist

1. The artwork pictured here best represents which message? a) Ideas and creativity can be shown with many different tools. b) It is important to use one type of tool because you understand how to use it. c) People can be limited by their ideas. d)

12. ## Physics

Two dogs pull horizontally on ropes attached to a post; the angle problem 1 between the ropes is 60.0 degrees. If dog A exerts a force of 270N and dog B exerts a force of 300N find the magnitude of the resultant force and the angle it makes with dog A's

13. ## physics

A certain orthodontist uses a wire brace to align a patient's crooked tooth as in the figure below. The tension in the wire is adjusted to have a magnitude of 21.12 N. Find the magnitude of the net force exerted by the wire on the crooked tooth.

14. ## Economics

Questions: Are the following workers more likely to experience short-term or long-term unemployment? Explain. a. A construction worker laid off because of bad weather. b. A manufacturing worker who loses her job at a plant in an isolated area. c. A

15. ## physics

What is the tension in the rope of this figure description? 60 kg person is hanging in the air on a rope attached to a pulley, with a 100 kg mass attached on other end that is touching the ground.

16. ## physics

It is possible to shoot an arrow at a speed as high as 100 m/s. (a) If friction is neglected, how high would an arrow launched at this speed rise if shot straight up? (b) How long would the arrow be in the air? Please help! I do not have any clue as to how

17. ## Partial Pressure- Chemistry

A gaseous mixture of O2 and N2 contains 31.8 % nitrogen by mass. What is the partial pressure of oxygen in the mixture if the total pressure is 445 mmHg?

18. ## Civics

2.   One main difference between the United States Constitution and state constitutions is that state constitutions  A. are much longer. B. don't provide for a legislature. C. can't be amended. D. don't have bills of rights. So your saying it's D?

19. ## Math to Ms.Sue (urgent )

11.   Lorenzo has a checkbook balance of $118.00. He writes two checks, one for$9.00 and one for $84.25. He then deposits$95.00. Finally, he uses his calculator to determine his new balance. Which one of the following series represents the correct

20. ## Chemistry

Ionization energy is defined as the minimum energy required to remove an electron from the ground state (n0) to infinity (n∞). Determine the wavelength of radiation required to ionize the hydrogen electron from the n = 2 energy level. Calculate the

21. ## Chemistry

Write the balanced chemical equation for each of these reactions. Include phases. When aqueous sodium hydroxide is added to a solution containing lead(II) nitrate, a solid precipitate forms. However, when additional aqueous hydroxide is added the

22. ## Physics

A bowling ball weighing 71.2 N is attached to the ceiling by a 3.80 m rope. The ball is pulled to one side and released; it then swings back and forth like a pedulum. as the rope swings through its lowest point, the speed of the bowling ball is measured at

23. ## Physics

A giant swing at a county fair consists of a vertical central shaft with a number of horizontal arms attahed at its upper end. Each arm supports a seat suspended from a 5.00 m long rod, the upper end of which is fastened to the arm at a point 3.00 m from

24. ## biology

Which best describes Francis Bacon’s contribution to the Scientific Revolution?

25. ## Chemistry Help

What is the ionic equation for: 2 HClO4(aq) + Mg(OH)2(s) ¨ Mg(ClO4)2(aq) + 2 H2O(l)

26. ## Physics

The four tires of an automobile are inflated to an absolute pressure of 2.0*10^5 Pa. Each tire has an area of 0.024m^2 in contact with the ground. Determine the weight of the automobile. Pressure*area= force. There are four tires.

27. ## Math(problem solving)

Four darts are thrown at this dartboard. If all four darts hit the board, how many different point totals are possible? there are 4 circles with point totals: working out from the middle bulls eye.. bulls eye = 9 2nd circle = 7 3rd circle = 4 outter circle

How can you use 4x7 to find 8x7? find the product. I don't understand this how can i expect my 3rd grader to understand.

29. ## chemistry

A voltaic cell that uses the reaction Tl3+(aq) + 2 Cr2+(s) ¨ Tl+(aq) + 2 Cr3+(aq) has a measured standard cell potential of +1.19 V. determine E‹red for the reduction of Tl3+(aq) to Tl+(aq).

30. ## science

Suppose you are hiking along a trail. Make a comparison between your displacement and your distance traveled. Check all that apply. -Your displacement must be less than your distance traveled. -Your displacement must be greater than your distance traveled.

Suppose the moon rotated on its axis just as quickly as Earth. Would you still always see the same side of the moon from Earth? *HELP ME PLEASE*

32. ## Chemistry

Aqueous solutions of copper (II) sulfate, CuSO4, and potassium carbonate, K2CO3, a blue parcipitate of copper (II) carbonate forms in addition to one other compound. We have to write the balanced chemical equation for that but our teacher didn't teach us

33. ## Physics

A potter’s wheel with rotational inertia of 45 kg m2, is spinning freely at 40 rpm. The potter drops a lump of clay onto the wheel where it sticks a distance 1.2 m from the rotational axis at the wheel’s center. If the subsequent angular speed of the

34. ## Chemistry

Commercial vinegar was titrated with NaOH solution to determine the content of acetic acid, HC2H3O2. For 20.0 milliliters of the vinegar 26.7 milliliters of 0.600-molar NaOH solution was required. What was the concentration of acetic acid in the vinegar if

35. ## Math

What happens to the man who carries an ax in his teeth?

36. ## chem

3 Ce4+(aq) + Cr(s) ¨ 3 Ce3+(aq) + Cr3+(aq) What is the emf of this cell when [Ce4+] = 2.9 M, [Ce3+] = 0.11 M, and [Cr3+] = 0.015 M?

37. ## Physics

A Chinook salmon can jump out of water with a speed of 6.60 m/s . How far horizontally d can a Chinook salmon travel through the air if it leaves the water with an initial angle of θ=27.0° with respect to the horizontal? (Let the horizontal direction the

38. ## World Geography

Imagine you are an elected official with the responsibility of drafting legislation designed to protect our environment. What items will you include in your bill? Who will be responsible for the bill's implementation? Its enforcement? Your response should

39. ## History

Which battle was a major turning point for US and South Korean forces during the Korean War? a. Battle of Pork Chop Hill b. Spring Offensive c. Battle of Heartbreak Ridge d. Inchon Bay landing Is it D?

40. ## Science

When evolution was first proposed, which of the following was used as evidence to support the idea? 1.observations of nature 2.laboratory experiments 3.extensive fossil collections 4.genetic sequences 1.?

49. ## PHYSICS

Two bulbs are connected in parallel across a source of emf EMF = 10.0V with a negligible internal resistance. One bulb has a resistance of 3.0 Omega , and the other is 2.5 Omega . A resistor R is connected in the circuit in series with the two bulbs. What

50. ## physics

A car travels between the 100 meter and 250 meter highway markers in 10 second. The average speed of the car during this interval is...

51. ## Chemistry

If the literature value for the ΔHfus of water is 6.01 kJ/mol, how many kJ of heat energy would be required to completely melt 130 g of ice at 0°C?

52. ## Chemistry

The reaction of aqueous sodium bromide and aqueous lead(II) nitrate is represented by the balanced net ionic equation. 2Br-(aq) + Pb2+(aq) → PbBr2(s) Give the balanced ionic equation for the reaction. Include the states.

53. ## English

Choose the meaning of the bolded vocabulary word in each passage in the next six questions. I can't bold them so the word will be in caps. Check my answers * = My answer 1. "Once, the listener fancied that he could DISTINGUISH the accent of town's people

54. ## Physics

A boy kicks a rock off a cliff with a speed of 15.5m/s at an angle of 53.5° above the horizontal. The rock hits the ground 5.37s after it was kicked. How high is the cliff? I found the height of the cliff which is 7.45*10^1 m. What is the speed of the

55. ## Physics

A 200 g mass attached to a horizontal spring oscillates at a frequency of 2 Hz. At one instant the mass is at x=5 cm and has a Vx=-30 cm/s.Determine: a) the period ( i got T=.5s) b) the amplitude c) the max speed d) the total energy need equations to solve

56. ## Calc

If y=tanu, u=v-(1/v), and v=lnx. What is the value of dy/dx at x=e?

57. ## math

In a certain town, 25% of people commute to work by bicycle. If a person is selected randomly from the town, what are the odds against selecting someone who commutes by bibycle? A). 3:1 B). 3:4 C). 1:3 D). 4:1

58. ## CHEMISTRY

Calculate the change in entropy that occurs when 17.68 g of ice at -12.7°C is placed in 54.05 g of water at 100.0°C in a perfectly insulated vessel. Assume that the molar heat capacities for H2O(s) and H2O(l) are 37.5 J K-1 mol-1 and 75.3 J K-1 mol-1,

59. ## Physics

On a cloudless day, the sunlight that reaches the surface of the earth has an intensity of about 1.2 103 W/m2. What is the electromagnetic energy contained in 6.4 m3 of space just above the earth's surface?

60. ## Literature

What are some of the poetic devices used in this poem by Gladys Cardiff? -diction -end-stopped -lyric -symbol -syntax Bending, I bow my head And lay my hand upon Her hair, combing, and think How women do this for Each other. My daughter's hair Curls

61. ## math

A right triangle is formed in the first quadrant by the x- and y-axes and a line through the point (2,3). Draw a figure that illustrates the problem. What is the area of the triangle A as a function of the x-intercept of the line?

62. ## Chemistry

Write a net ionic equation for the reaction that occurs when excess hydrobromic acid (aq) and sodium sulfide are combined.

63. ## Math

A conical water tank with vertex down has a radius of 10 feet at the top and is 22 feet high. If water flows into the tank at a rate of 30 {\rm ft}^3{\rm /min}, how fast is the depth of the water increasing when the water is 14 feet deep? I have tried

64. ## english

Put parentheses around the adverb clause by placing the parentheses in their correct locations. He will not come unless you invite him.

65. ## physics

A ferris wheel rotates at an angular velocity of .036 rad/s. At t=0min your friend Seth is at the very top of the ride. What is Seth's angular position at t=3 min, measured counterclockwise from the top?

90. ## CALCULUS

The linearization at a=0 to sqrt(6+6x) is A+Bx where A is:_____ and where B is:_____

91. ## Math

A drawer contains 22 black socks, 22 white socks, and 22 blue socks.  If the light is off and Matt reaches into the drawer to get his socks, what is the minimum number of socks he must pull out in order to be sure that he has a matching pair?

92. ## Chemistry

Automotive airbags inflate when sodium azide, NaN3, rapidly decomposes to its constituent elements according to the chemical equation, 2 NaN3 -> 2 Na + 3 N2. How many grams of nitrogen are produced when 1000 milligrams of sodium azide decomposes?

93. ## Math

The population of a town in 1920 was 3500 people. The town's population decreased linearly, and in 1927 the population was 3185. Find a formula for P, the town's population, in terms of t, the number of years since 1920.

95. ## PHYSICAL SCIENCE

A 1.0 kg metal head of a geology hammer strikes a solid rock with a velocity of 5.0 m/s. Assuming all the energy is retained by the hammer head, how much will its temperature increase?

96. ## PHYSICS

A 200g block slides back and forth on a frictionless surface between two springs, as shown. The left-hand spring has k = 130 N/m and its maximum compression is 16cm. The right-hand spring has k = 280 N/m. Find (a) the maximum compression of the right-hand

97. ## Latin

I saw the Tiber RIVER flowing through Rome. flumen fluminibus flumina fluminum Question 2 I love the POEMS of Vergil! carmen carmine carmina carminum Question 3 In his statue of Anchises, Aeneas, and Ascanius, Bernini did a beautiful job of depicting the

98. ## Math

If two pounds of meat will serve 5 people, how many pounds will be needed to serve 13 people?

A landscape architect wished to enclose a rectangular garden on one side by a brick wall costing $60/ft and on the other three sides by a metal fence costing$50/ft. If the area of the garden is 102 square feet, find the dimensions of the garden that


text:
Configuration pages don’t display well

Does anyone know what I could do? May I go back to a previous version?

How can one print the current sysmon configuration?

I’m trying to verify my sysmon configuration is correct. So I need to print the whole configuration in the client computer.

I’ve already took a look here, the only similar option is -s, and it only print the schema.

How can I print the configuration?

Configuration to use OWASP WebGoat whilw online? [closed]

OWASP WebGoat is a deliberately insecure webapplication with a set of tutorials how to hack it (and how to protect your own application). OWASP advises to disconnect from the internet while using it since it is an insecure application after all, and firewalls might be misconfigured or missing (see the prior question OWASP WebGoat Warning Meaning).

Is there a checklist how to use WebGoat safely while in a video conference? The first step is presumably to run it in the docker container. How do I configure that docker?

In setting up a VM, does the Bridged or NAT configuration provide more separation security?

I am setting up a few VM’s (assume VB w/ Linux). They will all be on the same PC host (assume Linux) and the intent is to have all the VM’s handle separate functions (business, personal finance, and fuck off time) and have no connection to each other through the network or otherwise. I want to set them up in a way that creates the best security as far as separation from each other and the host. The host will function only to host the VM’s. I would prefer to use one VPN subscription, which has been purchased anonymously. However, if this compromises the separation of these VM’s, then I would consider changing the approach.

So, the question here is, given this setup, which method (Bridged or NAT) would work better as far as providing the least amount of leaked information between the VM’s/Host?

The plan is to setup software firewalls allowing only outgoing connections for the VM’s and the host. I am still looking into whether this is best approach (secure and user friendly approach).

Any other board allowable suggestions would also be appreciated.

Optional/Mandatory Requirement For ‘req’ Command Configuration File Options Missing In OpenSSL v1.1.1g Manual Pages?

The OpenSSL v1.1.1 manual page for the req command’s Configuration File Format options seems to be missing any mention about whether each option is mandatory or optional. The other OpenSSL command manual pages (ca and ts) that support configuration file usage do stipulate whether each configuration file option is mandatory or optional.

Does anyone know which req configuration file options are mandatory and which are optional?

How Is The OpenSSL Configuration File Parsed?

I’m trying to understand how OpenSSL parses its configuration file. In the sample configuration file that is installed with OpenSSL v1.1.1g, its seems to be divided into three main sections – the [ ca ] section, the [ req ] section, and the [ tsa ] section (because of the lines that contain ############# ... that separate these sections). Inside the [ ca ] and [ req ] sections there are key/value pairs whose name is a command option and whose value "links" to another section in the configuration file. A good example is the x509_extensions = usr_cert key/value pair in the [ ca ] section.

I am under the impression that the OpenSSL config file is processed by the OpenSSL parser starting at the first line of the file and processing the next line in turn (please correct me if that’s not the case). Therefore, I would expect the [ ca ] section’s x509_extensions = usr_cert to be linked to a section of the config file that occurrs inside the [ ca ] section. But it doesn’t – it links to the [ usr_cert ] section that occurs inside the [ req ] section, which is outside the [ ca ] section.

So, what’s happening when the OpenSSL parser processes the configuration file? Is my visual perception of inside and outside wrong when I read the configuration file? Does the parser "call" the linked section, process its key/value pairs, then return parsing of the config file to the next line in the config file? If this is the case, wouldn’t it make it much easier to understand the structure of the config file if "links" to sections that pertained to the command whose section is being parsed were actually present within the command’s section?

Can Windows CMD/DOS Commands Be Used In An OpenSSL Configuration File On Windows 10? [migrated]

I’m using OpenSSL v1.1.1g on a Windows 10 machine (I don’t know Linux – yet). Can Windows CMD/DOS commands be used in the OpenSSL configuration file or is the configuration file limited to the use of OpenSSL commands only? I assume the answer to this question is "No" since OpenSSL uses its own parser to process OpenSSL configuration files, but I’d like to have my assumption confirmed.

Specify Location of Certificate Signing Requests in OpenSSL Configuration File?

Does the OpenSSL req command have a OpenSSL configuration file equivalent to the ca command’s new_certs_dir option? I’d like to establish a default directory for all Certificate Signing Requests ("CSRs") that are created using the req command.

What OpenSSL v1.1.1g Commands Require A Configuration File?

It’s my understanding that the OpenSSL v1.1.1g commands ca and req require sections to be present in an OpenSSL configuration file in order to operate. Are there any other OpenSSL v1.1.1g commands that require a section to be present in a configuration file in order to operate?

Configurations and CNF formula for neighboring configuration

A configuration of a Turing machine $$M$$ which runs in space $$S(n)$$ contains the state, the head positions, and the content of non-blank cells of all the tapes. For $$M$$ and an input $$x$$, we define its configuration graph $$G_{M,x}$$ as a directed graph whose nodes correspond to all the possible configurations and there is an edge from a configuration $$C$$ to $$C’$$ if $$C’$$ can be reached from $$C$$ in one step.

First question: In Arora-Barak (snapshot below), they say that these nodes can be encoded in a binary string of length $$O(S(n))$$. Such encoding contains the state, all symbols under the head, and non-blank content of work tapes with special marking to denote the location of the head. I think this is not correct since such an encoding doesn’t contain the input head position. If we don’t store the input head position, which requires O(\log n) bits, then two nodes can map to the same encoding, which seems wrong. Am I right? Although storing the input head position will not increase the length of the encoding since we are assuming in the book that $$S(n) > \log n$$.

Second question: Next Arora-Barak says that we can construct a CNF formula $$\phi_{M,x}$$ such that for any two strings $$C$$ and $$C’$$, $$\phi_{M,x}(C,C’) = 1$$ iff $$C$$ and $$C’$$ encode two neighboring configuration in $$G_{M,x}$$. I am not able to figure out the proof of this claim with the kind of encoding that I have described above i.e. encoding in which we also store the index of input head. Suppose a configuration C has $$q_1, q_2, \dots, q_c$$ bits for state, $$h_1,h_2, \dots, h_{O(\log n)}$$ bits for input head positions, $$w_1, w_2, \dots, w_{S(n)}$$ bits for work tape content and $$wh_1, wh_2, \dots, wh_{S(n)}$$ bits for work tape head position, where $$wh_i$$ is equal to 1 if the head is on the $$i$$th cell, else it is equal to 0. Then how with such an encoding we can construct a CNF formula as described at the beginning of this question?


text:
# Nonlinear Dimensionality Reduction by Locally Linear Embedding

## Introduction

This report will explain the article written by Sam T. Roweis and Lawrence K. Saul about the Locally Linear Embedding (LLE) algorithm used for the analysis and visualization of big amounts of data. This document called Nonlinear Dimensionality Reduction by Locally Linear Embedding and published at the American Association for the Advancement of Science in 2000, shows how the use of this algorithm improves the problem of dimensionality reduction mapping the inputs into a coordinate to be applied in nonlinear manifold data.

Sam T. Roweis, associate professor in Department of Computer Science at the University of Toronto since 2006, is a Research Scientist & Consultant for Google. And Lawrence K. Saul, professor in Department of Computer Science and Engineering at the UC San Diego since 2006, is now focused on applications of machine learning to problems in computer systems and security.

## Context of the work

High-dimensional data, that is to say all data that requires more than 2D or 3D to be represented,is difficult to be interpreted by a human. To simplify it, one method that can be followed is considering an embedded nonlinear manifold formed by the relevant data, this is the purpose of the nonlinear dimensionality reduction.

Dimensionality reduction can be considered as the process of deriving a set of degrees of freedom to reproduce most part of the variability of a data set. As in the example shown in Fig.3, a set of faces images which the only variation its pose, only one degree of freedom has been altered so the pictures lie on a continuous one-dimensional curve.

In other words, all manifold learning algorithms can be applied to data dimensionality reduction, producing a low-dimensional encoding from a high-dimensional one, data visualization, providing an image of a data set based on the degrees of freedom, and supervised learning preprocessing, to clean sub-sequent supervised training data.

## Positioning and contributions

The purpose of Locally Linear Embedding (LLE) and other dimensionality reduction algorithms like Multidimensional Scaling (MDS), Principal Component Analysis (PCA) and Isomap, is to find correlations and connections between different samples of an observed object and plotting them into a drawn that can be visualized. Also it is able to maps the resource data into a single global coordinate system, optimizing it not using local minima and learning form nonlinear manifolds as it is shown in the source article.

Although the work shown by Roweis and Saul names only a few algorithms, there are many other systems based also on manifold learning procedures (Local tangent space alignment, Laplacian eigenmaps,…). The algorithms presented and developed in the article have some main disadvantages with the existing LLE. As we can see in Fig.1 form the original file, mapping high-dimensional inputs into a low-dimensional space with the same number of coordinates as observed variability modes using MDS or Isomap preserve pairwise distance between points, distance calculated with straight lines (MDS) or manifold shortest path (Isomap) while LLE eliminates the need to calculate them for far points.

This is done by characterizing the local geometry of the linear manifold patch with coefficients that reconstruct all data points using their corresponding neighbors. Minimizing the cost function taken into account that each sample $$X_{i}$$ is reconstructed using its neighbors we obtain the weights for each case as a matrix, knowing that the sum of all weights of the same row must be equals to 1. So in the final step we can compute the cost function, basing on locally linear reconstruction errors, using the low dimensional vector $$Y_{i}$$ obtained from the corresponding $$X_{i}$$ that represents the global coordinates of the manifold.


text:
# Variance of Binomial Distribution

## Theorem

Let $X$ be a discrete random variable with the binomial distribution with parameters $n$ and $p$.

Then the variance of $X$ is given by:

$\operatorname{var} \left({X}\right) = n p \left({1-p}\right)$

## Proof 1

From the definition of Variance as Expectation of Square minus Square of Expectation:

$\operatorname{var} \left({X}\right) = E \left({X^2}\right) - \left({E \left({X}\right)}\right)^2$
$\displaystyle E \left({X^2}\right) = \sum_{x \mathop \in \operatorname{Im} \left({X}\right)} x^2 \Pr \left({X = x}\right)$

To simplify the algebra a bit, let $q = 1 - p$, so $p+q = 1$.

So:

 $$\displaystyle E \left({X^2}\right)$$ $$=$$ $$\displaystyle \sum_{k \mathop \ge 0}^n k^2 \binom n k p^k q^{n-k}$$ Definition of binomial distribution, with $p + q = 1$ $$\displaystyle$$ $$=$$ $$\displaystyle \sum_{k \mathop = 0}^n k n \binom {n - 1} {k - 1} p^k q^{n-k}$$ Factors of Binomial Coefficients: $\displaystyle k \binom n k = n \binom {n - 1} {k - 1}$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \sum_{k \mathop = 1}^n k \binom {n - 1} {k - 1} p^{k-1} q^{\left({n-1}\right)-\left({k-1}\right)}$$ note change of limit: term is zero when $k-1=0$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \sum_{j \mathop = 0}^m \left({j+1}\right) \binom m j p^j q^{m-j}$$ putting $j = k-1, m = n-1$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({\sum_{j \mathop = 0}^m j \binom m j p^j q^{m-j} + \sum_{j \mathop = 0}^m \binom m j p^j q^{m-j} }\right)$$ splitting sum up into two $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({\sum_{j \mathop = 0}^m m \binom {m-1} {j-1} p^j q^{m-j} + \sum_{j \mathop = 0}^m \binom m j p^j q^{m-j} }\right)$$ Factors of Binomial Coefficients: $\displaystyle j \binom m j = m \binom {m - 1} {j - 1}$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({\left({n-1}\right) p \sum_{j \mathop = 1}^m \binom {m-1} {j-1} p^{j-1} q^{\left({m-1}\right)-\left({j-1}\right)} + \sum_{j \mathop = 0}^m \binom m j p^j q^{m-j} }\right)$$ note change of limit: term is zero when $j-1=0$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({\left({n-1}\right) p \left({p + q}\right)^{m-1} + \left({p + q}\right)^m}\right)$$ by the Binomial Theorem $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({\left({n-1}\right) p + 1}\right)$$ as $p + q = 1$ $$\displaystyle$$ $$=$$ $$\displaystyle n^2 p^2 + n p \left({1 - p}\right)$$ by algebra

Then:

 $$\displaystyle \operatorname{var} \left({X}\right)$$ $$=$$ $$\displaystyle E \left({X^2}\right) - \left({E \left({X}\right)}\right)^2$$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({1-p}\right) + n^2 p^2 - \left({np}\right)^2$$ Expectation of Binomial Distribution: $E \left({X}\right) = n p$ $$\displaystyle$$ $$=$$ $$\displaystyle n p \left({1-p}\right)$$

as required.

$\blacksquare$

## Proof 2

From Variance of Discrete Random Variable from PGF, we have:

$\operatorname{var} \left({X}\right) = \Pi''_X \left({1}\right) + \mu - \mu^2$

where $\mu = E \left({x}\right)$ is the expectation of $X$.

From the Probability Generating Function of Binomial Distribution, we have:

$\Pi_X \left({s}\right) = \left({q + ps}\right)^n$

where $q = 1 - p$.

From Expectation of Binomial Distribution, we have:

$\mu = n p$

From Derivatives of PGF of Binomial Distribution, we have:

$\Pi''_X \left({s}\right) = n \left({n-1}\right) p^2 \left({q + ps}\right)^{n-2}$

Putting $s = 1$ using the formula $\Pi''_X \left({1}\right) + \mu - \mu^2$:

$\operatorname{var} \left({X}\right) = n \left({n-1}\right) p^2 + np - n^2p^2$

and hence the result.

$\blacksquare$

## Proof 3

From Bernoulli Process as Binomial Distribution, we see that $X$ as defined here is the sum of the discrete random variables that model the Bernoulli distribution.

Each of the Bernoulli trials is independent of each other.

Hence we can use Sums of Variances of Independent Trials.

The Variance of Bernoulli Distribution is $p \left({1-p}\right)$ so the variance of $B \left({n, p}\right)$ is $n p\left({1-p}\right)$.

$\blacksquare$


text:
# Regime switching in mean reverting stochastic process

Let you have a mean reverting stochastic process with a statistically significant autocorrelation coefficient; let it looks like you can well model it using an $ARMA(p,q)$.

This time series could be described by a mean reverting stochastic process like

$dS=k(\theta-S_{t})dt+\sigma S_{t}^{\beta}dz$

where $\theta$ is the mean reversion level, $k$ is the speed of mean reversion and $\beta$ determines the structural form of diffusion term (so $\beta=0$ yields the normally distributed mean reversion model, aka the Ornstein-Uhlenbeck process).

Regardless of the actual value of $S_{0}$, we know $S_{t}$ will go $\theta$ in the long run, right?

Now let there's an unlikely event which can drastically change $\theta$'s value: e.g. let $\theta=100$, you model the process, ok, then... bang! Starting from $t=\tau$ it happens that $\theta=30$ and you will have to deal with this new scenario.

My question: is there any model which can deal with such a situation?

-

## migrated from math.stackexchange.comJan 8 '13 at 15:47

This question came from our site for people studying math at any level and professionals in related fields.

I'm sure there are, as this would seem key to model risk in the real world. I believe I remember seeing them way back when I knew this when regime-switching was a hot topic (maybe late '90s). But except for this: scholar.google.com/…, I can only recommend to check the usual suspects in mathematical finance. –  gnometorule Jan 7 '13 at 17:08

As far as I can tell, you've essentially written the model that you are concerned with. The only difference is that you would instead have $\theta_{i}$ when $s_{t}=i$ where $s_{t}$ is a latent variable that reflects the probability of being in state $i$. You would also need to include the dynamics that drive the probability transitions as another part of the model. You could set them up as standard Markov Regime-Switching models are set up, though there are other options.

So the question becomes what do you want to do with the model?

If you are concerned with estimating the parameters of such a model, you would begin by setting this up as a regime-switching AR(p) model (these are more popular to use than ARMA models). You could set it up in levels and allow the coefficients on all the variables (and the variance) to switch between states. You could also set it up in differences and include the lag of the level as an independent variable.

To estimate the parameters, the simplest approach is to apply maximum likelihood using the Hamilton filter. There is a Matlab implementation that I have used to implement this approach. You could also estimate the regime-switching model by Bayesian MCMC.

-
I like your answer, John, and I think your approach may produce suitable results. Let me answer your question: «So the question becomes what do you want to do with the model?». I'm working with a 2-regime model and my final goal is to estimate the $S_{t}$ value which is the threshold between the first and the second regime. E.g.: if $S_{t}>60$ it's likely it will go $\theta=100$ BUT if $S_{t}<60$ it's likely it will go $\theta=25$. What should I do? –  Lisa Ann Jan 10 '13 at 14:03
You might want to learn more about regime-switching. Also, try to fit one of the models using that Matlab package to get a better sense of what you're dealing with. –  John Jan 10 '13 at 17:04
I'm used to R for quantitative analysis. Please, give a look at Regime Detection: it is a blog article on regime switching detection. Is that the kind of analysis you're suggesting to perform? –  Lisa Ann Jan 11 '13 at 14:26
This is closely related, but I'm not sure whether that R package can fit autoregressive models that you are looking to fit. –  John Jan 11 '13 at 17:55
The short name usually used to describe such a model is "TAR" (Threshold Autoregressive Model), isn't it? If so, how a TAR model can perform if the time series sample shows just the first regime (but we know also the second one does exist)? –  Lisa Ann Jan 14 '13 at 7:36


text:
# Net Profit Margin Calculator

Input

Note: Net Profit Margin calculator uses JavaScript, therefore you must have it enabled to use this calculator.

Results

Net profit margin calculator measures company's profitability or how much of each dollar earned by the company is translated into net profits. Net profit margin formula is:

							Net\;profit\;margin = \frac{Net\;profit\;(after\;taxes)}{Net\;Sales}\times100

Net Profit Margin calculator is part of the Online financial ratios calculators, complements of our consulting team.

1. Complementarily, in order to calculate Net Profit Margin for your business, we offer a calculator free of charge.
2. You may link to this calculator from your website as long as you give proper credit to C. C. D. Consultants Inc. and there exists a visible link to our website.
To link to our Net Profit Margin Calculator from your website or blog, just copy the following html code:

Net Profit Margin Calculator and Interpretation
3. Although C. C. D. Consultants Inc.'s personnel has verified and validated the Net Profit Margin calculator, C. C. D. Consultants Inc. is not responsible for any outcome derived from its use. The use of Net Profit Margin calculator is the sole responsibility of the user and the outcome is not meant to be used for legal, tax, or investment advice.

### Definitions and terms used in Net Profit Margin Calculator

Net Sales
The amount of revenue generated by a company after the deduction of returns, allowances for damaged or missing goods and any discounts allowed.
Net sales = Gross sales - Sales returns and allowances
Cost of Goods Sold (COGS)
The direct cost attributable to the production or purchasing of the goods sold by a company. It is also referred as Cost of sales.
Gross Profit
The difference between Net Sales and its Cost of Goods Sold, before deducting overhead, payroll, taxes, interest and other operating expenses.
Gross profit = Net sales - Cost of Goods Sold
Operating Expenses
The expenses incurred by a business in its normal day-to-day operations, but not directly associated with production of goods. Operating expenses include payroll, sales commissions, employee benefits and pension contributions, transportation and travel, amortization and depreciation, rent, repairs etc. These expenses are divided into selling expenses and administrative and general expenses.
Operating Income
A measure of a company's profitability that excludes interest and income tax expenses. This is the surplus generated by operations and equals gross profit less all operating expenses.
Also known as Earnings before Interest and Taxes - EBIT
Operating Income = Gross profit - Operating Expenses
Interest Expenses
A fee paid on borrowed assets, the price paid for the use of borrowed money.
Income tax
The tax levied on the income of a company.

### What is Net Profit Margin

Net profit margin is a key financial indicator used to asses the profitability of a company.

Net profit margin formula is:

							Net\;profit\;margin = \frac{Net\;profit\;(after\;taxes)}{Net\;Sales}\times100

Net profit margin measures how much of each dollar earned by the company is translated into profits. A low profit margin indicates a low margin of safety: higher risk that a decline in sales will erase profits and result in a net loss.

### Net Profit Margin Analysis

Net profit margin provides clues to the company's pricing policies, cost structure and production efficiency. Different strategies and product mix cause the net profit margin to vary among different companies.

Net profit margin is an indicator of how efficient a company is and how well it controls its costs. The higher the margin is, the more effective the company is in converting revenue into actual profit.

Net profit margin is mostly used to compare company's results over time. To compare net profit margin, even between companies in the same industry, might have little meaning. For example, if a company recently took a long-term loan to increase its production capacity, the net profit margin will significantly be reduced. That does not mean, necessarily, that the company is less efficient than other competitors.


text: The circuit shown in the figure has two sources connected in series. The instantaneous voltage of the $AC$ source (in Volt) is given by $v(t) = 12 \sin t$. If the circuit is in steady state, then the rms value of the current (in Ampere) flowing in the circuit is ________.


text:
Matplotlib: Plot Multiple Line Plots On Same and Different Scales

# Matplotlib: Plot Multiple Line Plots On Same and Different Scales

### Introduction

Matplotlib is one of the most widely used data visualization libraries in Python. From simple to complex visualizations, it's the go-to library for most.

In this tutorial, we'll take a look at how to plot multiple line plots in Matplotlib - on the same Axes or Figure.

If you'd like to read more about plotting line plots in general, as well as customizing them, make sure to read our guide on Plotting Lines Plots with Matplotlib.

### Plot Multiple Line Plots in Matplotlib

Depending on the style you're using, OOP or MATLAB-style, you'll either use the plt instance, or the ax instance to plot, with the same approach.

To plot multiple line plots in Matplotlib, you simply repeatedly call the plot() function, which will apply the changes to the same Figure object:

import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5, 6]
y = [2, 4, 6, 5, 6, 8]
y2 = [5, 3, 7, 8, 9, 6]

fig, ax = plt.subplots()

ax.plot(x, y)
ax.plot(x, y2)
plt.show()

Without setting any customization flags, the default colormap will apply, drawing both line plots on the same Figure object, and adjusting the color to differentiate between them:

Now, let's generate some random sequences using Numpy, and customize the line plots a tiny bit by setting a specific color for each, and labeling them:

import matplotlib.pyplot as plt
import numpy as np

line_1 = np.random.randint(low = 0, high = 50, size = 50)
line_2 = np.random.randint(low = -15, high = 100, size = 50)

fig, ax = plt.subplots()

ax.plot(line_1, color = 'green', label = 'Line 1')
ax.plot(line_2, color = 'red', label = 'Line 2')
ax.legend(loc = 'upper left')
plt.show()

We don't have to supply the X-axis values to a line plot, in which case, the values from 0..n will be applied, where n is the last element in the data you're plotting. In our case, we've got two sequences of data - line_1 and line_2, which will both be plotted on the same X-axis.

While plotting, we've assigned colors to them, using the color argument, and labels for the legend, using the label argument. This results in:

### Plot Multiple Line Plots with Different Scales

Sometimes, you might have two datasets, fit for line plots, but their values are significantly different, making it hard to compare both lines. For example, if line_1 had an exponentially increasing sequence of numbers, while line_2 had a linearly increasing sequence - surely and quickly enough, line_1 would have values so much larger than line_2, that the latter fades out of view.

Let's use Numpy to make an exponentially increasing sequence of numbers, and plot it next to another line on the same Axes, linearly:

import matplotlib.pyplot as plt
import numpy as np

linear_sequence = np.linspace(0, 10, 10)
# [0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 10]
exponential_sequence = np.exp(linear_sequence)
# [1.00e+00, 3.03e+00, 9.22e+00, 2.80e+01, 8.51e+01, 2.58e+02, 7.85e+02, 2.38e+03, 7.25e+03, 2.20e+04]

fig, ax = plt.subplots()

ax.plot(linear_sequence)
ax.plot(exponential_sequence)
plt.show()

Running this code results in:

The exponential growth in the exponential_sequence goes out of proportion very fast, and it looks like there's absolutely no difference in the linear_sequence, since it's so minuscule relative to the exponential trend of the other sequence.

Now, let's plot the exponential_sequence on a logarithmic scale, which will produce a visually straight line, since the Y-scale will exponentially increase. If we plot it on a logarithmic scale, and the linear_sequence just increases by the same constant, we'll have two overlapping lines and we will only be able to see the one plotted after the first.

## Free eBook: Git Essentials

Check out our hands-on, practical guide to learning Git, with best-practices, industry-accepted standards, and included cheat sheet. Stop Googling Git commands and actually learn it!

Let's change up the linear_sequence a bit to make it observable once we plot both:

import matplotlib.pyplot as plt
import numpy as np

# Sequences
linear_sequence = [1, 2, 3, 4, 5, 6, 7, 10, 15, 20]
exponential_sequence = np.exp(np.linspace(0, 10, 10))

fig, ax = plt.subplots()

# Plot linear sequence, and set tick labels to the same color
ax.plot(linear_sequence, color='red')
ax.tick_params(axis='y', labelcolor='red')

# Generate a new Axes instance, on the twin-X axes (same position)
ax2 = ax.twinx()

# Plot exponential sequence, set scale to logarithmic and change tick color
ax2.plot(exponential_sequence, color='green')
ax2.set_yscale('log')
ax2.tick_params(axis='y', labelcolor='green')

plt.show()

This time around, we'll have to use the OOP interface, since we're creating a new Axes instance. One Axes has one scale, so we create a new one, in the same position as the first one, and set its scale to a logarithmic one, and plot the exponential sequence.

This results in:

We've also changed the tick label colors to match the color of the line plots themselves, otherwise, it'd be hard to distinguish which line is on which scale.

### Plot Multiple Line Plots with Multiple Y-Axis

Finally, we can apply the same scale (linear, logarithmic, etc), but have different values on the Y-axis of each line plot. This is achieved through having multiple Y-axis, on different Axes objects, in the same position.

For example, the linear_sequence won't go above 20 on the Y-axis, while the exponential_sequence will go up to 20000. We can plot them both linearly, simply by plotting them on different Axes objects, in the same position, each of which set the Y-axis ticks automatically to accommodate for the data we're feeding in:

import matplotlib.pyplot as plt
import numpy as np

# Sequences
linear_sequence = [1, 2, 3, 4, 5, 6, 7, 10, 15, 20]
exponential_sequence = np.exp(np.linspace(0, 10, 10))

fig, ax = plt.subplots()

# Plot linear sequence, and set tick labels to the same color
ax.plot(linear_sequence, color='red')
ax.tick_params(axis='y', labelcolor='red')

# Generate a new Axes instance, on the twin-X axes (same position)
ax2 = ax.twinx()

# Plot exponential sequence, set scale to logarithmic and change tick color
ax2.plot(exponential_sequence, color='green')
ax2.tick_params(axis='y', labelcolor='green')

plt.show()

We've again, created another Axes in the same position as the first one, so we can plot on the same place in the Figure but different Axes objects, which allows us to set values for each Y-axis individually.

Without setting the Y-scale to logarithmic this time, both will be plotted linearly:

### Conclusion

In this tutorial, we've gone over how to plot multiple Line Plots on the same Figure or Axes in Matplotlib and Python. We've covered how to plot on the same Axes with the same scale and Y-axis, as well as how to plot on the same Figure with different and identical Y-axis scales.

If you're interested in Data Visualization and don't know where to start, make sure to check out our bundle of books on Data Visualization in Python:

Data Visualization in Python with Matplotlib and Pandas is a book designed to take absolute beginners to Pandas and Matplotlib, with basic Python knowledge, and allow them to build a strong foundation for advanced work with theses libraries - from simple plots to animated 3D plots with interactive buttons.

It serves as an in-depth, guide that'll teach you everything you need to know about Pandas and Matplotlib, including how to construct plot types that aren't built into the library itself.

Data Visualization in Python, a book for beginner to intermediate Python developers, guides you through simple data manipulation with Pandas, cover core plotting libraries like Matplotlib and Seaborn, and show you how to take advantage of declarative and experimental libraries like Altair. More specifically, over the span of 11 chapters this book covers 9 Python libraries: Pandas, Matplotlib, Seaborn, Bokeh, Altair, Plotly, GGPlot, GeoPandas, and VisPy.

It serves as a unique, practical guide to Data Visualization, in a plethora of tools you might use in your career.

Last Updated: April 12th, 2021

Get tutorials, guides, and dev jobs in your inbox.

David LandupAuthor

Entrepreneur, Software and Machine Learning Engineer, with a deep fascination towards the application of Computation and Deep Learning in Life Sciences (Bioinformatics, Drug Discovery, Genomics), Neuroscience (Computational Neuroscience), robotics and BCIs.

Great passion for accessible education and promotion of reason, science, humanism, and progress.

Project

### Data Visualization in Python: Visualizing EEG Brainwave Data

# python# matplotlib# seaborn# data visualization

Electroencephalography (EEG) is the process of recording an individual's brain activity - from a macroscopic scale. It's a non-invasive (external) procedure and collects aggregate, not...

Details
Project

### Data Visualization in Python: The Collatz Conjecture

# python# matplotlib# data visualization

The Collatz Conjecture is a notorious conjecture in mathematics. A conjecture is a conclusion based on existing evidence - however, a conjecture cannot be proven....

Details


text:
# Default for mo@symmetric is wrong #469

Closed
opened this issue May 17, 2013 · 6 comments

Projects
None yet
2 participants
Member

### dpvc commented May 17, 2013

 The default for mo@symmetric should be false but is true in the mml ElementJax code. It should be changed to false.
Contributor

### fred-wang commented Jun 12, 2013

 OK, I guess it is easy to fix, but I'm not sure how to write a test that will detect the change (perhaps it's not necessary).

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 8, 2014

 Fixed default value for mo@symmetric. Resolves issue mathjax#469.
 eb0cae8

Member Author

### dpvc commented Feb 8, 2014

 A test case could compare a stretchy vertical arrow with symmetric="true" to one without symmetric to see if the results are the same or different (image comparison). Vertical arrows should default to symmetric="false".
Member Author

### dpvc commented Feb 9, 2014

 It turns out that the spec was inconsistent on this (listed the default as both false and true). I asked for clarification on the MathML mailing list, and they indicated it should be "true" (as currently implemented in MathJax). Here is part of the conversation (from David Carlisle): All the boolean attributes other than symmetric default to false, so in the operator dictionary interpreting the lack of the property name as the default or as false comes to the same thing. For symmetric, now it's clarified as defaulting to true, as written an operator dictionary could set it to false but the compressed notation used in appendix C can not express that and so in fact they are all true and "symmetric" in the table no effect other than a visual hint in the sample dictionary. An alternative would be to say that an omitted boolean property name means false, but then we would have to check whether it needs adding to more entries eg the vertical arrows which are the majority of vertically stretchy characters for which currently symmetric isn't explicit in the table. So I'm deleting the branch where I made the change, and closing this issue (marking it "expected behavior").

Member Author

### dpvc commented Feb 10, 2014

 Well, it turns out that the default really is supposed to be false after all: Neil later checked the archives and the decision to change the default to false and add entries making it true for brackets in the operator dictionary was deliberate before MathML3. This fits better with arrows and also with the presentation style used for boolean attributes in the appendix (although that could have been changed of course). so I'm reopening the issue, and will resurrect my path from above.

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 10, 2014

 Merge branch 'issue469' into develop. Issue mathjax#469.
 e1b0093

Member Author

### dpvc commented Feb 10, 2014

 => Merged

### dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Apr 21, 2014

 Add test for issue mathjax/MathJax#469.
 3b6caf3
Member Author

### dpvc commented Apr 21, 2014

 => In Test Suite. MathMLToDisplay/Topics/StretchyChars/issue469.html


text:
# Assignment_8_solutions.pdf - ECE 205 Winter 2017 Assignment...

• Homework Help
• 11
• 100% (2) 2 out of 2 people found this document helpful

This preview shows page 1 - 4 out of 11 pages.

ECE 205 - Winter 2017 Assignment 8 solutions Due 02-04-2017 Note: Please submit the full solutions to all questions. In Questions 1 and 2, we consider the heat equation in one spatial dimension, for the temperature, U , of a rod of length L : U t = α 2 U xx , where α 2 is the thermal diffusivity. 1: Heat equation ( I ) Consider the initial condition U ( x, 0) = 100 x L . a) ( i ) Solve the PDE with the boundary conditions: U (0 , t ) = U ( L, t ) = 0 , ( t > 0) . ( ii ) What is the equilibrium state for this boundary value problem, i.e. solve the PDE U t = α 2 U xx , U t = 0, U (0 , t ) = U ( L, t ) = 0, t > 0. ( iii ) Is your solution from a ( i ) asymptotic to your solution to a ( ii ) as t → ∞ ? b) ( i ) Solve the PDE with the boundary conditions: U x (0 , t ) = U x ( L, t ) = 0 , ( t > 0) . ( ii ) What is the equilibrium state for this Boundary value problem, i.e. solve the PDE: U t = α 2 U xx , U t = 0, U x (0 , t ) = U x ( L, t ) = 0 . ( t > 0). ( iii ) Is your solution from b ( i ) asymptotic to your solution to b ( ii ) as t → ∞ ? ( II ) a) Consider now the general Boundary value problem: U t = α 2 U xx , U (0 , t ) = U ( L, t ) = 0 , t > 0 . Let us consider the mean square temperature: M ( t ) = 1 L L Z 0 U 2 ( x, t ) dx. Use the Leibniz rule for differentiating under the integral and integration by parts to show that this function is not increasing. b) Consider now the general boundary value problem: U t = α 2 U xx , U x (0 , t ) = U x ( L, t ) = 0 , t > 0 . Let us consider the total energy: E ( t ) = k L Z 0 U ( x, t ) dx, for some positive constant k . Use the Leibniz rule for differentiating under the integral and integration by parts to show that the function is constant, and explain your answer. 1
ECE 205 - Winter 2017 Assignment 8 solutions Due 02-04-2017 Solution ( I ) We try U ( x, t ) = X ( x ) T ( t ) and we get: ˙ T α 2 T = X 00 X = k, where K is a constant. X (0) = X ( L ) = 0 k = - λ 2 for a non trivial solution. Therefore X ( x ) = A sin( λx ) and X ( L ) = 0 implies λ = L for n Z . A solution is X n ( x ) = A n sin ( nπx L ) . Then ˙ T α 2 T = - L 2 T n = c n e - nπα L 2 t . We absorb c n into A n and we get: U n ( x, t ) A n e - β 2 n t sin nπx L , where β n = nπα L . The general solution is a sum of such terms due to the linearity so, U ( x, t ) = n = X n =1 A n e - β 2 n t sin( λ n x ) , where λ n = L and β n = αλ n . Note that we can combine the solutions with negative integer values with those of positive integer values. We want U ( x, 0) = 100 x L , then n = X n =1 A n sin( λ n x ) = 100 x L ⇐⇒ A n = 2 L L Z 0 100 x L sin nπx L dx = - 200 nπL [ L cos( )] = 200 ( - 1) n +1 . The above integration is performed by parts. Thus, U ( x, t ) = n = X n =1 200 ( - 1) n +1 e - β 2 n t sin( λ n x ) . ( ii ) If we solve the PDE with U t = 0 we get, U xx = 0. Therefore, U ( x, t ) = c 1 x + c 2 . With U (0 , t ) = U ( L, t ) = 0, we get c 1 = c 2 = 0. Therefore, the equilibrium solution is U e ( x, t ) = 0 . ( iii ) We have lim t →∞ e - β 2 n t = 0 . Thus for our general solution from ( I ), all terms die away and lim t →∞ U ( x, t ) = 0 = U e ( x, t ) . The general solution tends to the equilibrium solution.
2
ECE 205 - Winter 2017 Assignment 8 solutions Due 02-04-2017 b) As before, we have U ( x, t ) = X ( x ) T ( t ) with ˙ T α 2 T = X 00 X = k, where k is a constant. Now we also have X 0 (0) = X 0 ( L ) = 0. Therefore, if k = 0 then X = c 1 is a solution. If k = λ 2 > 0, then X ( x ) = c 2 e λx + c 3 e - λx is a solution. But X 0 (0) = X 0 ( L ) = 0 implies c 2 = c 3 = 0. If k = λ 2 < 0, then we have X ( x ) = c 4 sin( λx ) + c 5 cos( λx ). The condition X 0 (0) = 0 gives c 4 = 0. The condition X 0 ( L ) = 0 implies λ = λ n = L where n Z . Thus X n ( x ) = d n