text:
# Tag Info

0

After a lot of trial and error, I created a function that I think is fast enough for general data science (I mean, to be applicable to millions of records). At first, I tried to create two interpolation functions: one for the gap itself (with a zero order interpolation function), and one for the values (the "PathFunction" itself). But Mathematica ...

2

Perhaps, ClearAll[inpField] inpField[arg_, fs_: 5] := InputField[arg, FieldSize -> fs, Background -> Yellow, Appearance -> "Frameless"] Interpretation[{f = {-y, -2 x}, xmin = 0, xmax = 1, ymin = 0, ymax = 1}, Panel@Row[{"StreamPlot[", inpField[Dynamic[f], 12], ", \n ", Invisible["StreamPlo"], "{x, ", inpField[Dynamic[xmin]], ",", ...

3

This is essentially the same algorithm as Leonid's but implemented in terms of Pick instead of sparse arrays: negativePositions2[lst_] := Module[{a, b}, a = Pick[Range[Length[lst]], UnitStep[lst], 0]; b = UnitStep[Differences[a]~Subtract~2]; Transpose[{Pick[a, b~Prepend~1, 1], Pick[a, b~Append~1, 1]}]]

3

Leonid's answer is as impressive as it is too advanced for me (a lot). For lesser mortals like me, not as fast but still acceptable performance: largeTest = RandomInteger[{-100,100},1000000]; a quarter of a second performance for a million length list: Transpose[{#, Append[Rest[# - 1], Length@#]}] & [FoldList[Plus, 1, Length /@ ...

7

Code Using the very fast function intervals from this post by Mr.Wizard, intervals[a_List] := {a[[Prepend[# + 1, 1]]], a[[Append[#, -1]]]}\[Transpose] &@ SparseArray[Differences@a, Automatic, 1]["AdjacencyLists"] We can write: negativePositions[lst_] := intervals[ Flatten@SparseArray[UnitStep[lst], Automatic, 1]["NonzeroPositions"] ...

1

Not a full answer, but there are other tools available, such as Outer and TensorProduct. For example, compare AbsoluteTiming[(mat1 = Table[Etc[t] mtx, {t, 0., 20, 0.01}]);] with AbsoluteTiming[(mat2 = TensorProduct[Et[Range[0., 20, 0.01]], mtx]);] TensorProduct is over twice as fast. The answers are identical: Norm[Flatten[mat1 - mat2]] // Chop

5

Update: You can go even faster with Compile, and exploit the Listable and Parallelization attributes to great effect, if you have a multi-core machine: SeedRandom[0]; cluster = RandomReal[{0, 1}, {5000, 14}]; myDistMatrix = Compile[{{point, _Real, 1}, {tr, _Real, 2}}, Total[(point - tr)^2], RuntimeOptions -> "Speed", ...

4

This is much faster: distMatCompiled = Compile[{{cluster, _Real, 2}}, Outer[Function[diff, diff.diff][#1 - #2] &, cluster, cluster, 1, 1] , CompilationTarget -> "C" ] medoidCompiled[cluster_] := Block[{distances, indexOfMin}, distances = Total@distMatCompiled[cluster]; indexOfMin = First[Ordering[distances, 1]]; {cluster[[indexOfMin]], ...

5

If you're on 10.3+, this should be faster (it's two orders of magnitude faster than your first example on my loungebook): medioid=With[{m = #, d = Tr /@ DistanceMatrix[#, DistanceFunction ->SquaredEuclideanDistance]}, {First@m[[#]], First@#} &@Pick[Range@Length@d, d, Min@d]]&;

4

I do not see an elegant solution using TimeSeriesResample or the like using ResamplingMethod or MissingDataMethod. Maybe there is something undocumented? But programming something that does what you want does look straight forward imo: (* define a function to determine the gapsize for a given time *) gapsize = Function[ {ts, time}, With[ { ...

6

Verily, this is a headache, since Table wants its iterators as Sequence rather than nested list of lists. Here is a method I used quite recently to get sufficiently fast code for this. c1c[n_] := With[{itvals = RandomReal[{0, 1}, {n, 5}]}, With[{iters = Apply[Sequence, Table[{x[j], itvals[[j]]}, {j, n}]]}, c1[n] = cCompile[{}, tTable[1, ...

7

Solution for Update1 The ellipses described by matThetaList can be plotted by Show[ParametricPlot[#[[1]].{Sin[θ], Cos[θ], 1}, {θ, 0, 2 Pi}] & /@ matThetaList, PlotRange -> All] To describe each of these four curves as an ImplicitRegion, first eliminate θ from the parametric equations given in the question, h = Total[#^2 & /@ ({Sin[θ], ...

0

It is handy to use DateString for formatting the time: SetAttributes[myAbsoluteTiming, HoldAll]; myAbsoluteTiming[calculation_] := Module[{startTime, hms, result}, startTime = SessionTime[]; result = calculation; hms = DateString[SessionTime[] - startTime, {"Hour", ":", "Minute", ":", "Second"}]; {hms, result}] It is quite efficient: ...

7

Here, I applied the discrete strategy(sampling $400$ points in a period $2\pi$) to calculate the boundary of ellipses $E_1,\cdots,E_n$. The algorithm mainly consists of four steps as follows : Using the ellipses $E_2,\cdots,E_n$ to trim the black segment of the first ellipse $E_1$; Using the ellipses $E_1,\cdots,E_{n-1}$ to trim the red segment of the last ...

3

This is a very quick-and-dirty, but gives 4X speed-up (7X with tweak for symmetry) on my crappy netbook for the n=8 case, don't have time or patience to test bigger cases to see scaling differences. Perhaps a description of what you're trying to calculate? It appears to be some combinatorial problem, there may well be a much more efficient scheme to do ...

3

As example functions I'll use x[t_] := (0.5 (1 - t^0.8)^0.625 + 0.5 t^0.5)^2 y[t_] := (0.7 (1 - t^0.8)^0.125 + 0.3 t^0.1)^10 To get the points that were calculated while plotting, one can use Reap and Sow. {plot, {tValues, xValues, yValues}} = Reap@ParametricPlot[{Sow[x[Sow[t, "t"]], "x"], Sow[y[t], "y"]}, {t, 0, 1}]; Because ParametricPlot does ...

1

So I found a method that might be of interest, but i'm not sure it's optimal. rawPlotData = ParametricPlot[{x[t], y[t]}, {t, 0, 1}][[1]]; (* get plot data *) plotData = Apply[List, rawPlotData[[1, 3, 2]]][[1]]; Index (1,3,2) of rawPlotData has a Line[-data-] object where -data- contains all the points. I don't know if this is the address for all ...

4

You just need to fully compile your function: fullycompiledBSplineSurf = Hold@Compile[{{ctrlnets, _Real, 3}, {deg1, _Integer}, {deg2, _Integer}, {knots1, _Real, 1}, {knots2, _Real, 1}, {u, _Real}, {v, _Real}}, Module[{i, j, validnets, row, col}, i = searchSpan[{deg1, knots1}, u]; j = searchSpan[{deg2, knots2}, v]; validnets ...

10

Mr.Wizard proposed that the slowness is due to the copying of the data. It seems that this intuition is correct. We can use the two different arguments passing mechanism in LibraryLink to test this conjecture. In LibraryLink, there are the "copied" passing and the "shared" passing. The copied passing copies the data from Mathematica to the library function ...

3

Perhaps something like: f = 6 + # Sin[# + Pi] - Cos[Pi #/4] &; g = # Cos[# + Pi/3]/2 - 1/12 Sin[Pi #] &; Plot[{f[t], g[t]}, {t, 0, 3 Pi}, PlotStyle -> {Red, Blue}, Mesh -> {{0}, {0}}, MeshFunctions -> {ConditionalExpression[f'[#], f''[#] < 0 && g[#] > 0] &, ConditionalExpression[g'[#], g''[#] < 0 && ...

4

I believe that on packed arrays both Dot and Times are performed by external libraries, e.g. Intel MKL, and that following Mathematica's paradigm of immutability the library does not act directly upon the original array but rather a copy. I conjecture that this copying or transport is the cause of the slow-down that you observe and that within Mathematica ...

3

So why the matrix number multiplication and addition so much slower than the matrix vector multiplication? Are there ways to speed them up? It seems that if we use SparseArray for this computation we can get ~3 times speed-up: n = 2000; tres = Table[ (Print[lth]; mtx = RandomReal[{0, 1}, {lth, lth}]; {lth, (AbsoluteTiming[ ...

1

You could introduce further conditional definitions for H which will prevent those computations whose results would end up being thrown away. For instance, you could add: H[i_, j_, k_, l_] /; (i > j || k > l) = Missing[]; As a toy example: m = Table[H[n, 2, 3, 4], {n, 1, 10}] (* Out: {(3 Sqrt[5])/128, (5 Sqrt[15])/256, Missing[], Missing[], ...

2

Here are couple of quick tips. Lets say this is your matrix mat = SparseArray[{{i_, j_} /; Abs[i - j] == 3 -> 1, {i_, i_} -> 1}, {200, 200}]; This is the conventional way to find EigenSystem Eigensystem[SparseArray[{{i_, j_} /; Abs[i - j] == 3 -> 1, {i_, i_} -> 1}, {200, 200}]]; // AbsoluteTiming {53.6551, Null} Now just change the ...

3

Here goes the benchmark for a high-end surface book with i7-6600U (2.6 up to 3.4 GHz, 4 MB cache, 15 W), which might be not quite different from surface pro 4 with intel i7-6650U (2.2 up to 3.4 GHz, 4 MB cache, 15 W). Plugged On battery

1

If the digit and month characters always appear in the exact same place you can use StringTake to extract them and a lookup table for all the conversions: a = Association@Join[ StringPadLeft[ToString[#], 2, "0"] -> # & /@ Range[0, 99], {"Jan" -> 1, "Feb" -> 2, "Mar" -> 3, "Apr" -> 4, "May" -> 5, "Jun" -> 6, "Jul" -> ...

6

If the date format is sufficiently rigid, you might try string patterns or regular expressions. AbsoluteTime[{"05-Mar-2004 10:15:00", {"Day", "-", "MonthNameShort", "-", "Year", " ", "Hour24", ":", "Minute", ":", "Second"}}] // RepeatedTiming (* {0.00043, 3287470500} *) This is about 10 times faster: months = <|"Jan" -> 1, "Feb" -> 2, ...

1

Here's my take, borrowing some code from here and here: ic = Function[x, With[{r = Round[x]}, r + Chop[x - r]], Listable]; SetAttributes[myTiming, HoldAllComplete]; myTiming[calculation_, tf : (Timing | AbsoluteTiming) : AbsoluteTiming] := Module[{timing = tf[calculation]}, Print[StringTemplate["h hr m min s s", ...

0

As pointed out kindly by Oleksandr I bumped into a common beginner's error. Reference to this can be found in the following links: HERE and HERE The correct way to do this, in my case, as I have vectors as variables would have been: fitcst[wlo : {_?NumericQ, _?NumericQ}, wup : {_?NumericQ, _?NumericQ}, sol_] := With[{m = 50, \[Alpha] = 2 Degree}, ...

7

You can use Interpolate to interpolate between the polygon vertices: First make sure the polygon is closed, by appending the first vertex: cyclic = Append[manualPolyPoints, First[manualPolyPoints]]; then accumulate the distance from one vertex to the next: accumulatedDistance = Rescale@Prepend[Accumulate[Norm /@ Differences[cyclic]], 0.]; then ...

1

I prefer @Karsten's approach of making a pure function that can be applied directly to format results from AbsoluteTiming, but if you're new to Mathematica this might be easier to follow: SetAttributes[myAbsoluteTiming, HoldAllComplete]; myAbsoluteTiming[calculation_] := Module[{time, result, hours, minutes, seconds, format}, {time, result} = ...

4

SetAttributes[hmsAbsTiming, HoldAllComplete]; hmsAbsTiming[calculation_] := MapAt[IntegerDigits[IntegerPart[#], MixedRadix[{24, 60, 60}]] &, AbsoluteTiming[ calculation ], 1] If you prefer a Quantity object: SetAttributes[hmsAbsTiming2, HoldAllComplete]; hmsAbsTiming2[calculation_] := MapAt[UnitConvert[Quantity[#, "Seconds"], ...

0

Here's a little one-liner without If, probably not fast on large lists: corr = (! MemberQ[elList, #] & /@ els) /. {True -> 1.13, False -> 1.0}

7

Sure, try for example: pr[14709321003111578837870501266345370175409, 2, 2] There are many things in MMA where small cases/edge cases can be done much more quickly with user code, this is one of them. The advantage here is that PowersRepresentation can handle huge cases...

1

If speed is not you concern, may be this can be worth a try common = Intersection[elList, els]; u = Map[ Position[els, # ] &, common ] ; corr[[ Flatten[u] ]] = 1.13 This can be fit in a single line, and is almost readable corr[[ Flatten[ Position[els, # ] & /@ Intersection[elList, els] ] ]] = 1.13 and will seem even more nice if you use (elList ...

11

You can rewrite your idea using If as follows: If[MemberQ[elList, #], 1., 1.13] & /@ els {1.13, 1., 1., 1.13, 1.} However you may find on larger problems that repetitive use of MemberQ is not as fast as you would like, so consider a hash table in the form of an Association, or if using an older version of Mathematica a Dispatch table. Create a ...

8

Dirichelet random variates are constructed from gamma random variates. Let $$v_j \stackrel{\text{iid}}{\sim} \textsf{Gamma}(\alpha_j,1)$$ for $j = 1, \ldots, n$ and set $$x_j = \frac{v_j}{\sum_{j=1}^n v_j}.$$ Then $x \sim \textsf{Dirichlet}(\alpha)$, where $x = (x_1,\ldots,x_n)$ and $\alpha = (\alpha_1,\ldots,\alpha_n)$. Gamma random variates ...

13

Here's a million points processed in half a second: SeedRandom[0]; (* updated for reproducibility *) xyCoordinateCentreCircle = RandomReal[1, {1*^6, 3}]; Map[ Mean[#[[All, -1]]] &, BinLists[xyCoordinateCentreCircle, {0, 1, 1/10}, {0, 1, 1/10}, {0, 1, 1}], {3}] // AbsoluteTiming (* {0.513721, {{{0.506174}, {0.497757},..., {0.50284}}, ...

3

This is your definition: m = 1; u[x_, t_] = (t^\[Alpha]*x*(2*t^2 + (1 + \[Alpha])*(2 + \[Alpha])))/ Gamma[3 + \[Alpha]]; Your code makes 3.19 seconds on Mma10.4.1 DUt = FullSimplify[(1/Gamma[m - \[Alpha]])*Integrate[(t - \[Tau])^(m - \[Alpha] - 1)*D[u[x, \[Tau]], {\[Tau], m}], {\[Tau], 0, t}], Assumptions -> {m - 1 < \[Alpha] < m, t ...

10

Slightly expanding my comment. It is a partial answer, explaining most but not all of the observed timing increase. First I show some representative timings. Note that I use 2^16-1 and 2^21-1 below, for reasons that will be explained. AbsoluteTiming[RandomInteger[2^16 - 1, 100000000];] AbsoluteTiming[RandomInteger[2^21 - 1, 100000000];] (* Out[37]= ...

Top 50 recent answers are included


text:
# Hatcher exercise 2.1.6 (Simplicial homology)

Compute the simplicial homology groups of the $\Delta$-complex obtained from $n+1$ $2$-simplices $\Delta_0^2,...,\Delta_n^2$ by identifying all three edges of $\Delta_0^2$ to a single edge, and for $i>0$ identifying the edges $[v_0,v_1]$ and $[v_1,v_2]$ of $\Delta_i^2$ to a single edge and the edge $[v_0, v_2]$ to the edge $[v_0, v_1]$ of $\Delta_{i-1}^2$.

My attempt:

Our space $X$ has $1$ vertex, $n+1$ edges and $n+1$ faces.

We have $\partial_0=0$ and $\partial_1=0$. So we conclude that $H_0(X) = \ker \partial_0 / \text{Im} \partial_1 \approx \mathbb{Z}$. Also $H_n(X)$ is trivial for $n>2$.

Now let's compute $H_1(X) = \ker \partial_1 / \text{Im} \partial_2$. Let's call the vertex $v$, the edges $a_i$ and the faces $U_i$ $(i=0,1,...,n)$. We then have $$\partial_2(U_0)= a_0, \qquad \partial_2(U_i) = 2a_i - a_{i-1} \quad (i\neq0).$$

So $\text{Im} \partial_2 = < a_0, 2a_1-a_o,...,2 a_n - a_{n-1}>$.

Also since $\partial_1=0$, we have $\ker \partial_1 = <a_0,...,a_n> \approx \mathbb{Z}^{n+1}$

Is this correct? How do we compute the factor group $H_1(X)$ from this?

One way to compute the factor group would be to view $\textrm{Im}(\partial_2)$ as the largest element in the following ascending chain:
• $\langle a_0\rangle \subset \langle a_0, 2a_1 - a_0\rangle \subset \langle a_0, 2a_1 - a_0, 2a_2-a_1\rangle \subset \dots \subset \langle a_0, 2a_1 - a_0, \ldots, 2a_n - a_{n-1}\rangle$
Now you can inductively determine the isomorphism class (in the standard classification of finitely-generated abelian groups) of the quotient $\mathbb{Z}^{n+1} / \langle a_0, 2a_1 - a_0, \ldots, 2a_{i+1} - a_{i}\rangle$ for $i = 0, 1, \ldots, n-1$. It is clear, for instance, that $\mathbb{Z}^{n+1}/\langle a_0\rangle \cong \mathbb{Z}^n$. Hopefully that is enough get started.

format: plain


text:
# Small-Molecule Suppressors of Cytokine-Induced Beta-Cell Apoptosis

 Title: Small-Molecule Suppressors of Cytokine-Induced Beta-Cell Apoptosis Author: Chou, Danny Hung-Chieh Citation: Chou, Danny Hung-Chieh. 2011. Small-Molecule Suppressors of Cytokine-Induced Beta-Cell Apoptosis. Doctoral dissertation, Harvard University. Full Text & Related Files: Chou_gsas.harvard_0084L_10019.pdf (8.185Mb; PDF) Abstract: Type-1 diabetes is caused by the autoimmune destruction of insulin-producing beta cells in the pancreas. Beta-cell apoptosis involves a complex set of signaling cascades initiated by $$interleukin-1\beta (IL-1\beta)$$, $$interferon-\gamma (IFN-\gamma)$$, and $$tumor necrosis factor-\alpha (TNF-\alpha)$$. $$IL-1\beta$$ and $$TNF-\alpha$$ induce $$NF\kappa B$$ expression, while $$IFN-\gamma$$ induces STAT1 activation. These cytokines lead to a decrease of beta-cell function. The goal of this thesis is to identify small-molecule suppressors of cytokine-induced beta-cell apoptosis using high-throughput screening approach. Using the rat INS-1E beta-cell line, I developed an assay to measure cellular viability after 48 hours of cytokine treatment. I screened 29,760 compounds for their ability to suppress the negative effects of the cytokines. I identified several compounds to be suppressors of beta-cell apoptosis. These efforts led to the discovery of $$GSK-3\beta$$ and HDAC3 as novel targets for suppressing beta-cell apoptosis. I also followed up on BRD0608, a novel suppressor that increased ATP levels and decreased caspase activity in the presence of cytokines. To follow up this compound, 35 analogs related to BRD0476 were synthesized using solid-phase synthesis and tested for their protective effects in the presence of cytokines. A structurally related analog, BRD0476, was found to be more potent and active in human islets, decreasing caspase activation and increasing insulin secretion after a 6-day treatment. I performed gene-expression profiling of INS-1E cells treated with the cytokine cocktail in the absence or presence of $$10\mu M$$ BRD0476. Gene-set enrichment analysis revealed that the gene sets most significantly changed by BRD0476 involved cellular responses to $$IFN-\gamma$$. I therefore assessed the effects of BRD0476 on STAT1 transcriptional activity. Cytokine treatment increased the reporter-gene luciferase activity, while co-treatment with BRD0476 reduced this activity significantly. To identify the intracellular target(s) of BRD0476, I collaborated with the Proteomics Platform in Broad Institute using SILAC (stable isotope labeling by amino acids in cell culture). SILAC is a mass spectrometry-based method to identify proteins that bind a small molecule attached to a bead. Deubiquitinase USP9X was pulled down by BRD0476. Knock-down of USP9X by siRNA phenocopied the protective effects of BRD0476. Binding assays were performed to identify interactions between BRD0476 and USP9X. Terms of Use: This article is made available under the terms and conditions applicable to Other Posted Material, as set forth at http://nrs.harvard.edu/urn-3:HUL.InstRepos:dash.current.terms-of-use#LAA Citable link to this page: http://nrs.harvard.edu/urn-3:HUL.InstRepos:10121978 Downloads of this work:


text:
2 added 1 characters in body

Warren Moors and Julia Novak in a paper entitled "Order matters when choosing sets" proved that if 1 < w < t < v are integers then $${{{v}\choose {w}}\choose {t}} > {{{v}\choose {t}}\choose {w}}.$$ In words: the number of t-subsets from the family of w-subsets of [v]={1,2,...,v} is larger than the number of w-subsets from the family of t-subsets of [v].

## The question

(proposed by Steve Wilson in a problem session of this conference)

Find a combinatorial explanation for Moors and Novak's result.

### Remark

Moors and Warren give an elementary proof an even stronger inequality. $$(w!)^{t-1}{{{v}\choose {w}}\choose {t}} > (t!)^{w-1} {{{v}\choose {t}}\choose {w}}.$$

1

# Order matters when choosing sets

Warren Moors and Julia Novak in a paper entitled "Order matters when choosing sets" proved that if 1 < w < t < v are integers then $${{{v}\choose {w}}\choose {t}} > {{{v}\choose {t}}\choose {w}}.$$ In words: the number of t-subsets from the family of w-subsets of [v]={1,2,...,v} is larger than the number of w-subsets from the family of t-subsets of [v].

## The question

(proposed by Steve Wilson in a problem session of this conference)

Find a combinatorial explanation for Moors and Novak's result.

### Remark

Moors and Warren give an elementary proof an even stronger inequality. $$(w!)^{t-1}{{{v}\choose {w}}\choose {t}} > (t!)^{w-1} {{{v}\choose {t}}\choose {w}}.$$


text:
Get our free extension to see links to code for papers anywhere online!

# TDprop: Does Jacobi Preconditioning Help Temporal Difference Learning?

We investigate whether Jacobi preconditioning, accounting for the bootstrap term in temporal difference (TD) learning, can help boost performance of adaptive optimizers. Our method, TDprop, computes a per parameter learning rate based on the diagonal preconditioning of the TD update rule. We show how this can be used in both $n$-step returns and TD($\lambda$). Our theoretical findings demonstrate that including this additional preconditioning information is, surprisingly, comparable to normal semi-gradient TD if the optimal learning rate is found for both via a hyperparameter search. In Deep RL experiments using Expected SARSA, TDprop meets or exceeds the performance of Adam in all tested games under near-optimal learning rates, but a well-tuned SGD can yield similar improvements -- matching our theory. Our findings suggest that Jacobi preconditioning may improve upon typical adaptive optimization methods in Deep RL, but despite incorporating additional information from the TD bootstrap term, may not always be better than SGD.

* Presented at the Theoretical Foundations of Reinforcement Learning workshop at ICML 2020


text:
# Netzschleuder network catalogue, repository and centrifuge

Problems with this dataset? Open an issue.
You may also take a look at the source code.
The network in this dataset can be loaded directly from graph-tool with:
import graph_tool.all as gt
g = gt.collection.ns["corporate_directors"]

# corporate_directors — Global corporate directors (2016)

Description

Bipartite network of directors and the companies on whose boards they sit, spanning 54 countries worldwide, constructed from data collected by the Financial Times (c. Sept. 2016). Person nodes are annotated with age and gender. Company nodes are annotated with their country, sector, industry, and number of employees.1

1. Description obtained from the ICON project.

Tags
Name Nodes Edges $\left<k\right>$ $\sigma_k$ $\lambda_h$ $\tau$ $r$ $c$ $\oslash$ $S$ Kind Mode NPs EPs gt GraphML GML csv


text:
# Working out probability of winning a match

Say you have two people playing first to 11 points for a game of whatever. A has a 0.55 chance to get a point and B has a 0.45 chance. How would I go about working out the probability that A will win the match?

The way I think you'd work it out is by running it say, 10000 times and then do :

(number of games A wins) / (total number of games). Is this correct?

-
 possible duplicate of If a player is 50% as good as I am at a game, how many games will it be before she finally wins one game? (The question is phrased a bit differently, but answering it also requires working out the probability you want, and this is what the answers do.) – joriki Dec 14 '12 at 9:31 Thanks. Yeah, setting the probability to win at 50% each came out with them winning 50% of the time. – Arktri Dec 14 '12 at 9:36 That's a misunderstanding. That somewhat ambiguous title is intended to mean that one player wins $2$ out of $3$ games. Anyway, the precise probability isn't important; the answers can readily be adapted to an arbitrary probability. – joriki Dec 14 '12 at 9:50

So you want to know $$\sum_{i=11}^{21} {21 \choose i} p^i (1-p)^{21-i}$$ where $p=0.55$. This gives about $0.679$ while your simulation is likely to give an answer between $0.67$ and $0.69$.


text:
# Resources tagged with: Creating and manipulating expressions and formulae

Filter by: Content type:
Age range:
Challenge level:

### There are 131 results

Broad Topics > Algebraic expressions, equations and formulae > Creating and manipulating expressions and formulae

### Consecutive Squares

##### Age 14 to 16 Challenge Level:

The squares of any 8 consecutive numbers can be arranged into two sets of four numbers with the same sum. True of false?

### Perfectly Square

##### Age 14 to 16 Challenge Level:

The sums of the squares of three related numbers is also a perfect square - can you explain why?

### Enriching Experience

##### Age 14 to 16 Challenge Level:

Find the five distinct digits N, R, I, C and H in the following nomogram

### Pair Products

##### Age 14 to 16 Challenge Level:

Choose four consecutive whole numbers. Multiply the first and last numbers together. Multiply the middle pair together. What do you notice?

##### Age 11 to 14 Challenge Level:

Surprising numerical patterns can be explained using algebra and diagrams...

### Fibonacci Surprises

##### Age 11 to 14 Challenge Level:

Play around with the Fibonacci sequence and discover some surprising results!

### Unusual Long Division - Square Roots Before Calculators

##### Age 14 to 16 Challenge Level:

However did we manage before calculators? Is there an efficient way to do a square root if you have to do the work yourself?

### Pythagoras Perimeters

##### Age 14 to 16 Challenge Level:

If you know the perimeter of a right angled triangle, what can you say about the area?

### Lower Bound

##### Age 14 to 16 Challenge Level:

What would you get if you continued this sequence of fraction sums? 1/2 + 2/1 = 2/3 + 3/2 = 3/4 + 4/3 =

### Chocolate Maths

##### Age 11 to 14 Challenge Level:

Pick the number of times a week that you eat chocolate. This number must be more than one but less than ten. Multiply this number by 2. Add 5 (for Sunday). Multiply by 50... Can you explain why it. . . .

### Terminology

##### Age 14 to 16 Challenge Level:

Given an equilateral triangle inside an isosceles triangle, can you find a relationship between the angles?

### The Simple Life

##### Age 11 to 14 Challenge Level:

The answer is $5x+8y$... What was the question?

### Always the Same

##### Age 11 to 14 Challenge Level:

Arrange the numbers 1 to 16 into a 4 by 4 array. Choose a number. Cross out the numbers on the same row and column. Repeat this process. Add up you four numbers. Why do they always add up to 34?

### There and Back

##### Age 14 to 16 Challenge Level:

Brian swims at twice the speed that a river is flowing, downstream from one moored boat to another and back again, taking 12 minutes altogether. How long would it have taken him in still water?

### Think of Two Numbers

##### Age 11 to 14 Challenge Level:

Think of two whole numbers under 10, and follow the steps. I can work out both your numbers very quickly. How?

### Always Perfect

##### Age 14 to 16 Challenge Level:

Show that if you add 1 to the product of four consecutive numbers the answer is ALWAYS a perfect square.

### Perimeter Expressions

##### Age 11 to 14 Challenge Level:

Create some shapes by combining two or more rectangles. What can you say about the areas and perimeters of the shapes you can make?

### Chocolate 2010

##### Age 14 to 16 Challenge Level:

First of all, pick the number of times a week that you would like to eat chocolate. Multiply this number by 2...

### Regular Hexagon Loops

##### Age 11 to 14 Challenge Level:

Make some loops out of regular hexagons. What rules can you discover?

### Harmonic Triangle

##### Age 14 to 16 Challenge Level:

Can you see how to build a harmonic triangle? Can you work out the next two rows?

##### Age 7 to 14 Challenge Level:

Think of a number and follow the machine's instructions... I know what your number is! Can you explain how I know?

### More Mathematical Mysteries

##### Age 11 to 14 Challenge Level:

Write down a three-digit number Change the order of the digits to get a different number Find the difference between the two three digit numbers Follow the rest of the instructions then try. . . .

### Reversals

##### Age 11 to 14 Challenge Level:

Where should you start, if you want to finish back where you started?

### Algebra from Geometry

##### Age 11 to 16 Challenge Level:

Account of an investigation which starts from the area of an annulus and leads to the formula for the difference of two squares.

### Puzzling Place Value

##### Age 14 to 16 Challenge Level:

Can you explain what is going on in these puzzling number tricks?

### The Number Jumbler

##### Age 7 to 14 Challenge Level:

The Number Jumbler can always work out your chosen symbol. Can you work out how?

### Training Schedule

##### Age 14 to 16 Challenge Level:

The heptathlon is an athletics competition consisting of 7 events. Can you make sense of the scoring system in order to advise a heptathlete on the best way to reach her target?

### Difference of Two Squares

##### Age 14 to 16 Challenge Level:

What is special about the difference between squares of numbers adjacent to multiples of three?

##### Age 14 to 16 Challenge Level:

Robert noticed some interesting patterns when he highlighted square numbers in a spreadsheet. Can you prove that the patterns will continue?

### Square Number Surprises

##### Age 11 to 14 Challenge Level:

Think of a number and follow my instructions. Tell me your answer, and I'll tell you what you started with! Can you explain how I know?

##### Age 11 to 14 Challenge Level:

Think of a number, add one, double it, take away 3, add the number you first thought of, add 7, divide by 3 and take away the number you first thought of. You should now be left with 2. How do I. . . .

### Beach Huts

##### Age 11 to 14 Challenge Level:

Can you figure out how sequences of beach huts are generated?

### Algebra Match

##### Age 11 to 16 Challenge Level:

A task which depends on members of the group noticing the needs of others and responding.

### Magic Sums and Products

##### Age 11 to 16

How to build your own magic squares.

### Never Prime

##### Age 14 to 16 Challenge Level:

If a two digit number has its digits reversed and the smaller of the two numbers is subtracted from the larger, prove the difference can never be prime.

### ' Tis Whole

##### Age 14 to 18 Challenge Level:

Take a few whole numbers away from a triangle number. If you know the mean of the remaining numbers can you find the triangle number and which numbers were removed?

### Card Trick 1

##### Age 11 to 14 Challenge Level:

Can you explain how this card trick works?

### Number Rules - OK

##### Age 14 to 16 Challenge Level:

Can you convince me of each of the following: If a square number is multiplied by a square number the product is ALWAYS a square number...

### What's Possible?

##### Age 14 to 16 Challenge Level:

Many numbers can be expressed as the difference of two perfect squares. What do you notice about the numbers you CANNOT make?

### Good Work If You Can Get It

##### Age 11 to 14 Challenge Level:

A job needs three men but in fact six people do it. When it is finished they are all paid the same. How much was paid in total, and much does each man get if the money is shared as Fred suggests?

### Even So

##### Age 11 to 14 Challenge Level:

Find some triples of whole numbers a, b and c such that a^2 + b^2 + c^2 is a multiple of 4. Is it necessarily the case that a, b and c must all be even? If so, can you explain why?

### Series Sums

##### Age 14 to 16 Challenge Level:

Let S1 = 1 , S2 = 2 + 3, S3 = 4 + 5 + 6 ,........ Calculate S17.

### Archimedes and Numerical Roots

##### Age 14 to 16 Challenge Level:

The problem is how did Archimedes calculate the lengths of the sides of the polygons which needed him to be able to calculate square roots?

### Fair Shares?

##### Age 14 to 16 Challenge Level:

A mother wants to share a sum of money by giving each of her children in turn a lump sum plus a fraction of the remainder. How can she do this in order to share the money out equally?

### Quick Times

##### Age 11 to 14 Challenge Level:

32 x 38 = 30 x 40 + 2 x 8; 34 x 36 = 30 x 40 + 4 x 6; 56 x 54 = 50 x 60 + 6 x 4; 73 x 77 = 70 x 80 + 3 x 7 Verify and generalise if possible.

### Sums of Pairs

##### Age 11 to 16 Challenge Level:

Jo has three numbers which she adds together in pairs. When she does this she has three different totals: 11, 17 and 22 What are the three numbers Jo had to start with?”

### Sum Equals Product

##### Age 11 to 14 Challenge Level:

The sum of the numbers 4 and 1 [1/3] is the same as the product of 4 and 1 [1/3]; that is to say 4 + 1 [1/3] = 4 � 1 [1/3]. What other numbers have the sum equal to the product and can this be so. . . .

### Boxed In

##### Age 11 to 14 Challenge Level:

A box has faces with areas 3, 12 and 25 square centimetres. What is the volume of the box?

### Diophantine N-tuples

##### Age 14 to 16 Challenge Level:

Can you explain why a sequence of operations always gives you perfect squares?


text:
# Are the molar extinction coefficient and cross-section of an absorption related to the probability of absorption?

I have struggled to find a formal definition of cross-section of absorption; from what I've gathered, its best defined as 'the intensity of absorption'.

Wikipedia's formal definition of the molar extinction coefficient is 'how strongly a species absorbs EMR at a given wavelength, per molar concentration'.

So how are the molar extinction coefficient and cross-section different? I presume that whilst the molar extinction coefficient remains constant for a given wavelength across all concentrations, the cross-section differs for a given wavelength with changing concentration.

Is either the molar extinction coefficient or cross-section of an absorption equal to the probability that a single species absorbs a photon at any one point in time?


text:
# A calculation of the gauge anomaly with the chiral overlap operator

Ago, Taichi (Department of Physics, University of Tokyo, Tokyo, Japan)

21 November 2018

Abstract: We investigate the property of the effective action with the chiral overlap operator, which was derived by Grabowska and Kaplan. They proposed a lattice formulation of four-dimensional chiral gauge theory, which is derived from their domain-wall formulation. In this formulation, an extra dimension is introduced and the gauge field along the extra dimension is evolved by the gradient flow. The chiral overlap operator satisfies the Ginsparg–Wilson relation and only depends on the gauge fields on the two boundaries. We start from the arbitrary even-dimensional chiral overlap operator. We treat the gauge fields on the two boundaries independently, and derive the general expression to calculate the gauge anomaly with the chiral overlap operator in the continuum limit. As a result, we show that the gauge anomalies with the chiral overlap operator in two, four, and six dimensions in the continuum limit are equivalent to those known in the continuum theory up to total derivatives.

Published in: PTEP 2018 (2018) 113B01
DOI: 10.1093/ptep/pty112
arXiv: 1808.02701

Fulltext:
PDF XML PDF (PDFA)


text:
# httplib2 / libhttplib2.tex

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 % Template for a library manual section. % PLEASE REMOVE THE COMMENTS AFTER USING THE TEMPLATE % % Complete documentation on the extended LaTeX markup used for Python % documentation is available in Documenting Python'', which is part % of the standard documentation for Python. It may be found online % at: % % http://www.python.org/doc/current/doc/doc.html % ==== 0. ==== % Copy this file to /lib.tex, and edit that file % according to the instructions below. % ==== 1. ==== % The section prologue. Give the section a title and provide some % meta-information. References to the module should use % \refbimodindex, \refstmodindex, \refexmodindex or \refmodindex, as % appropriate. \section{\module{httplib2} A comprehensive HTTP client library. } % Choose one of these to specify the module module name. If there's % an underscore in the name, use % \declaremodule[modname]{...}{mod_name} instead. % \declaremodule{}{httplib2} % not standard, in Python % Portability statement: Uncomment and fill in the parameter to specify the % availability of the module. The parameter can be Unix, IRIX, SunOS, Mac, % Windows, or lots of other stuff. When Mac'' is specified, the availability % statement will say Macintosh'' and the Module Index may say Mac''. % Please use a name that has already been used whenever applicable. If this % is omitted, no availability statement is produced or implied. % % \platform{Unix} % These apply to all modules, and may be given more than once: \moduleauthor{Joe Gregorio}{joe@bitworking.org} % Author of the module code; % omit if not known. \sectionauthor{Joe Gregorio}{joe@bitworking.org} % Author of the documentation, % even if not a module section. % Leave at least one blank line after this, to simplify ad-hoc tools % that are sometimes used to massage these files. \modulesynopsis{A comprehensive HTTP client library, \module{httplib2} supports many features left out of other HTTP libraries.} % ==== 2. ==== % Give a short overview of what the module does. % If it is platform specific, mention this. % Mention other important restrictions or general operating principles. % For example: The \module{httplib2} module is a comprehensive HTTP client library with the following features: \begin{description} \item[HTTP and HTTPS] HTTPS support is only available if the socket module was compiled with SSL support. \item[Keep-Alive] Supports HTTP 1.1 Keep-Alive, keeping the socket open and performing multiple requests over the same connection if possible. \item[Authentication] The following three types of HTTP Authentication are supported. These can be used over both HTTP and HTTPS. \begin{itemize} \item Digest \item Basic \item WSSE \end{itemize} \item[Caching] The module can optionally operate with a private cache that understands the Cache-Control: header and uses both the ETag and Last-Modified cache validators. \item[All Methods] The module can handle any HTTP request method, not just GET and POST. \item[Redirects] Automatically follows 3XX redirects on GETs. \item[Compression] Handles both 'deflate' and 'gzip' types of compression. \item[Proxies] If the Socksipy module is installed then httplib2 can handle sock4, sock5 and http proxies. \item[Lost update support] Automatically adds back ETags into PUT requests to resources we have already cached. This implements Section 3.2 of Detecting the Lost Update Problem Using Unreserved Checkout \end{description} % ==== 3. ==== % List the public functions defined by the module. Begin with a % standard phrase. You may also list the exceptions and other data % items defined in the module, insofar as they are important for the % user. The \module{httplib2} module defines the following variables: % ---- 3.2. ---- % Data items are described using a datadesc'' block. This has only % one parameter: the item's name. \begin{datadesc}{debuglevel} The amount of debugging information to print. The default is 0. \end{datadesc} % --- 3.3. --- % Exceptions are described using a excdesc'' block. This has only % one parameter: the exception name. Exceptions defined as classes in % the source code should be documented using this environment, but % constructor parameters must be omitted. The \module{httplib2} module may raise the following Exceptions. Note that there is an option that turns exceptions into normal responses with an HTTP status code indicating an error occured. See \member{Http.force_exception_to_status_code} \begin{excdesc}{HttpLib2Error} The Base Exception for all exceptions raised by httplib2. \end{excdesc} \begin{excdesc}{RedirectMissingLocation} A 3xx redirect response code was provided but no Location: header was provided to point to the new location. \end{excdesc} \begin{excdesc}{RedirectLimit} The maximum number of redirections was reached without coming to a final URI. \end{excdesc} \begin{excdesc}{ServerNotFoundError} Unable to resolve the host name given. \end{excdesc} \begin{excdesc}{RelativeURIError} A relative, as opposed to an absolute URI, was passed into request(). \end{excdesc} \begin{excdesc}{FailedToDecompressContent} The headers claimed that the content of the response was compressed but the decompression algorithm applied to the content failed. \end{excdesc} \begin{excdesc}{UnimplementedDigestAuthOptionError} The server requested a type of Digest authentication that we are unfamiliar with. \end{excdesc} \begin{excdesc}{UnimplementedHmacDigestAuthOptionError} The server requested a type of HMACDigest authentication that we are unfamiliar with. \end{excdesc} % ---- 3.4. ---- % Other standard environments: % % classdesc - Python classes; same arguments are funcdesc % methoddesc - methods, like funcdesc but has an optional parameter % to give the type name: \begin{methoddesc}[mytype]{name}{args} % By default, the type name will be the name of the % last class defined using classdesc. The type name % is required if the type is implemented in C (because % there's no classdesc) or if the class isn't directly % documented (if it's private). % memberdesc - data members, like datadesc, but with an optional % type name like methoddesc. \begin{classdesc}{Http}{\optional{cache=None}, \optional{timeout=None}, \optional{proxy_info=None}} The class that represents a client HTTP interface. The \var{cache} parameter is either the name of a directory to be used as a flat file cache, or it must an object that implements the required caching interface. The \var{timeout} parameter is the socket level timeout. The \var{proxy_info} is an instance of \class{ProxyInfo} and is supplied if a proxy is to be used. Note that the Socksipy module must be installed for proxy support to work. \end{classdesc} \begin{classdesc}{Response}{info} Response is a subclass of \class{dict} and instances of this class are returned from calls to Http.request. The \var{info} parameter is either an \class{rfc822.Message} or an \class{httplib.HTTPResponse} object. \end{classdesc} \begin{classdesc}{FileCache}{dir_name, \optional{safe=safename}} FileCache implements a Cache as a directory of files. The \var{dir_name} parameter is the name of the directory to use. If the directory does not exist then FileCache attempts to create the directory. The optional \var{safe} parameter is a funtion which generates the cache filename for each URI. A FileCache object is constructed and used for caching when you pass a directory name into the constructor of \class{Http}. \end{classdesc} \begin{classdesc}{ProxyInfo}{proxy_type, proxy_host, proxy_port, \optional{proxy_rdns=None}, \optional{proxy_user=None}, \optional{proxy_pass=None}} The parameter \var{proxy_type} must be set to one of socks.PROXY_TYPE_XXX constants. The \var{proxy_host} and \var{proxy_port} must be set to the location of the proxy. The optional \var{proxy_rdns} should be set to True if the DNS server on the proxy should be used. The \var{proxy_user} and \var{proxy_pass} are supplied when the proxy is protected by authentication. \end{classdesc} % If your module defines new object types (for a built-in module) or % classes (for a module written in Python), you should list the % methods and instance variables (if any) of each type or class in a % separate subsection. \subsection{Http Objects} \label{http-objects} % This label is generally useful for referencing this section, but is % also used to give a filename when generating HTML. Http objects have the following methods: \begin{methoddesc}[Http]{request}{uri, \optional{method="GET", body=None, headers=None, redirections=DEFAULT_MAX_REDIRECTS, connection_type=None}} Performs a single HTTP request. The \var{uri} is the URI of the HTTP resource and can begin with either \code{http} or \code{https}. The value of \var{uri} must be an absolute URI. The \var{method} is the HTTP method to perform, such as \code{GET}, \code{POST}, \code{DELETE}, etc. There is no restriction on the methods allowed. The \var{body} is the entity body to be sent with the request. It is a string object. Any extra headers that are to be sent with the request should be provided in the \var{headers} dictionary. The maximum number of redirect to follow before raising an exception is \var{redirections}. The default is 5. The \var{connection_type} is the type of connection object to use. The supplied class should implement the interface of httplib.HTTPConnection. The return value is a tuple of (response, content), the first being and instance of the \class{Response} class, the second being a string that contains the response entity body. \end{methoddesc} \begin{methoddesc}[Http]{add_credentials}{name, password, \optional{domain=None}} Adds a name and password that will be used when a request requires authentication. Supplying the optional \var{domain} name will restrict these credentials to only be sent to the specified domain. If \var{domain} is not specified then the given credentials will be used to try to satisfy every HTTP 401 challenge. \end{methoddesc} \begin{methoddesc}[Http]{add_certificate}{key, cert, domain} Add a \var{key} and \var{cert} that will be used for an SSL connection to the specified domain. \var{keyfile} is the name of a PEM formatted file that contains your private key. \var{certfile} is a PEM formatted certificate chain file. \end{methoddesc} \begin{methoddesc}[Http]{clear_credentials}{} Remove all the names and passwords used for authentication. \end{methoddesc} \begin{memberdesc}[Http]{follow_redirects} If \code{True}, which is the default, safe redirects are followed, where safe means that the client is only doing a \code{GET} or \code{HEAD} on the URI to which it is being redirected. If \code{False} then no redirects are followed. Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' must be True. \end{memberdesc} \begin{memberdesc}[Http]{follow_all_redirects} If \code{False}, which is the default, only safe redirects are followed, where safe means that the client is only doing a \code{GET} or \code{HEAD} on the URI to which it is being redirected. If \code{True} then all redirects are followed. Note that a False 'follow_redirects' takes precedence over a True 'follow_all_redirects'. Another way of saying that is for 'follow_all_redirects' to have any affect, 'follow_redirects' must be True. \end{memberdesc} \begin{memberdesc}[Http]{force_exception_to_status_code} If \code{True}, which is the default, then no \module{httplib2} exceptions will be thrown. Instead, those error conditions will be turned into \class{Response} objects that will be returned normally. If \code{False}, then exceptions will be thrown. \end{memberdesc} \begin{memberdesc}[Http]{ignore_etag} Defaults to \code{False}. If \code{True}, then any etags present in the cached response are ignored when processing the current request, i.e. httplib2 does \strong{not} use 'if-match' for PUT or 'if-none-match' when GET or HEAD requests are made. This is mainly to deal with broken servers which supply an etag, but change it capriciously. \end{memberdesc} \subsection{Cache Objects} \label{cache-objects} % This label is generally useful for referencing this section, but is % also used to give a filename when generating HTML. If you wish to supply your own caching implementation then you will need to pass in an object that supports the following methods. Note that the \module{memcache} module supports this interface natively. \begin{methoddesc}[Cache]{get}{key} Takes a string \var{key} and returns the value as a string. \end{methoddesc} \begin{methoddesc}[Cache]{set}{key, value} Takes a string \var{key} and \var{value} and stores it in the cache. \end{methoddesc} \begin{methoddesc}[Cache]{delete}{key} Deletes the cached value stored at \var{key}. The value of \var{key} is a string. \end{methoddesc} \subsection{Response Objects} \label{response-objects} % This label is generally useful for referencing this section, but is % also used to give a filename when generating HTML. Response objects are derived from \class{dict} and map header names (lower case with the trailing colon removed) to header values. In addition to the dict methods a Response object also has: \begin{memberdesc}[Response]{fromcache} If \code{true} the the response was returned from the cache. \end{memberdesc} \begin{memberdesc}[Response]{version} The version of HTTP that the server supports. A value of 11 means '1.1'. \end{memberdesc} \begin{memberdesc}[Response]{status} The numerical HTTP status code returned in the response. \end{memberdesc} \begin{memberdesc}[Response]{reason} The human readable component of the HTTP response status code. \end{memberdesc} \begin{memberdesc}[Response]{previous} If redirects are followed then the \class{Response} object returned is just for the very last HTTP request and \var{previous} points to the previous \class{Response} object. In this manner they form a chain going back through the responses to the very first response. Will be \code{None} if there are no previous respones. \end{memberdesc} The Response object also populates the header \code{content-location}, that contains the URI that was ultimately requested. This is useful if redirects were encountered, you can determine the ultimate URI that the request was sent to. All Response objects contain this key value, including \code{previous} responses so you can determine the entire chain of redirects. If \member{Http.force_exception_to_status_code} is \code{True} and the number of redirects has exceeded the number of allowed number of redirects then the \class{Response} object will report the error in the status code, but the complete chain of previous responses will still be in tact. % ==== 4. ==== % Now is probably a good time for a complete example. (Alternatively, % an example giving the flavor of the module may be given before the % detailed list of functions.) \subsection{Examples \label{httplib2-example}} To do a simple \code{GET} request just supply the absolute URI of the resource: \begin{verbatim} import httplib2 h = httplib2.Http() resp, content = h.request("http://bitworking.org/") assert resp.status == 200 assert resp['content-type'] == 'text/html' \end{verbatim} Here is more complex example that does a PUT of some text to a resource that requires authentication. The Http instance also uses a file cache in the directory \code{.cache}. \begin{verbatim} import httplib2 h = httplib2.Http(".cache") h.add_credentials('name', 'password') resp, content = h.request("https://example.org/chap/2", "PUT", body="This is text", headers={'content-type':'text/plain'} ) \end{verbatim} Here is an example that connects to a server that supports the Atom Publishing Protocol. \begin{verbatim} import httplib2 h = httplib2.Http() h.add_credentials(myname, mypasswd) h.follow_all_redirects = True headers = {'Content-Type': 'application/atom+xml'} body = """ Atom-Powered Robots Run Amok urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a 2003-12-13T18:30:02Z John Doe Some text. """ uri = "http://www.example.com/collection/" resp, content = h.request(uri, "POST", body=body, headers=headers) \end{verbatim} % Note that there is no trailing ">>> " prompt shown. Here is an example of providing data to an HTML form processor. In this case we presume this is a POST form. We need to take our data and format it as "application/x-www-form-urlencoded" data and use that as a body for a POST request. \begin{verbatim} >>> import httplib2 >>> import urllib >>> data = {'name': 'fred', 'address': '123 shady lane'} >>> body = urllib.urlencode(data) >>> body 'name=fred&address=123+shady+lane' >>> h = httplib2.Http() >>> resp, content = h.request("http://example.com", method="POST", body=body) \end{verbatim} % Note that there is no trailing ">>> " prompt shown. Here is an example of using a proxy server: \begin{verbatim} import httplib2 import socks httplib2.debuglevel=4 h = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, 'localhost', 8000)) r,c = h.request("http://bitworking.org/news/") \end{verbatim}


text:
# 2 + 6 (x — 4) = 3х - 18 + Зx

###### Question:

2 + 6 (x — 4) = 3х - 18 + Зx

### Was the 1991 Iraq war justified?

Was the 1991 Iraq war justified?...

### What is the sum of -7 + 5? You may use the number line to help you figure out the answer -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 4 5 6 7 8 9 10 Drag and drop the sum into the box to match the expression

What is the sum of -7 + 5? You may use the number line to help you figure out the answer -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 4 5 6 7 8 9 10 Drag and drop the sum into the box to match the expression...

### Can i get help please?? :) As the science teacher explained how the cells doubled, Emma felt frustrated. To help Emma understand, the teacher compared the cells to using exponents in math. The first stage is 21 = 2; the second stage is 22 = 4 and the pattern continues. How many cells there will be on the 5th stage? A. 5 B. 10 C. 32 D. 64

can i get help please?? :) As the science teacher explained how the cells doubled, Emma felt frustrated. To help Emma understand, the teacher compared the cells to using exponents in math. The first stage is 21 = 2; the second stage is 22 = 4 and the pattern continues. How many cells there will be o...

### What is the measurement of A: 28 B: 62 C: 90 D: 118 E: 208

What is the measurement of A: 28 B: 62 C: 90 D: 118 E: 208...

### Aaron earns a weekly salary of 350$plus a 7% commission on sales. Last week, his sales totaled$3200. What was his total pay ?

Aaron earns a weekly salary of 350$plus a 7% commission on sales. Last week, his sales totaled$3200. What was his total pay ?...

### Simplify the following expression completely using distribution and combining like terms3(2a - 3) -6

Simplify the following expression completely using distribution and combining like terms3(2a - 3) -6...

### The 3rd multiple of the difference of 2 from x is equal to 15. Construct an equation and find the value of x.

The 3rd multiple of the difference of 2 from x is equal to 15. Construct an equation and find the value of x....

### The chemical formula for water is H20. What does the formula show about each element in the compound? Select one: the mass of protons in each atom the number of atoms of each element the number of valence electrons the charge of the compound

The chemical formula for water is H20. What does the formula show about each element in the compound? Select one: the mass of protons in each atom the number of atoms of each element the number of valence electrons the charge of the compound...

### In what industry did industrialization begin in the united states

In what industry did industrialization begin in the united states...

### 3x + ? = 11x what is “?”

3x + ? = 11x what is “?”...

### How did the leaders of the United States attempt to form a national identity?

How did the leaders of the United States attempt to form a national identity?...

### Elements in Group 18, at the far right of the periodic table, are called what? Transition Metals Noble Gases Alkaline Metals Halogens

Elements in Group 18, at the far right of the periodic table, are called what? Transition Metals Noble Gases Alkaline Metals Halogens...

### What is the source of more than half of Bruneis wealth?

what is the source of more than half of Bruneis wealth?...

### Need Help!What conclusion can be drawn about the number of elements the make up the majority of the world in which we live and the total number of elements identified on the Periodic table?

Need Help!What conclusion can be drawn about the number of elements the make up the majority of the world in which we live and the total number of elements identified on the Periodic table?...

### What is the geometric mean between 4 and 9?

what is the geometric mean between 4 and 9?...

### Does the sentence state a fact or an opinion? The Mariana Trench, the deepest point of Earth's oceans, would be more exciting to visit than Mount Everest, the planet's highest mountain.

Does the sentence state a fact or an opinion? The Mariana Trench, the deepest point of Earth's oceans, would be more exciting to visit than Mount Everest, the planet's highest mountain....


text:
# How can I change the path to the repository folder?

How can I change the path to the repository folder?

Using cache found in C:\Users\Андрей/.cache\torch\hub\ultralytics_yolov5_master

I am using yolov5:

If you want to change the `torch.hub` directory, you could use `torch.hub.set_dir(DIR)`.


text:
QuickSort C# Implementation

It has been a while I haven't implemented a QuickSort and I wanted to write it down like I remembered. Here it is:

    int MyPartition(List<int> list, int left, int right)
{
int pivot = list[left];

while(true)
{
while(list[left] < pivot)
left++;

while(list[right] > pivot)
right--;

if(list[right] == pivot && list[left] == pivot)
left++;

if(left < right)
{
int temp = list[left];
list[left] = list[right];
list[right] = temp;
}
else
{
return right;
}
}
}

void MyQuickSort(List<int> list, int left, int right)
{
if(list == null || list.Count <= 1)
return;

if(left < right)
{
int pivotIdx = MyPartition(list, left, right);

if(pivotIdx > 1)
MyQuickSort(list, left, pivotIdx - 1);

if(pivotIdx + 1 < right)
MyQuickSort(list, pivotIdx + 1, right);
}
}

Sample usage:

var list = RandomList(1000);
MyQuickSort(list, 0, list.Count - 1);

-
why do you check if pivotIDX > 1 –  Gilad Dec 8 '14 at 23:07

With QuickSort, the complexity always comes down to two things:

• how you deal with equal numbers (duplicates)
• which index you use to return from the partition (left or right)

You need to decide up-front whether the pivot value is going to be in the left partition, or the right partition. If the pivot is going to be in the left, then you need to return left index, and the left partition is values <= the pivot.

In my 'education', all the examples I looked at, and all the implementations I have done since then, have always returned the left index.... and they have always included the pivot in the left side.

There are a number of things that stand out to me in your code:

1. you do not start with the left at left + 1 (you know that list[left] == pivot for the first check...)
2. It is common practice for the 'right' index to start at the length (i.e. to be 1 after the last member).
3. you have odd handling for the duplicate value case
4. you are returning right instead of left
5. you are not swapping the pivot to where it belongs.... The point of the partitioning is that you are supposed to end up with the pivot value where it belongs.
6. you are not checking for left >= right on the increment side of the partition loops

The odd handling of duplicates is because the 'left' loop should be a <= loop, not a < loop:

        while(list[left] <= pivot)
left++;

and you should get rid of the condition:

        if(list[right] == pivot && list[left] == pivot)
left++;

You should return left.

Then, in the Recursive call, you have the constant value 1 which you use to test the left-condition.... This is a big bug, because the pivot will only return 0 for the left-most partition. The 1 constant should be left ....

I ended up ideoning your code to play with it. IU shuffled around a lot of the logic.

Have a look...

This is the code that does the sort closer to the way that I expect:

using System;
using System.Collections.Generic;

public class Test
{
static List<int> RandomList(int size) {
List<int> ret = new List<int>(size);
Random rand = new Random(1);
for (int i = 0; i < size; i++) {
}
return ret;
}

static int MyPartition(List<int> list, int left, int right)
{
int start = left;
int pivot = list[start];
left++;
right--;

while(true)
{
while(left <= right && list[left] <= pivot)
left++;

while(left <= right && list[right] > pivot)
right--;

if(left > right)
{
list[start] = list[left - 1];
list[left - 1] = pivot;

return left;
}

int temp = list[left];
list[left] = list[right];
list[right] = temp;

}
}

static void MyQuickSort(List<int> list, int left, int right)
{
if(list == null || list.Count <= 1)
return;

if(left < right)
{
int pivotIdx = MyPartition(list, left, right);
//Console.WriteLine("MQS " + left + " " + right);
//DumpList(list);
MyQuickSort(list, left, pivotIdx - 1);
MyQuickSort(list, pivotIdx, right);
}
}

static void DumpList(List<int> list) {
list.ForEach(delegate(int val)
{
Console.Write(val);
Console.Write(", ");
});
Console.WriteLine();
}

public static void Main()
{
List<int> list = RandomList(100);
DumpList(list);
MyQuickSort(list, 0, list.Count);
DumpList(list);
}
}

-


text:
electromagnetic induction. Does charge matter?

Just wondering. I know a negative electric charge moving though a coil will induce a voltage in the coil. My question is, would a positive charge, say an ion beam, moving though a coil also induce a voltage?

Here, it states that for a tightly wound coil of wire, composed of $N$ identical turns, each with the same $\Phi_B$, Faraday's law of induction states that:
$$\epsilon = - N \frac{d \Phi_B}{dt}$$
So the Electro Motive Force (voltage) $\epsilon$ induced will be proportional to the number of turns $N$. And be proportional to the rate of change of magnetic flux with time. Due to the negative sign the EMF will take place in the opposite direction to the change in the flux.


text:
# Another Line Integral Problem

1. Apr 29, 2005

### PhysicsMajor

Greetings All Again,

I wanted to thank you for the reply on my other problem, it was indeed very helpful and this is a very strange problem. So here goes :yuck: :

Compute the work done by the force field F(x,y,z) = <4y,2xz,3y> acting on an object as it moves along the helix defined parametrically by
x=2 cos t, y=2 sin t, z=3t, from the point (2,0,0) to the point (-2,0,3(pi)).

Thanks

2. Apr 29, 2005

### Data

this is just

$$\int_C 4y \ dx + 2xy \ dy + 3y \ dz$$

where C is the curve you defined above. You know the parameterization. Just solve for the values of $t$ that give you the endpoints (to get the appropriate bounds), and sub in the parameterized x, y, z, dx, dy, dz.

3. Apr 30, 2005

### PhysicsMajor

With this problem, assuming i worked it correctly, i got the values for the parameticize. I am confused about what values to plug into x,y, and z. either what i just solved or the other values for x,y, and z. x = 2cost, y = 2sint, and z = 3t.

r(t)=(1-t)<2,0,0> + t<-2,0,3(pi)>

x(t)=-4t+2
y(t)=0
z(t)=3(pi)t

I hope this makes sense.

4. Apr 30, 2005

### Data

i have absolutely no idea what you're doing there. The parameterization is given in the question, x(t) = 2cos t, y(t) = 2sin t, z(t) = 3t. All you need to do is find the bounds on t (using the endpoints given) and take the integral.

5. Apr 30, 2005

### trancefishy

physicsmajor, what you've done on this probllem, with yoru parametricization, is turned your path from a helix into a straight line. you should be computing along the helix.

now, if your vector field is conservative, you can do that, the straight line approach, which makes things much easier, but, i'd imagine it's not conservative or you wouldn't be told to integrate along the helix.

6. Apr 30, 2005

### PhysicsMajor

thanks trance, i actually figured that out a few hours after i made that post. i guess i am having trouble finding the limits to integrate from. I believe they are from 0 < t < 3(pi), but i am not sure.

7. Apr 30, 2005

### Data

0<t is correct, but at the second endpoint you need $z=3t=3\pi$, and does $t=3\pi$ solve that?

8. Apr 30, 2005

### PhysicsMajor

no it does not, so its from 0<t<(pi)

9. Apr 30, 2005

### Data

sounds good to me.

10. Apr 30, 2005

### PhysicsMajor

you the man data!!!!!!!!


text:
# Heat loss in Optical Fiber

I am conducting a thermal analysis of optical fibers. ( Software used AutoCAD Fusion 360)

The Inputs conditions are :

Let's assume an input power of 1250W, with an efficiency of 98%. 2% loss which becomes heat. (25W)

The internal heat of 25W at the inner core ( power loss ) gives 407.7 degrees Celcius.

Convection Coefficient of $$10W/m^2K$$ (Convection of still air)

The material of the rod I assume is glass with an emissivity of 0.9 ( Radiation ).

The temperature of the optical fiber reaches 407.7 degrees Celcius, which is inconsistent with real life. The temperature should be approximately 35 degrees Celcius? Why is this so, am I missing out on another method of heat loss? Any help will be greatly appreciated.


text:
# To prove differentiability of a function at a point

I am studying Denlinger's Elements of Real Analysis, there a problem is given as-

Suppose $$f:\mathbb{R}\to\mathbb{R}$$ is differentiable at $$x_o$$, and define $$g:\mathbb{R}\to\mathbb{R}$$ by $$g(x)=x^3f(x^2)$$. Prove that g is differentiable at $$x_o$$ and find $$g'(x_o)$$.

I have attached the pic of my work.

I have a doubt that we are just given that f is differentiable at $$x_o$$. Please tell is my way incorrect or I am missimg something.
You are right. The problem statement is wrong. For example, $$f(x)=\begin{cases}(x+1)^2&x\in\Bbb Q\\0&0>x\notin \Bbb Q\\\frac1{x^2}&0 is differentiable at $$x_0=-1$$, but $$g(x)=x^3f(x^2)$$ is nowhere differentiable (in fact, nowhere continuous).
The problem statement should ask for differentiability at $$\sqrt{x_0}$$ (hoping that $$x_0\ge0$$) or specify $$x_0=0$$ or $$=1$$.


text:
# Revision history [back]

If you type

sage: f??

You will see that the method .__call__ (responsible for the behaviour of evaluating f) is the one-liner

return vector([e(*args, **kwargs) for e in self])

This has been designed so that symbolic functions can safely be used in symbolic expressions in a meaningful way.

There is no way around it. If you really only need to return a list, then an ordinary python function (like (2) or (3)) is probably enough. Or you can convert the output of f to a list like so:

sage: list(f(x))

If you type

sage: f??

You will see that the method .__call__ (responsible for the behaviour of evaluating f) is the one-liner

return vector([e(*args, **kwargs) for e in self])

This has been designed so that symbolic functions can safely be used in symbolic expressions in a meaningful way.way. For example, you can combine f with another symbolic function using the vector product operator *:

sage: f(x) = [x,x]
sage: f
x |--> (x, x)
sage: f * f
x |--> 2*x^2

This would not work with ordinary python lists.

There is no way around it. If you really only need to return a list, then an ordinary python function (like (2) or (3)) is probably enough. Or you can convert the output of f to a list like so:

sage: list(f(x))


text:
1. A search problem consists of: A state space, A successor function (with actions, costs), A start state and a goal test. A solution is a sequence of actions (a plan) which transforms the start state to a goal state.

2. Uniform-cost orders by path cost, or backward cost g(n) Greedy orders by goal proximity, or forward cost h(n) A* Search orders by the sum: f(n) = g(n) + h(n)

3. Manhattan distance, Euclidean distance

4. A heuristic h is admissible if $0 \leqslant h(n) \leqslant h^*(n)$

5. Graph Search Idea: never expand a state twice Tree search + set of expanded states (“closed set”). Expand the search tree node-by-node, but before expanding a node, check to make sure its state has never expanded before. If not new, skip it, if new add to closed set. Important: store the closed set as a set, not a list

6. Admissibility: heuristic cost ≤ actual cost to goal, h(A) ≤ actual cost from A to G. Consistency: heuristic “arc” cost ≤ actual cost for each, h(A) – h© ≤ cost(A to C).

8. minimax efficiency: time $O(b^m)$ space $O(bm)$ (b: Branch factor, m: depth)

9. Alpha-Beta pruning: α: MAX’s best option on path to root, β: MIN’s best option on path to root max节点：if $v \geqslant \beta$ return $v$ , $\alpha = max(\alpha, v)$ ；min节点：if $v \leqslant \alpha$ return $v$ , $\beta = min(\beta, v)$ . With perfect ordering: Time complexity drops to $O(b^{m/2})$

10. An MDP is defined by: A set of states s $\in$ S, A set of actions a $\in$ A, A transition function P(s’|s,a) or T(s, a, s’), A reward function R(s, a, s’), A start state $s_0$, Maybe a terminal state.

11. The Bellman Equations: $V^* = max_{a} Q^*(s, a)$ $Q^*(s, a) = \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma V^*(s')]$ $V^*(s) = max_a \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma V^*(s')]$

12. Value Iteration $V_0(s) = 0$ , $V_{k+1}(s) \gets max_a \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma V_k (s')]$ complexity of each iteration: $O(S^2 A)$

13. Policy Evaluation relation: $V^\pi(s) = \sum_{s'} T(s, \pi(s), s') [R(s, \pi(s), s') + \gamma V^\pi(s')]$ $V_0^\pi(s) = 0$ , $V_{k+1}^\pi(s) \gets \sum_{s'} T(s, \pi(s), s') [R(s, \pi(s), s') + \gamma V_k^\pi(s')]$ efficiency: $O(S^2)$ policy extraction: $\pi^*(s) = argmax_a \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma V^*(s')]$ $\pi^* (s) = argmax_a Q^*(s, a)$

14. Policy Iteration Evaluation: $V_{k+1}^{\pi_i}(s) \gets \sum_{s'} T(s, \pi_i (s), s') [R(s, \pi_i (s), s') + \gamma V_k^{\pi_i}(s')]$ Improvement: $\pi_{i+1}(s) = argmax_a \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma V^{\pi_i}(s')]$

15. Temporal difference learning Sample of V(s): $sample = R(s, \pi(s), s') + \gamma V^\pi(s')$ Update to V(s): $V^\pi(s) \gets (1-\alpha)V^\pi(s) + (\alpha)sample$ Same Update: $V^\pi(s) \gets V^\pi(s) + \alpha(sample - V^\pi(s))$

16. Q-Learning $Q_{k+1}(s, a) \gets \sum_{s'} T(s, a, s') [R(s, a, s') + \gamma max_{a'}Q_k(s', a')]$ $sample = R(s, a, s') + \gamma max_{a’}Q(s', a')$ $Q(s, a) \gets (1 - \alpha)Q(s, a) + (\alpha) [sample]$

17. Approximate Q-Learning $Q(s, a) = w_1f_1(s, a) + w_2f_2(s, a) + ... + w_nf_n(s, a)$ $difference = [R(s, a, s') + \gamma max_{a'}Q(s', a')] −Q(s, a)$ $w_i \gets w_i + \alpha \cdot difference \cdot f_i(s)$

18. CSP Variables, Domains, Constraints Unary / Binary / N-ary

19. Backtracking Search (DFS with two improvements) Idea 1: One variable at a time Idea 2: Check constraints as you go

20. Arc consistency An arc X $\to$ Y is consistent iff for every x in the tail there is some y in the head which could be assigned without violating a constraint. Forward Checking: Cross off values that violate a constraint when added to the existing assignment. (Enforcing consistency of arcs pointing to each new assignment) Variable Ordering: Minimum remaining values (MRV): Choose the variable with the fewest legal values left in its domain. Value Ordering: Least Constraining Value: Given a choice of variable, choose the least constraining value.

21. Tree-Structured CSPs, Cutset Conditioning

22. Propositional Logic: Knowledge base = set of sentences in a formal language Syntax: What sentences are allowed? Semantics: What are the possible worlds? Which sentences are true in which worlds? (i.e., definition of truth) Entailment: $\alpha \vDash \beta$ iff in every world where $\alpha$ is true, $\beta$ is also true Inference: Method 1: model-checking: For every possible world, if α is true make sure that is β true too. Method 2: theorem-proving: Search for a sequence of proof steps (applications of inference rules) leading from α to β. $A \to B \Leftrightarrow \neg A \vee B$ , $A \leftrightarrow B \Leftrightarrow (A \land B) \lor (\neg A \land \neg B)$ , $A \leftrightarrow B \Leftrightarrow (A \lor \neg B) \land (\neg A \lor B)$ , $A \leftrightarrow B \Leftrightarrow (A \to B) \land (B \to A)$ 合取(Conjunction) 析取(Disjunction)

23. DPLL algorithm Early termination: stop if all clauses are satisfied, or any clause is falsified. Pure literals: if all occurrences of a symbol in as-yet-unsatisfied clauses have the same sign, then give the symbol that value. Unit clauses: if a clause is left with a single literal, set symbol to satisfy clause.

24. Successor-state Axiom $X_t \Leftrightarrow [X_{t-1} \land \neg(Some Action_{t-1} Made It False)] \lor [\neg X_{t-1} \land (Some Action_{t-1} Made It True)]$

25. Baye’s Chain Rule $P(x_1, x_2, x_3) = P(x_1)P(x_2|x_1)P(x_3|x_1, x_2)$ $P(x_1, x_2, ...x_n) = \prod_i P(x_i | x_1...x_{i-1})$

26. Conditional Independence X is conditionally independent of Y given Z if and only if: $\forall x, y, x: P(x, y|z) = P(x|z)P(y|z)$ or, equivalently, if and only if $\forall x, y, z: P(x|z, y) = P(x|z)$

27. Bayes net global semantics $P(X_1,..,X_n) = \prod_i P(X_i | Parents(X_i))$

1022 Words

2019-03-21 09:30 +0800

本文阅读量
本站访客量


text:
## FANDOM

4,402 Pages

Encumbrance is a term used to describe the various effects of worn and carried weight on a player character or mob.

## Weight LimitsEdit

### Carried Weight LimitEdit

Both player characters and mobs have a limit on the total weight of items in their inventory.

Player Characters:

$Weight Limit (lbs) = (3.5\times Str) + Con$

Mobs:

$Weight Limit (lbs)= 74.0$

### Worn Weight LimitEdit

Both player characters and mobs have a limit on the total weight of items that can be equipped or worn.

Player Characters:

$Weight Limit (lbs) = (5\times Str) + (2.5\times Con)$

Mobs:

$Weight Limit (lbs) = 117.5$

### Total Weight LimitEdit

Total Weight Limit (lbs) = Max Weight Carried + Max Weight Worn

or

$Total Weight Limit (lbs) = (8.5\times Str) + (3.5\times Con)$

### Weight Messages TableEdit

You are carrying 0.0 lbs and wearing 0.0 lbs, peanuts.

The following messages are based on fractions of the Total Weight Limit defined above:

Percent Message
0 to <20% peanuts
20% to <30% very light
30% to <40% light
40% to <50% fairly light
50% to <60% somewhat heavy
60% to <70% heavy
70% to <80% moderately heavy
80% to <90% really heavy
90% to <100% incredibly heavy
100% maxed out

## EffectsEdit

OB, DB, and PB are all reduced by added weight, being multiplied by an encumbrance factor, before rounding, given as follows.

### Offensive bonusEdit

$OB Mult = 1 - \frac{(5\times Weight)}{(25\times MaxWeight)}$

### Dodge bonusEdit

$DB Mult = 1 - \frac{(5\times Weight)}{(8\times MaxWeight)}$

### Parry bonusEdit

$PB Mult = 1 - \frac{(5\times Weight)}{(16\times MaxWeight)}$

### Movement pointsEdit

#### RegenEdit

Regen rates for Movement points are also reduced by the effects of encumbrance, as a function of the Total Weight Allowance mentioned above.

Regen Rate (MVs) = $Base Regen - \left \lfloor \frac{10\times Weight}{(8.5\times Str) + (3.5\times Con)} \right \rfloor$
Note that $\lfloor x\rfloor$ means the greatest integer less than or equal to $x$.

Where BaseRegen denotes the MVs regen rate for a given position when wearing and carrying no weight.

#### Room MVs CostEdit

In a similar manner, when worn/carried weight equals or exceeds 80% of the Total Weight Allowance, a 1-MVs penalty is added to the MVs cost to enter any room. So, from 80% to <90%, a 2-MVs room will instead cost 3 MVs to enter. For each additional 10% weight increase, an additional 1-MV penalty is incurred.


text:
Revision history [back]

Collision Avoidance using OpenCV on iPad

I'm working on a project where I need to implement collision avoidance using OpenCV. This is to be done on iOS (iOS 5 and above will do).

Project Objective: The idea is to mount an iPad on the car's dashboard and launch the application. The application should grab frames from the camera and process these to detect if the car is going to collide with any obstacle.

I'm a novice to any sort of image processing, hence I'm getting stuck at conceptual levels in this project.

What I've done so far:

• Had a look at OpenCV and read about it on the net. Collision avoidance is implemented using Lukas-Kanade Pyramid method. Is this right?
• Using this project as a starting point: http://aptogo.co.uk/2011/09/opencv-framework-for-ios/ It successfully runs on my iPad and capture functionality works as well, which means camera capture is well-integrated. I changed the processFrame implementation to try Optical Flow instead of Canny edge detection. Here is the function (incomplete yet).

    -(void)processFrame {
int currSliderVal = self.lowSlider.value;
if(_prevSliderVal == currSliderVal) return;
cv::Mat grayFramePrev, grayFrameLast, prevCorners, lastCorners, status, err;

// Convert captured frame to grayscale for _prevFrame
cv::cvtColor(_prevFrame, grayFramePrev, cv::COLOR_RGB2GRAY);
cv::goodFeaturesToTrack(grayFramePrev, prevCorners, 500, 0.01, 10);
// Convert captured frame to grayscale for _lastFrame
cv::cvtColor(_lastFrame, grayFrameLast, cv::COLOR_RGB2GRAY);
cv::goodFeaturesToTrack(grayFrameLast, lastCorners, 500, 0.01, 10);

cv::calcOpticalFlowPyrLK(_prevFrame, _lastFrame, prevCorners, lastCorners, status, err);
self.imageView.image = [UIImage imageWithCVMat:lastCorners];
_prevSliderVal = self.lowSlider.value;
}

• Read about Optical Flow and how it is used (conceptually) to detect impending collision. Summary: If an object is growing in size, but moving towards any edge of the frame, then it is not a collision path. If an object is growing in size, but not moving towards any edge, then it is on collision path. Is this right?
• This project (http://se.cs.ait.ac.th/cvwiki/opencv:tutorial:optical_flow) appears to be doing exactly what I want to achieve. But I did not understand how it is doing so by reading the code. I cannot run it as I don't have a linux box. I read the explanation on this web-page, it seems to arrive at an homograph matrix. How is this result used in collision avoidance?

In addition to the above four points mentioned, I have read a lot more about this topic but still can't put all the pieces together.

Here are my questions (please remember I'm a novice at this)

1. HOW is optical flow used to detect impending collision? By this I mean, supposing I'm able to get correct result from the function cv::calcOpticalFlowPyrLK(), how do I take it forward from there to detect impending collision with any object on the frame? Is it possible to gauge distance from the object we are most likely to collide with?

2. Is there a sample working project which implements this or any similar functionality that I can have a look at. I had a look at the project on eosgarden.com, but no functionality seemed to be implemented in it.

3. In the above sample code, I'm converting lastCorners to UIImage and I'm displaying that image on screen. This shows me an image which only has colored horizontal lines on the screen, nothing similar to my original test image. Is this the correct output for that function?

4. I'm having a little difficulty understanding the datatypes used in this project. InputArray, OutputArray etc are the types accepted by OpenCV APIs. Yet in processFrame function, cv::Mat was being passed to Canny edge detection method. Do I pass cv::Mat to calcOpticalFlowPyrLK() for prevImage and nextImage?

Thanks in advance :)


text:
# [OS X TeX] Backanswers in Memoir

Mon Apr 6 04:28:28 CEST 2009

OK.

Tried the following, but no go. Getting this error:

! Argument of \verbatim at start has an extra }.
<inserted text>
\par

?

\documentclass{memoir}

\chapterstyle{bianchi}

\newoutputstream{backansout}

\newenvironment{Exercises}
{\openoutputfile{\jobname.backans}{backansout}}
{\closeoutputstream{backansout}}

\newcounter{exercise}[section]
\renewcommand{\theexercise}{\arabic{exercise}}

\newenvironment{exercise}%
{\refstepcounter{exercise}
\par\noindent\textbf{\theexercise}.}
{\par}

\input{\jobname.backans}}

{\ifodd\theexercise{%
\begin{writeverbatim}{backansout}}\else{\begin{comment}}\fi}
{\ifodd\theexercise{%
\end{writeverbatim}}\else{\end{comment}}\fi}

\begin{document}

\chapter{The Whole Numbers}

\section{Introduction to the Whole Numbers}

Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.
Now is the time for all good men to come to the aid of their country.

\subsection{Exercises}

\begin{Exercises}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and $-15$?
$-17$

\end{exercise}

\begin{exercise}
What is the sum of 2 and 15?

$17$

\end{exercise}

\begin{exercise}
What is the sum of $-2$ and 15?

$13$

\end{exercise}

\end{Exercises}

\input{\jobname.backans}

\end{document}

On Apr 5, 2009, at 5:05 PM, Ross Moore wrote:

> Hi David,
>
> On 06/04/2009, at 9:24 AM, David Arnold wrote:
>
>> All,
>>
>> I'm trying to print only odd backanswers using the memoir class. My
>> full code sample appears below. The crux of the matter is this new
>> environment, where I am trying to output the contents of the
>> environment to \jobname.backans only if the exercise number is odd:
>>
>> \newsavebox{\backans}
>>
>> 	{\begin{lrbox}{\backans}}
>> 	{\end{lrbox}\ifodd\theexercise{%
>
> You cannot do it this way.
> You need to be writing out into the file,
> the text that lies between
>  ...
>
> By trying to write out the *result* of having typeset
> this info into a box, you will get lots of stuff that
> you cannot control --- as you are discovering.
>
>>
>> I get this error:
>>
>> ! Undefined control sequence.
>> l.2 \unhbox \voidb
>>                  @x \copy \backans \relax
>> ?
>>
>> And the contents of \jobname.backans are:
>>
>> \par \noindent \textbf {1.}
>> \unhbox \voidb at x \copy \backans \relax
>> \par \noindent \textbf {3.}
>> \unhbox \voidb at x \copy \backans \relax
>> \par \noindent \textbf {5.}
>> \unhbox \voidb at x \copy \backans \relax
>> \par \noindent \textbf {7.}
>> \unhbox \voidb at x \copy \backans \relax
>> \par \noindent \textbf {9.}
>> \unhbox \voidb at x \copy \backans \relax
>
>>
>> Please be kind. I'm OK using LaTeX to write documents, but I'm
>> pretty lousy at the coding end and trying to write macros.
>>
>> Any help appreciated.
>
>
> I'd advise you to look at:  \usepackage{comment} .
> This lets you define environment that can be switched
> between inclusion or exclusion.
>
>>
>
>>
>> As a second request, if anyone could help me get these exercises
>> into two columns using all of the page (no odd-even large margins),
>> that would also be appreciated.
>>
>> Thanks.
>>
>> David Arnold
>> College of the Redwoods
>> http://msemac.redwoods.edu/~darnold/index.php
>
>
> Hope this helps,
>
> 	Ross Moore
>
> ------------------------------------------------------------------------
> Ross Moore                                       ross at maths.mq.edu.au
> Mathematics Department                           office: E7A-419
> Macquarie University                             tel: +61 (0)2 9850
> 8955
> Sydney, Australia  2109                          fax: +61 (0)2 9850
> 8114
> ------------------------------------------------------------------------
>
>
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>