text:
In this tutorial, we're going to look at how you can stop and start your code to see what it is doing as well as view some variables and values. This is a process called debugging, it can be a complex process but we'll stick with the basics of breakpoints, and following program flow while keeping an eye on variables.

# Getting the stuff you need

As with the last tutorial, we'll use the template again. Extract the package to a fresh directory (say, c:\my_projects\debug) and load up the .sln file. Remove the 'hello world' stuff in the Tick function.

# Debug Mode

First of all, we must make sure that when you are running your program you are in debug mode. When you first load up your project, this is already the case, but let's be sure:

Look at the options you have on the drop down window on your toolbar and make sure Debug Mode is selected.

# Sprites Again

Yes.. more sprites, but its best that we have something on screen that we know works.

So as before lets put a sprite on screen. Add a Sprite variable above the Tick function like this:

Sprite theSprite( new Surface("assets/ctankbase.tga"), 16 );

void Game::Tick( float a_DT )
{
...

Now make once again your Tick function like this:

void Game::Tick( float a_DT )
{
m_Screen->Clear( 0 );
theSprite.Draw( 0, 0, m_Screen );
}

Run the program and make sure you can see your tank. Again lets make it move. Add a tankY variable.

int tankY=0;

void Game::Tick( float a_DT )
{
...

and change the Tick function to make it look like this:

void Game::Tick( float a_DT )
{
m_Screen->Clear( 0 );
theSprite.Draw( 0, tankY, m_Screen );
tankY = tankY + 1;
if( tankY > 430 )
{
tankY = 1;
}
}

You should be an old pro at this by now. Run your program and you will see your tank moving top to bottom and resetting; quite fast, because we are using ints. Now, lets add something. Carefully add the following after this

	if( tankY > 430 )
{
tankY = 1;
}

if (tankY = 200)
m_Screen->Print( "My Tank is at 200", 2, 2, 0xffffff );

Now hopefully you will have already spotted a very simple typing error. Depending on your compiler settings it may even have warned you of the error. Please take a moment to look at the code before going to the next page. Can you see the problem?

We've used = instead of == in our condition test.

Remember that = is an assignment, it causes tankY to become 200 rather than test if tankY is equal to 200. This is a very common type of typo error and you will soon learn to spot and avoid these kinds of typing errors which can legally compile.

Now you already know the fault, but lets pretend that you do not, and lets try using our debugger to locate the problem. Run the code. You will see the tank sticks in the middle of the screen and the printout stays on screen all the time. Now clearly this is not what we want it to do: our plan is to have the tank move and then when it gets to screen Y 200, it should print up some text.

Now is the time to use our debugger.

We know our program worked fine before we added those 2 extra lines...so lets stop the program before it runs those two lines.

To the left of our source window we have a greyed out vertical bar. Let's put the cursor in that bar next to a line that contains some code. Then, press F9. This gets us a fat red dot, which indicates the breakpoint. Press F9 again to remove it later on.

Now run the program again.

Don't panic....nothing bad has happened. At the bottom of your windows bar you can still see your Template program, as well as an open console window. But your Visual studio has become the windows focus. Look at your IDE window again:

Notice though that red dot now has a yellow arrow in it. This tells us that our program started, went through its set up process, and then when it arrived at the breakpount, it halted. Your program is now paused: now we have a chance to look at things.

Hover your cursor over the word tankY. You see that pop up line that appears?

This is the debugger giving you some information on the values related to tankY. It gives you its type, its address and more important is current value. But hovering over a variable name is not always a good way to view a variable we need something else. At the bottom left of your IDE you will see some tabs:

The most important of these is the Autos window, this keeps track of any global variables that are currently in scope as well as local variables.  Ignore the this for now, we'll explain this when we talk about classes.

This window allows you to keep an eye on variables as they are changed by each line of code. Good, we have stopped our program and we're keeping a eye on our tankY variable, which looks ok, so..Lets look at our available debugging tools, the three most important are these icons:

In order, these are Continue, Break (greyed out when in debug mode) , Stop, Restart, Show Next Statement and, the ones we are most interested in: Step Into, Step Over and Step Out. We'll start with the middle one, Step Over.

Click on that icon. We can see immediately something interesting happens.

Our yellow arrow has moved to the next line, ready to execute that and also did you notice what happened to tankY in our Autos window...it changed colour to red to indicate it had been changed by the instruction that just occurred.

Step Over has allowed us to execute this instruction:  if (tankY = 200)

Immediately we can see that tankY was changed to 200. Not what we wanted.. An "if test" should not be setting variables (note...sometimes this can be on purpose, but only very very strange people do this). By isolating that instruction we have been able to view the direct effect it has had on tankY. We should now be able to spot our bug, and normally we would stop the debugger and fix this mistake and re-run to test.

But for now lets examine what we can do with our debug commands. Our arrow is pointing at this line

    m_Screen->Print( "My Tank is at 200", 2, 2, 0xffffff );

meaning this is the next instruction that will be executed. Try pressing the Step Into command. Ok...Now we have gone to a totally new bit of code.

Pressing Step into will actually then take us into the Print routine. That's fine, but that routine is rather a large loop and stepping though ever single instruction will take us a long time. Here is where our Step Out instruction will helps us. We know the Print routine works...so pressing Step Out takes us magically back to where the routine was called in the game.cpp file.

When our program is running we can also stop it at any time using the Break all button, which looks like a CD pause button. If our program appears to get stuck in a tight loop, this can be a useful way to stop, but remember most modern programs run thousands and thousands of instructions each loop, and the Break All button will stop it at the exact instruction it is at when you press the button. We can continue at any time using the Continue (play) button. It is usually better to place breakpoints in code at points where you feel there is something that might need looking at.

# Changing Values

Notice on the Autos window the tankY variable was coloured red after it was changed.

If you click on that value you can actually enter a new value; try entering 20 and then continue. You will see when it breaks again, your value of 20 is still there, but if you step over or into the

    if (tankY = 200)

command it will become 200 again. This proves to you that this is the command causing the problem and now you can stop debugging and change that line to

    if (tankY == 200)

This is your first taste of debugging, but it is something you will learn to do a lot of. All coders make mistakes and visually miss them, often the compiler will find them and print warnings or errors, but as you saw here, not all. So being to execute one instruction at a time and viewing the result is important. Of course it is also possible that the code is perfectly correct and compiles and runs, but does not actually do what you think it does. These kind of bugs are much harder to locate, but seeing the impact they have as they operate helps.

# Assignment

Experiment with your debugger. Debugging skill comes from practice, add some features and functions to your tank demos and use the debugger to make sure things are happening as you expect them. Continue with the next tutorial when you feel comfortable with debugging.


text:
# what is the result type 3D vector, point and scalar arithmetic operations?

I doing programming but I am not good at math.

I want to represent point and vector in different type. Both point and vector are tuple of 3 elements, where point represent location and vector represent direction and magnitude.

Given P for point, V for vector and S for one dimensional scalar type, how they interact each other in arithmetic operations?

By arithmetic operations I mean addition, subtraction, multiplication dan division.

In my understanding, adding or subtract 2 vectors will get result as vector.

V + V = V
V - V = V

but, what about addition or subtraction vector with scalar? is that make sense?

Multiplication vector with scalar have meaning to scale the magnitude of vector, which is give vector as result.

V * S = V

Subtraction of 2 points will result a vector between two points

P - P = V

well, that is what I know, I not sure about the other operators.

So, my question is, what is the result type of arithmetic operations of vectors, points and scalars?

V + V = V      V + S = ?      V + P = ?
V - V = V      V - S = ?      V - P = ?
V * V = ?      V * S = V      V * P = ?
V / V = ?      V / S = V      V / P = ?

P + V = ?      P + S = ?      P + P = ?
P - V = ?      P - S = ?      P - P = V
P * V = ?      P * S = ?      P * P = ?
P / V = ?      P / S = ?      P / P = ?

S + V = ?      S + S = ?      S + P = ?
S - V = ?      S - S = ?      S - P = ?
S * V = V      S * S = ?      S * P = ?
S / V = V      S / S = ?      S / P = ?

P: point

V: vector

S: scalar

X: meaningless/not make sense

format: plain


text:
# List all financial Assets data conditionally

I would like to get all the Financial Data that Mathematica respecting those constraints :

The assets for which there are at least 20 years of daily price quotations. Or that have s price for each day the market has been open for at least 20 years.

or

The assets that have prices time resolution of 15 min available for at least 1 year. That is I wil have 4 Price in each hour that the market has been open for at least 1 year.

Is it possible?

-
I'm not sure what the first constraint is asking for, could you clarify? –  rcollyer Feb 22 '12 at 4:25
Do any of them have 15-minute data? PS congratulations on a very auspicious reputation level (888). –  Verbeia Feb 22 '12 at 4:27
AUSPICIOUS, not suspicious. 888 is a lucky number in some cultures. –  Verbeia Feb 22 '12 at 5:01
@verbeia ahaha, thank you very much it all make sense now wow, I had never heard/seen that word. 888 i my reputations :-) I took a screen shot, for my colleague from China ! –  500 Feb 22 '12 at 6:08
I think that MMA gets its data (for stocks) from Yahoo!Finance, and they don't provided historical tick data as far as I know. To get all stocks that have 20 years of daily quotes, I think you'd have to check the length of the returned values for all symbols. –  Tim Mayes Feb 22 '12 at 6:21

As far as I know, FinancialData does not provide a way to query the length of data available for a particular stock. The only way of knowing it is to query the data and select those that have data for 20 years. First, let's get a list of all NYSE stocks with:

stocks = FinancialData["NYSE:*", "Lookup"];

Now, I have multiple interpretations for your 20 year constraint, so I'll address them below.

### 1. The stock existed 20 years ago

This does not take into account if the stock exists at present. So, first we get the exact date 20 years ago with

date20yAgo = DatePlus[DatePlus[0], {-20, "Year"}];

and select those stocks that have data on that day. To account for that day being a Saturday/Sunday or any other public holiday, we retrieve data for the entire week:

existed20yAgo := ! FinancialData[#, {date20yAgo, DatePlus[date20yAgo, 7]}] ===
Missing["NotAvailable"] &;

Select[stocks[[ ;; 20]], existed20yAgo] // Quiet
(*
Out[1]= {"NYSE:AA", "NYSE:AAI", "NYSE:AAN", "NYSE:AAR", "NYSE:AB",
"NYSE:ABA", "NYSE:ABK", "NYSE:ABK-PZ", "NYSE:ABM", "NYSE:ABN-PE"}
*)

I've just retrieved for the first 20 so that it runs in a reasonable time when you're checking. For the full list, remove the call to Part.

### 2. The stock has existed for the past 20 years

You can simply modify the above example a little as:

existedForPast20y[stock_] :=
FreeQ[! (FinancialData[stock, {#, DatePlus[#, 7]}] ===
Missing["NotAvailable"]) & /@ {date20yAgo, DatePlus[-7]}, False]

You can do a quick check of the above with:

existedForPast20y /@ {"AAPL", "GOOG"}
(* Out[2]= {True, False} *)

You can use Select[...] as before and use this function to test.

### 3: The stock has 20 years of historical data (any date range)

This will unfortunately require pulling all the data for each stock, and will definitely be slower.

has20yData := DateDifference[Sequence @@ (First /@
Through[{First, Last}[FinancialData[#, All]]]), "Year"][[1]] >= 20 &

Again, replace the test function in Select with has20yData. I'll leave the rest of the constraints for you to work on.

-


text:
## Linear Algebra: A Modern Introduction

$$u+v = \begin{bmatrix}0\\0\\1\end{bmatrix}$$
Add each component of $u$ and $v$ separately. The first two components are $1+1=0$, and the last is $0+1=1$.


text:
# Duality between extremal points and extremal maps

Suppose I have a convex set $C\subset\mathbb{R}^n$ such that $0\in C$ ad every Cauchy sequence in $C$ converges in $C$, but $C$ need not be bounded. (Actually I want unbounded $C$). Consider the set $$\mathfrak{L}=\{T:\mathbb{R}^n\rightarrow \mathbb{R}^n, \text{ T is linear}, T(C)\subseteq C\}$$ Is there any relation between extremal points (and rays, faces, well any such thing) of $C$ and extremal points of $\mathfrak{L}$?

I do not work in convex geometry, and so do not know whether the statement is making sense. Please give suggestions and feel free to correct (and edit), if I am wrong. Advanced thanks for any help.

-
Your edit has made the question unclear to me. In the original question, you ask about a relationship between extremal points of $C$ and of $\mathcal L$. In the edit, you ask about a relationship between the image of the extremal points of $C$ under $T$ and the extremal points of the image of $C$ under $T$. Those seem to be two very different questions. Or does "what I want is" merely refer to a part of the assumptions? If so, which part? –  joriki Sep 13 '12 at 9:00
Thanks @joriki. It was nonsense stupid, and hence removed. What I wanted was perhaps the statement "Let $E(C)$ be the set of extremal points of $C$. Is it possible that $T$ is an extremal map if and only if $T(E(C))\subseteq E(T(C))$ (or something similar)". However, I am having a feeling that, boundary of $C$ will be mapped to the boundary of $T(C)$. Thus the conditions written will be satisfied for any $T\mathfrak{L}$. Am I right here, or again doing some mistake? –  RSG Sep 13 '12 at 15:06


text:
Topic Archive: Harrington's Principle

Set theory seminarMonday, March 30, 20155:00 pmGC 3309

Harrington’s Principle and remarkable cardinals

University of Münster

It is open whether $\Pi^1_1$ determinacy implies the existence of $0^{\#}$ in 3rd order arithmetic, call it $Z_3$. We compute the large cardinal strength of $Z_3$ plus “there is a real $x$ such that every $x$-admissible is an $L$-cardinal.” This is joint work with Yong Cheng.


text:
slavfox.space:~\$
back to posts

# Revisiting Revolvers, part 1 - The cylinder

Tue Aug 13, 2019 · 1024 words · 6 min

Yesterday we made an algorithm that could build procedural revolver cylinders. Unfortunately, it has some quirks that I’m not too happy about - particularly, once there are enough chambers that the distance between them is smaller than the distance between a chamber and the outer wall, the cylinder starts getting unreasonably thick. We’ll fix that today, and parametrize the algorithm further, so that the generation can be tweaked even more.

I’ll split this into four parts - in the first part we’ll talk about generating the cylinder itself, in the second part we’ll be tweaking our generator to support polygonal cylinders, akin to the Chiappa Rhino, we’ll add grooves in the third post, and then make the whole thing 3D in the final chapter.

Let’s start! This is what we made last time:

The result of this part can be found at the very bottom of this post.

# The groundwork

As usual, let’s start by looking at what we want.

This time, we’ll start by defining the outer wall thickness as a third of a chamber’s radius, instead of arbitrarily making the chamber start halfway out. This will help deal with disproportionately small chambers way better.

Let’s look at our definitions real quick:

• $$A$$ is the center of the cylinder
• $$R$$ is the radius of the cylinder
• $$R_c$$ is the radius of a single chamber (half of the caliber)
• $$n$$ is the number of chambers (in this example, 6)
• $$\lvert CK \rvert = \lvert CO \rvert = \frac{4}{3}R_c$$

However, to let us parametrize the creation even more, we’ll change the arguments ($$n$$, $$R_c$$, and $$R$$ growth) to our algorithm. Instead of $$R$$ growth, which caused $$R$$ to grow past the minimum value, we’ll have $$R_i$$ and $$R_o$$, which, respectively, will be added to the inner radius ($$AK$$), and the outer radius ($$CO$$). In total, we now have:

$$R = \lvert AK \rvert + R_i + 2(\frac{4}{3}R_c) + R_o$$

We’ll need to find $$\lvert AC \rvert$$, and we know it’s equal to $$\lvert AK \rvert + \frac{4}{3}R_c$$.

Although for six chambers and $$R_i = R_o = 0$$ the triangle $$\triangle AC’C$$ is equilateral, this is not always the case. It is, however, an isosceles triangle, which we can use to our advantage, along with our knowledge that $$\alpha = \frac{2 \pi}{n}$$.

Note that we can handwave away $$R_i$$ and $$R_o$$. Since our algorithm only needs to know how big the cylinder is, and how far away the chambers are, we can do all our calculations assuming $$R_i = R_o = 0$$, and then just add the values afterwards. This lets us have $$\lvert CC’ \rvert = \frac{7}{3} R_c$$. Armed with that knowledge, let’s finally find $$\lvert AK \rvert$$!

\begin{align} \frac{\lvert AC \rvert}{\sin (\frac{\pi - \alpha}{2})} & = \frac{\lvert CC' \rvert }{\sin \alpha} \\ \frac{\lvert AK \rvert + \frac{4}{3}R_c}{\sin (\frac{\pi - \alpha}{2})} & = \frac{ \frac{7}{3} R_c }{\sin \alpha} \\ \frac{\lvert AK \rvert + \frac{4}{3}R_c}{\cos (\frac{\alpha}{2})} & = \frac{ 7 R_c }{3 \sin \alpha} \\ \frac {3 \sin \alpha (\lvert AK \rvert + \frac{4}{3}R_c)} {\cos (\frac{\alpha}{2})} & = 7 R_c \\ \frac {3 \sin \alpha}{\cos (\frac{\alpha}{2})}\lvert AK \rvert + \frac{\frac{4}{3}R_c}{\cos (\frac{\alpha}{2})} & = 7 R_c \\ \frac {3 \sin \alpha}{\cos (\frac{\alpha}{2})}\lvert AK \rvert & = 7 R_c - \frac{\frac{4}{3}R_c}{\cos (\frac{\alpha}{2})} \\ \lvert AK \rvert & = \frac{7 R_c - \frac{\frac{4}{3}R_c}{\cos (\frac{\alpha}{2})}}{\frac {3 \sin \alpha}{\cos (\frac{\alpha}{2})}} \\ & = \cos (\frac{\alpha}{2}) 7 R_c - \frac{\frac{4}{3}R_c}{ 3 \sin \alpha} \\ & = \frac{(21 \cos (\frac{\alpha}{2}) - 4) R_c}{ 9 \sin \alpha} \\ \end{align}

That gives us:

\begin{align} \lvert AC \rvert & = \lvert AK \lvert \color{red}{+ R_i} + \frac{4}{3}R_c \\ & = \frac{(21 \cos (\frac{\alpha}{2}) - 4) R_c}{ 9 \sin \alpha} \color{red}{+ R_i} + \frac{4}{3}R_c \end{align}

And:

\begin{align} \lvert AO \rvert & = R \\ & = \lvert AC \lvert + \frac{4}{3}R_c \color{red}{+ R_o} \\ & = (\lvert AK \lvert \color{red}{+ R_i} + \frac{4}{3}R_c) + \frac{4}{3}R_c \color{red}{+ R_o} \\ & = \frac{(21 \cos (\frac{\alpha}{2}) - 4) R_c}{ 9 \sin \alpha} \color{red}{+ R_i} + \frac{8}{3}R_c \color{red}{+ R_o} \\ \end{align}

Alright, cool! Let’s see how it looks. Notice that I’ve increased the maximum chamber count, since the new algorithm deals with extreme numbers much better.

As before, you can see the algorithm in the source code for this page’s demo.


text:
# PROBING THE INTRINSIC ELECTRONIC EFFECTS OF THE $[Fe_{4}S_{4}]^{2+}$ CLUSTER ON THE REDOX POTENTIALS OF FERREDOXINS AND HIGH POTENTIAL Fe-S PROTEINS

Please use this identifier to cite or link to this item: http://hdl.handle.net/1811/20522

Files Size Format View
2002-RI-05.jpg 276.6Kb JPEG image

 Title: PROBING THE INTRINSIC ELECTRONIC EFFECTS OF THE $[Fe_{4}S_{4}]^{2+}$ CLUSTER ON THE REDOX POTENTIALS OF FERREDOXINS AND HIGH POTENTIAL Fe-S PROTEINS Creators: Wang, X. B.; Yang, X.; Niu, S. Q.; Wang, L. S. Issue Date: 2002 Abstract: Iron-sulfur proteins are ubiquitous in living systems. The bacterial ferredoxins and high potential iron-sulfur proteins are the simplest examples of Fe-S proteins with a [4Fe-4S] active center. We report a combined photodetachment photoelectron spectroscopic and theoretical study of a series of bioinorganic analog complexes, $[Fe_{4}S_{4}X_{4}]^{2-} (X = SH, SCH3, Cl, Br, I)$, in the gas phase to elucidate the intrinsic electronic contributions to the redox potentials of both the $[Fe_{4}S_{4}]^{2+/1+}$ and $[Fe_{4}S_{4}]^{3+/2+}$ redox couples. We found that the intrinsic redox potential of $[Fe_{4}S_{4}]^{3+/2+}$ increases with the decrease of the donor capability of the terminal thiolate ligands, whereas it is relatively insensitive to the bridging sulfides. The major factors contributing to the intrinsic redox potential changes in the $[Fe_{4}S_{4}]^{2+/1+}$ redox pair is the donor property of the bridging sulfide, as well as the terminal thiolate ligands. We also studied the different contributions of bridging and terminal H-bonds to the two different redox couples. URI: http://hdl.handle.net/1811/20522 Other Identifiers: 2002-RI-05


text:
# formula for the convolution inverse of a completely multiplicative function

## Primary tabs

Major Section:
Reference
Type of Math Object:
Corollary


text:
# Properties¶

Kivy introduces a new way of declaring properties within a class. Before:

class MyClass(object):
def __init__(self):
super(MyClass, self).__init__()
self.numeric_var = 1

After, using Kivy’s properties:

class MyClass(EventDispatcher):
numeric_var = NumericProperty(1)

These properties implement the Observer pattern. They help you to:

• Easily manipulate widgets defined in the Kv language
• Automatically observe any changes and dispatch functions/code accordingly
• Check and validate values
• Optimize memory management

To use them, you have to declare them at class level. That is, directly in the class, not in any method of the class. A property is a class attribute that will automatically create instance attributes. Each property by default provides an on_<propertyname> event that is called whenever the property’s state/value changes.

Kivy provides the following properties:
NumericProperty, StringProperty, ListProperty, ObjectProperty, BooleanProperty, BoundedNumericProperty, OptionProperty, ReferenceListProperty, AliasProperty, DictProperty,

For an in-depth explanation, take a look at Properties.


text:
# Macro to replace text with random string of same length

I am playing with LuaLaTeX substitutions, trying to find a way to replace a string within a macro with random characters of the same length.

The chickenize package offers the randomchars function which does this for an entire paragraph. However, I cannot get this to work on just the argument of the TeX macro, and get either errors or nothing when trying to create a macro like:

\newcommand{\rndm}[1]{\directlua{randomchars(#1)}}

• Do uppercase and lowercase have to be respected? Or should it be all uppercase, all lowercase, or should the case status of letters be random as well (presumably 50-50, right)? Should whitespace be preserved as such? What about any digits in the string: Should they be replaced with other, randomly chosen digits? Please advise.
– Mico
Jan 30 at 13:52
• Any character in unicode is fine, but whitespace should be respected (so abcd can be replaced with !RX? ) Jan 30 at 13:56
• Imho, this is a better question for a Lua community, where you'd most likely get the broader audience. Afterwards it's just tex.print the results. Jan 30 at 14:43
• Perhaps something along these lines: tex.stackexchange.com/questions/450795/…. Also, "of same length" I presume you mean same number of characters, and not same textual width? Jan 30 at 17:00
• I should note my above comment is an alternative to lua. Jan 30 at 18:00

Here you go. Note that the input and output characters could be (almost) arbitrary utf8-encoded characters. (On output, it's your job to verify that the output characters are indeed present in the font that's in use.) If the characters are TeX-special -- say, & and $ -- be sure to escape them as \\& and \\$, etc. Whitespace in the input string is preserved, but punctuation characters aren't given any preferential treatment.

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{luacode} % for 'luacode' environment and '\luastring' macro
\begin{luacode}

function rndstring ( inputstring )
local outputstring, choices, mm, nn
mm = unicode.utf8.len(inputstring) -- no. of utf8-encoded characters in input string

-- Place candidate replacement characters in a Lua table:
choices = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"\\#", "\\\$", "\\%", "\\%", "\\&", "\\_", "\\textbackslash{}",
"*", "+", "-", "/", "(", ")", "[", "]", "\\{", "\\}",
"<", "=", ">", "?", "@", "\\textasciitilde{}",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
}
-- Number of rows in 'choices' table
nn = #choices

-- Generate the outputstring in a 'for' loop:
outputstring = ""
for i = 1 , mm do
if unicode.utf8.sub ( inputstring , i , i ) == " "  then
outputstring = outputstring .. " " -- preserve space char.
else -- choose a new char randomly from 'choices' table
outputstring = outputstring .. choices[ math.random ( nn ) ]
end
end

return ( outputstring )
end

\end{luacode}

%% Define a LaTeX macro to invoke the Lua function
\newcommand\rndstring[1]{\directlua{tex.sprint(rndstring(\luastring{#1}))}}

%% test strings to feed to '\rndstring':
\newcommand\stringA{Hello World}
\newcommand\stringB{Hello Владимир öäüß}
\newcommand\stringC{Once upon a time, there was ...}

\begin{document}
\ttfamily % optional

\rndstring{\stringA}\par\rndstring{\stringB}\par\rndstring{\stringC}

\bigskip
\rndstring{\stringA}\par\rndstring{\stringB}\par\rndstring{\stringC}

\end{document}

• Why not use #choices to get the number of choices in the table? Jan 30 at 23:33
• @Skillmon - Good question! :-) I guess it's because of an old (aquired) habit of mine: In general, one should not assume that the two methods provide the same result. However, after about 10 seconds of thought, it's clear to me too that for the Lua table at hand, the two methods must provide the same result, since there are no "gaps" in this table. Indeed, I rely on this result implicitly later on, when I select a table entry randomly via choices[ math.random ( nn ) ]. I'll go ahead and fix this issue in the code.
– Mico
Jan 31 at 0:34
• I knew about the peculiarities of table access in Lua with the # operator (just came to the same conclusion as you here, in that it is the same if the table assignment is done this way). Jan 31 at 6:13
• magnificent, thank you! Jan 31 at 16:49


text:
# In game image memset function not working...

## Recommended Posts

Posted (edited)

In one of my games, I have a minimap. the question that has been buzzing around in my mind for a while is "Why wont this function work correctly?" I did some experimenting and I narrowed my selection down to a memset function. Here are the lines of code.

...

D3DLOCKED_RECT sRect;
sightTexture->LockRect(0, &sRect, NULL, NULL);
BYTE *bytes = (BYTE*)sRect.pBits;
memset(bytes, 0, sRect.Pitch*sRect.Pitch);

float intensity = 1.3f;
D3DXVECTOR2 center = D3DXVECTOR2(32.0f, 32.0f);

for(int y=0;y<64;y++)
for(int x=0;x<64;x++)
{
float d = D3DXVec2Length(&(center - D3DXVECTOR2((float)x, (float)y)));
int value = (int)(((32.0f - d) / 32.0f) * 255.0f * intensity);
if(value < 0)value = 0;
if(value > 255)value = 255;
bytes[x + y * sRect.Pitch] = value;
}
sightTexture->UnlockRect(0);

...

Where is the code going wrong?

I found this technique on an old programming website I used to use...

Without the memset function, only 1/3 of my minimap gets rendered...

Edited by rjhwinner03
Uncommented the code that I needed to.

##### Share on other sites

I don't see enough code here. How many bytes per pixel are you using?

##### Share on other sites

Well for a start, you don't appear to be locking the rect (it is commented out), so sRect contains garbage. That and you are memsetting with the pitch * pitch, which sounds unlikely?

##### Share on other sites
Posted (edited)

It still passes an exception if I uncomment the lock function...

Edited by rjhwinner03

##### Share on other sites
3 minutes ago, rjhwinner03 said:

It still passes an exception if I uncomment the lock function...

Well, yes, that will probably be using pitch * pitch as the size of the surface, which is incorrect, so you are memsetting off the edge of the surface and causing an exception.

Pitch is the size of an x line in bytes. The correct number of bytes to memset (if you need to do this) would presumably be the pitch * the height of the texture.

##### Share on other sites

The code runs, but I still get the issue that I would get if I commented out the memset function...

##### Share on other sites

I'm not too up to speed on D3D at the moment, but:

- Are you sure the texture is lockable?

- Have you tried checking the return value of LockRect()?

- Have you fixed the previously mentioned 'pitch * pitch' issue? (That might be working circumstantially, depending on the texture size and format, but it doesn't seem conceptually correct.)

- Are you sure the texture format is single-channel 8-bit?

As for the minimap only being partially rendered, I don't know that there's enough information here to diagnose that. It looks though like the texture in question is some sort of circular visibility region, so I can imagine that if the code you posted is incorrect, it might result in something like the behavior you describe.

##### Share on other sites

All of this stuff worked like a charm in Windows XP through Windows 8... I had no errors... Windows 10 is and has been a big obstacle for me in the past and the present...

##### Share on other sites

It seems to me that the same questions remain open (texture lockable? LockRect() return value? pitch * pitch? texture format?).

Regarding the change in development environment, although the problem could be related to Windows 10, I wouldn't assume that it is. I'm not saying this is necessarily the case here, but sometimes changes in environment can reveal problems that simply went unnoticed previously due to accident or circumstance.

Anyway, if you haven't solved it yet, maybe it would help take it a question at a time. So:

Have you fixed the 'pitch * pitch' issue? If not, is there any particular reason you're computing the size of the data that way?

##### Share on other sites

Attach the debugger and put a breakpoint at the line with the memset. What are the contents of sRect?

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632905
• Total Posts
3009152
• ### Who's Online (See full list)

There are no registered users currently online

×


text:
## DJBreezy one year ago Complete the equations of the system in slope-intercept form. Use a decimal for the slope if necessary. Line 1 x y 0 3 1 5 Line 2 x y –1 1 –2 –1 Line 1: y = x + Line 2: y = x + @perl .......i have no idea

1. DJBreezy

@perl i have no ideo

2. anonymous

3. anonymous

And then for line 1 you already know the y intercept so y=mx+b should be easier to figure out

4. DJBreezy

i havt a hard time with this

5. anonymous

Ok for slope formula. y2-y1=5-3 and the. You divide that by x2-x1 which equals 1-0. So the slope for line 1 is m=2/1=2.

6. perl

line 1 slope: $$\Large {m=\frac{5-3}{1-0}}$$

7. DJBreezy

m=2/1?

8. anonymous

Once you find out the slope like perl gave a good illustration for, look at the ordered pairs. Do you have an x that is 0? Well we know that for lines the y intercept is (0,y)

9. perl

the y intercept is the point (0,b)

10. perl

thats given in the directions

11. perl

m = 2 y intercept b is 3 y = mx + b now put it together

12. DJBreezy

can u give me the answer i'm completely lost now

13. anonymous
14. anonymous

Wow, you have all type of K12 questions posted here. Did you know that is copyright infringement? I bet your teachers would love to know I found this....


text:
# BFILENAME function in Oracle

BFILENAME is an advanced function that the Oracle database supports. It is used to get a BFILE locator for a physical LOB binary file. The BFILENAME function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.

Syntax:

BFILENAME( 'directory', 'filename' )

Parameters:
directory: It is used to specify the directory object to serve as an alias for the full path of the file.
filename: It is used to specify the file name of the file on the file server.

Example :

SELECT BFILENAME ('Dir', 'file.png') FROM dual;

Explanation:
Here, the ‘Dir’ is an already created directory and the ‘file.png’ is the name of the required file.


text:
# smallest square containing k non-overlapping equal rectangles at any orientation

This seems like something that should have a known answer, but I haven't found it after some time alternating between searching and generating multiple pages of algebra. I'm interested in $k=4$ and $k=6$, but I'll phrase it for general $k$:

Given $k$ identical rectangles of dimension $a \times b$ (let's assume $a \leq b$), what is the smallest square that can contain them if the rectangles do not overlap and can be placed at any orientation (i.e., not necessarily parallel to the square's sides)?

• It is not clear from your wording what constraints are given and what freedoms are allowed. For example, for k=1 and a much smaller than b, I can use a square with side length close to 0.7 times b, if I get to choose the packing. Do I get to choose? Or are the orientations fixed and I have to find the smallest square covering them? Gerhard "What Are The Rules Here?" Paseman, 2018.08.31. – Gerhard Paseman Aug 31 '18 at 22:50
• What motivates this question? And why are the cases $k=4$ and $k=6$ of special interest? – Wlodek Kuperberg Nov 6 '18 at 21:50

You might recheck your values for k=1 and 2. In particular, an ab rectangle fits in a square of side length (a+b)/c, where c*c=2. For a less than (c-1)b, this improves upon a square of side length b. For k=2 and a smaller than (c-1)b/2, a similar diagonal packing works.

One approach you can use is to consider packing rectangles into the smallest rectangle, and then fitting this larger rectangle inside a square. This may not achieve optimum, but it leverages earlier work and should give near optima.

Gerhard "And Check Out Pack-O-Mania Website" Paseman, 2018.08.31.

Just a note to indicate why this question might not be straightforward, now that it's been bumped to the homepage. For $$k=2$$ rectangles of size $$a \times b = 1 \times 6$$, the diagonal packing is better than $$6$$, because $$2a < (\sqrt{2}-1) b$$, as Gerhard mentions in his answer. But this is not the optimal packing, as the figure below indicates: Tilting the rectangles differently fits in a smaller square.

The diagonal packing for two $$1 \times 6$$ rectangles is suboptimal. The blue squares are identical.
It would be interesting to find an example where the rectangles are necessarily not parallel in an optimal packing.

• For your last question (sorry, I do have to use words instead of pictures), I suspect that four copies of a $1\times(1-\epsilon)$-rectangle (for small $\epsilon >0$) can best be packed into a square when not parallel. I have the feeling (but have not attempted to prove) that when parallel, the smallest square has side length 2. But if we are allowed to use the rectangles in two different orientations (related by a 90 degree rotation), then we can pack them into a square of side length $2-\epsilon$. I imagine a ring-like arrangement in which the rectangles leave a small hole in the middle. – M. Winter Sep 2 at 21:20


text:
Dictionary Learning Strategies for Compressed Fiber Sensing Using a Probabilistic Sparse Model

We present a sparse estimation and dictionary learning framework for compressed fiber sensing based on a probabilistic hierarchical sparse model. To handle severe dictionary coherence, selective shrinkage is achieved using a Weibull prior, which can be related to non-convex optimization with p-norm constraints for 0 < p < 1. In addition, we leverage the specific dictionary structure to promote collective shrinkage based on a local similarity model. This is incorporated in form of a kernel function in the joint prior density of the sparse coefficients, thereby establishing a Markov random field-relation. Approximate inference is accomplished using a hybrid technique that combines Hamilton Monte Carlo and Gibbs sampling. To estimate the dictionary parameter, we pursue two strategies, relying on either a deterministic or a probabilistic model for the dictionary parameter. In the first strategy, the parameter is estimated based on alternating estimation. In the second strategy, it is jointly estimated along with the sparse coefficients. The performance is evaluated in comparison to an existing method in various scenarios using simulations and experimental data.

Authors

• 3 publications
• 18 publications
• NOODL: Provable Online Dictionary Learning and Sparse Coding

We consider the dictionary learning problem, where the aim is to model t...
02/28/2019 ∙ by Sirisha Rambhatla, et al. ∙ 0

• Observable dictionary learning for high-dimensional statistical inference

This paper introduces a method for efficiently inferring a high-dimensio...
02/17/2017 ∙ by Lionel Mathelin, et al. ∙ 0

• Self-expressive Dictionary Learning for Dynamic 3D Reconstruction

We target the problem of sparse 3D reconstruction of dynamic objects obs...
05/22/2016 ∙ by Enliang Zheng, et al. ∙ 0

• Learning Hybrid Representation by Robust Dictionary Learning in Factorized Compressed Space

In this paper, we investigate the robust dictionary learning (DL) to dis...
12/26/2019 ∙ by Jiahuan Ren, et al. ∙ 9

• Globally Variance-Constrained Sparse Representation for Image Set Compression

Sparse representation presents an efficient approach to approximately re...
08/17/2016 ∙ by Xiang Zhang, et al. ∙ 0

• Example Selection For Dictionary Learning

In unsupervised learning, an unbiased uniform sampling strategy is typic...
12/18/2014 ∙ by Tomoki Tsuchida, et al. ∙ 0

• A Dictionary Learning Approach for Factorial Gaussian Models

In this paper, we develop a parameter estimation method for factorially ...
08/18/2015 ∙ by Y. Cem Subakan, et al. ∙ 0

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Fiber sensors are versatile devices with broad applicability [38, 23, 46, 63]. They are of high interest in smart structures to sense and react to the environment [42, 58]. For quasi-distributed sensing based on wavelength-division multiplexing (WDM), fiber Bragg grating (FBG) sensors are often employed due to their sensitivity to strain or temperature [38, 23]. An FBG describes a local variation of the refractive index and reflects light at a certain wavelength, called Bragg wavelength. Typically, a number of detuned FBGs is imprinted into the core of an optical fiber. Fiber interrogation is performed using broadband light sources or wavelength-tunable lasers. The latter feature higher local signal-to-noise ratios (SNRs) [46, 63]. However, in order to monitor time-varying perturbations, the laser has to sweep quickly through the tuning range. This requires high-speed analog-to-digital converters (ADCs) and produces large amounts of data.
Compressed sensing (CS) [5, 15, 27] can help to alleviate these problems by taking samples in form of projections into a low-dimensional subspace. The original signal can be reconstructed by exploiting the sparsity of the signal with respect to an adequate dictionary [14, 11]. This task strongly resembles the sparse synthesis problem with redundant dictionaries in [57, 53]. Besides greedy methods, such as Orthogonal Matching Pursuit (OMP) [49], -minimization is a popular method to solve the sparse reconstruction problem [56, 24, 12]. It relies on the restricted isometry property (RIP), which essentially states that unique sparse solutions can be recovered by restricting the -norm instead of the -norm [25, 13]. Redundant dictionaries can yield highly sparse representations, that allow for estimating quantities at high resolution directly in the sparse domain [24, 41]. However, redundancy causes inter-column coherence and it is likely that the required RIP conditions are no longer fulfilled [24, 52, 12]. The -norm, with , offers a trade-off to avoid an NP-hard combinatorical problem imposed by the -norm, while a unique solution might still be retrieved [17, 18].

Dictionaries can be classified as parametric or non-parametric. Non-parametric dictionaries are typically learned from training data and often used if no analytical model is available

[53]. While they can yield sparser representations of certain data realizations [40], non-parametric dictionaries usually lack an interpretable structure and are inefficient in terms of storage [53]. Parametric dictionaries, in turn, rely on an analytical model for the observed signal. Their analytic form offers an efficient implementation and a means to obtain optimality proofs and error bounds [53]. They are also favorable in terms of scalability and storage-efficiency [4, 53]. Translation-invariant dictionaries represent an important sub-class of parametric dictionaries, that can be used to estimate the translation coefficients of localized signals [36, 9, 29]. Nonetheless, due to the complexity of natural signals, some model parameters might be unknown or contain uncertainty. Parametric Dictionary Learning (DL) addresses this problem with the aim of estimating these parameters from the measured data. Herein, statistical DL methods, such as maximum likelihood (ML) or maximum a posteriori (MAP) estimation, are commonly employed [53]. In order to solve the resulting optimization problem, alternating estimation (AE) is a frequently pursued sub-optimal paradigm, that iteratively optimizes a local objective function [43, 6, 2]

. In a Bayesian setting, the Expectation Maximization (EM) algorithm is a popular variant of AE-based estimation

[53].
A model for the sparse coefficients can be of deterministic or probabilistic nature. While the deterministic case is often assumed in sparse estimation [24, 12], a probabilistic model offers high flexibility to take model deviations and measurement errors into account. Moreover, a hierarchical structure can be used to incorporate additional uncertainty in prior assumptions. Sparsity can either be promoted by continuous distributions, resulting in weakly sparse models, or by discrete mixtures, leading to strongly sparse models [43]. A prominent example of discrete mixtures are Spike & Slab models [34]

. They are based on binary activations and yield strongly sparse representations. Continuous sparse priors, such as a Gaussian or double-exponential (Laplace) prior, feature high excess kurtosis with heavy tails and a narrow peak around zero

[50, 43]. Besides sparsity, additional knowledge of the signal, e.g. correlation, can be incorporated [26, 66].
For many practical models, evaluating the posterior distribution is not feasible and approximate methods, such as Markov Chain Monte Carlo (MCMC) or variational Bayes methods, have to be used to accomplish inference [8, 48, 54]. Variational methods use rather simple analytic functions to approximate the posterior distribution by factorization, which is favorable in terms of scalability and computational costs but leads to a deterministic approximation [54, 8]. MCMC methods attempt to sample the posterior distribution, where subsequent samples form a Markov chain [8]. The Hamilton Monte Carlo (HMC) method is a powerful technique, that is especially suitable for sampling high-dimensional spaces in the presence of correlation [47]. However, MCMC performance is generally limited by the available computation time, thereby relying on a stochastic approximation. Another application of MCMC is found in non-convex optimization, where Stochastic Gradient (SG) MCMC has gained popularity for large-scale Bayesian learning [22, 20, 19].
In the present work, we consider the problem of Compressed Fiber Sensing (CFS) with highly coherent translation-invariant dictionaries and imperfectly known parameters. For the sparse coefficients, a weakly sparse hierarchical model is considered. We also establish a relation between this model and non-convex optimization with -norm constraints for . In order to alleviate the problem of dictionary coherence, we leverage additional structure of the dictionary and achieve augmented sparsity by establishing a Markov random field (MRF) relation among the sparse coefficients. For dictionary learning, we pursue two different strategies: In the first strategy (S1), we consider a deterministic dictionary parameter, that is estimated using a Monte Carlo EM algorithm. In the second strategy (S2), a probabilistic hierarchical model for the dictionary parameter is considered, leading to a full Bayesian formulation and joint estimation of the sparse coefficients and the dictionary parameter. In both strategies, approximate inference is accomplished using a hybrid MCMC method based on Gibbs sampling and HMC. Finally, we use simulations and real data to compare the proposed methods to previous work in [62], where a deterministic model is considered for the sparse coefficients and the dictionary parameter. For the deterministic case, we derive the Cramér-Rao bound (CRB) to assess the performance gain achieved by a probabilistic model.

1.1 Contributions

• We propose a probabilistic model for the sparse coefficients, where a Weibull prior is used to promote (weak) sparsity. Additional collective shrinkage is achieved by establishing an MRF-relation among the sparse coefficients based on a bivariate kernel function in the joint prior density. This helps to moderate the impact of severe dictionary coherence and can be used in general sparse synthesis problems with similar dictionary structure. We also establish a relation to non-convex optimization with constraints on the -norm for .

• For dictionary learning, we investigate two conceptually different strategies, assuming either a deterministic (S1) or a stochastic (S2) dictionary parameter. In both strategies, the noise level can be jointly estimated along with the sparse coefficients. We further highlight advantages, disadvantages and limitations to offer support in choosing an adequate method for practical systems.

• To accomplish inference in these models, we use a hybrid MCMC method, combining HMC and Gibbs sampling, We show its applicability and efficacy in the considered sampling problem for CFS.

• We use simulations to evaluate the performance of the proposed sparse estimation and DL methods for various scenarios of different CS sample sizes, SNRs and CS matrices. These results are compared to an existing method in [62], where the sparse coefficients and the dictionary parameter are assumed to be deterministic. In addition, we provide a real-data example to verify the practical applicability of S1 and S2.

• We derive the Cramér-Rao bound for jointly estimating the sparse coefficients and the dictionary parameter in the deterministic case. It is a valid bound for the competing method in [62], and serves to assess the achieved performance gain of our probabilistic approach.

2 Related Work

There exists little work addressing the combination of CS and DL for the application of WDM-based distributed fiber-optic sensing [60, 61, 62]. In [60], a model for the received sensor signal is presented, from which a redundant shift-invariant parametric dictionary is created. The works in [61, 62] focus on the aspect of CS and sparse estimation in the case of uncertain dictionary parameters. The authors use AE-based estimation to determine the dictionary parameters, where a pre-processing routine accounts for severe dictionary coherence. Unlike our approach, these works use a deterministic model for the sparse coefficients and dictionary parameters.
Weakly sparse models have been widely used in the literature. A comprehensive analysis of different hierachical sparse prior models is provided in [44]. The general problem of choosing the prior in weakly sparse models for sparse regression is addressed in [50], where the authors describe various properties of different shrinkage priors and illuminate the selection problem from two perspectives: prior distributions and penalty functions. The work in [43] also investigates Bayesian methods with different sparse models in comparison to classical -minimization. Seeger [54] found that the Laplace prior is able to shrink most components close to zero, while allowing for selected components to become sufficiently large. This effect, termed selective shrinkage in [35], is most noticeable for heavy-tailed priors, e.g. the Student’s -prior [54] or the horseshoe prior in [16, 50]. Based on these findings, we select a sparsity prior that resembles a positive version of the horseshoe prior. Other works, that focus on the perspective of penalized regression, report higher sparsity levels by penalizing the -norm with instead of the -norm [30]. The authors in [17] show that the RIP requirements for the dictionary can be relaxed in this case. It is also pointed out in [17, 18] that non-convex CS with -norm penalization requires less measurements than standard CS, which is based on the -norm. We rely on these results and show a relation between the considered sparsity prior and non-convex optimization with -norm constraints.
There exist several approaches to exploit additional structure of the signal. One example is block sparsity [26]. A block sparse Bayesian learning framework is proposed in [66], pointing out how correlation can be exploited in regularization algorithms. Wakin et al. [59] introduce the concept of joint sparsity for signal recovery in distributed CS theory. In [41], temporal correlation across subsequent CS measurements is considered, while the authors in [21] use correlation to achieve smoothness. Another related concept is proposed in [3], where a truncated multivariate Ising MRF model is used to describe the correlation between adjacent pixels for image processing. Different from these works, we use the ideas of MRFs [45] and exploit correlation to achieve collective shrinkage among the sparse coefficients.
A comparative analysis in [43] suggests that MCMC methods are powerful for inference in sparse models. In [47], the benefits of HMC and Gibbs sampling in hierarchical models are outlined. It is also shown, that HMC can be more effective than a Gibbs sampler for sampling high-dimensional spaces in the presence of correlation. According to these results, we consider a hybrid MCMC method that combines HMC and Gibbs sampling for inference in our hierarchical model, where the sparse coefficients are high-dimensional and correlated. For parametric DL, the Monte Carlo EM algorithm in S1 represents one variant of the frequently applied AE-based estimation technique [39, 51]. Comparable to S2 is the Bayesian framework for sparse estimation and DL in [31]. However, the authors use a Gaussian prior without correlation.

2.1 Outline

In Section 3, the signal model for CFS is introduced, and in Section 4, the CRB for joint estimation of the deterministic sparse coefficients and dictionary parameters is derived. Section 5 details the sparsity and local similarity model, while Section 6 describes the hybrid MCMC method for approximate inference in this model. The parametric DL strategies S1 and S2 are described in Section 7. Section 8 shows the working principle along with a performance analysis of the proposed and an existing method based on simulations and experimental data. A discussion of the results and findings is given in Section 9. Section 10 concludes this work.

3 Signal Model

In order to determine the quantity and nature of impairments at the FBGs in a WDM-based fiber sensor, the time delays of the reflections from the individual FBGs need to be estimated. We adopt the model in [60, 61, 62], where CS-based acquisition is employed to reduce the number of samples to be stored and processed. The CS measurements are described by

 y=ΦA(θ)x+n, (1)

where is the CS sampling matrix and is a Gaussian noise component with independent and identically distributed (i.i.d.) entries, ,

. The vector

is sparse with significant components, and is a scalar dictionary parameter. The matrix represents a redundant shift-invariant dictionary and its columns, called atoms, represent FBG reflections on a dense grid of delays. The indices of the significant components in indicate the desired reflection delays. They are collected in the set . We can write the full data likelihood function for this model by

 (2)

The -th dictionary atom, , is defined by [62]

 [ai]l(θ)=r(lTd−iδt,θ),  l=1,…,L, (3)

where the generating function, , describes the reflection from a single FBG, incrementally shifted by and sampled with a design sampling period, . In order to specify the dictionary parameter in CFS according to [62], we write

 r(t,θ)=∫∞−∞ej2πftH\tiny LP(f,θ)iph(f)df. (4)

Herein, is the received photocurrent in the frequency domain, and is the transfer function of a lowpass filter, that models a limited effective bandwidth of the receiver circuitry. This bandwidth is described in terms of a positive dictionary parameter, . As an auxiliary parameter, it accounts for different indistinguishable sources of uncertainty, that all contribute to the broadening in the temporal response of the FBG reflections. A detailed model for is provided in [62].

4 The CRB for joint estimation of (x,θ) in CFS

We derive the CRB for jointly estimating the deterministic parameters (). This is a valid bound for the model considered in [62] and can be used to assess the relative performance gain achieved by the proposed probabilistic sparse model and DL strategies. Although the Bayesian CRB in [10] can be empirically determined, we found that this bound is very lose, due to the high information content in the considered sparsity prior. Therefore, and in regard of the comparative analysis with the deterministic case in [62], the non-Bayesian CRB is more useful in this case.
The constrained CRB for estimating with sparsity constraints has been derived in [7]. However, this derivation does not assume uncertainty in the dictionary. It is based on locally balanced sets and involves the projection of the Fisher Information matrix (FIM), , onto a low-dimensional subspace spanned by the so-called feasible directions. Any estimator, , for which the constrained CRB is a valid lower bound, must be unbiased with respect to these directions. The projection matrix can be created from the unit vectors corresponding to the non-zero coefficients in , that is with , . For a Gaussian likelihood as in (2), the FIM can be derived from the expected value of the Hessian matrix of the log-likelihood function, i.e. [37, 7]

 I(x)=−Ey∇2xlogp(y|x,θ)=1σ2nB⊤B, (5)

with . Further, we define the reduced FIM by . Then, given that is exactly -sparse, the constrained CRB for a known dictionary becomes [7]

 Cov(^x)⪰UI−1KU⊤,∥x∥0=K. (6)

Based on these results, we derive the CRB for the joint parameters . First, we derive the Fisher information for , given that is known. It is given by

 I(θ) = −Ey∂2∂θ2logp(y|x,θ) (7) = Ey∂2∂θ212σ2n(y−ΦA(θ)x)⊤(y−ΦA(θ)x) = 1σ2nx⊤A′(θ)⊤Φ⊤ΦA′(θ)x.

Herein, denotes the (element-wise) derivative of with respect to . Next, we have to take into account that and share some mutual information. Therefore, we define the combined FIM:

 I(γ)=(I(x)−Eyu−Eyu⊤I(θ)), (8)

where and , . Since the partial derivatives can be interchanged, the off-diagonal elements are identical. In order to complete the definition of , we determine

 −Eyui = −Ey∂2∂xi∂θlogp(y|x,θ) (9) = 1σ2nx⊤A′(θ)⊤Φ⊤Φai(θ).

The reduced FIM is obtained by appending the set of feasible directions, such that the coordinate is included, i.e. . Hence, . To obtain the inverse, we apply twice the matrix inversion lemma [32]

 I−1K+1=⎛⎜ ⎜⎝(IK−vv⊤I(θ))−1−1˘bI−1Kv−1˘bv⊤I−1K1˘b⎞⎟ ⎟⎠, (10)

where , and

 (IK−vv⊤I(θ))−1=I−1K+1˘bI−1Kvv⊤I−1K. (11)

The constrained CRB for the joint parameters in becomes

 Cov(γ) ⪰ ~UI−1K+1~U⊤,∥x∥0=K. (12)

Finally, a lower bound for the mean squared error (MSE) in the joint setting is obtained by updating the individual estimation errors to account for the information shared between and :

 MSE(^x) ≥ (Tr I−1K)+1˘bv⊤I−1KI−1Kv (13) MSE(^θ) ≥ 1˘b= I(θ)−1+v⊤IKvI(θ)(I(θ)−v⊤IKv). (14)

5 Probabilistic sparse model

Regarding the model in (1), the data can be explained in different ways. On the one hand, many non-zero components in and a large bandwidth, , result in many narrow temporal peaks that can yield a good approximation of the observed reflections. On the other hand, it is known that the sensing fiber contains FBGs, so we expect exactly reflections. Therefore, a more useful explanation is given by significant elements in with a smaller value of , such that correctly indicates the reflection delays. Nevertheless, even for a suitable value of , the signal is usually not exactly sparse but contains many small elements close to zero, e.g. due to measurement noise. In a strongly sparse model, these contributions are not taken into account, which impacts the positions of non-zero elements in . Hence, it may lead to incorrectly estimated reflection delays. This motivates a weakly sparse model, where the most significant components indicate the reflection delays. When and are both unknown, the reflections delays can only be estimated when prior information of sparsity is incorporated, since depends on and vice versa. Severe dictionary coherence aggravates this problem and results in several non-zero components with moderate amplitudes around the true significant elements. The coherence level is even stronger when the dimensionality of the acquired data is further reduced by CS. Thus, an adequate sparse model for must compensate for this effect. Classic -minimization can be interpreted as an MAP estimation problem, where has i.i.d. entries with Laplace priors [43]. However, the required performance guarantees for -minimization, essentially the RIP [14, 11], are no longer fulfilled in the case of strong dictionary coherence. According to [17, 18], the RIP conditions can be relaxed for -minimization, when . Therefore, we use a prior with stronger selective shrinkage effect, that can be related to constraints on the -norm in non-convex optimization. Yet, specific characteristics of the signal have to be considered. The measured reflection signal is proportional to the optical power, and the dictionary atoms essentially model the optical power reflected from the individual FBGs. Thus, the prior must also account for the non-negativity of the data. Due to these restrictions, we choose a Weibull prior that resembles a positive version of the horseshoe prior in [50] and induces the required selective shrinkage effect:

 xi∼p(xi)=W(xi|λw,kw), xi>0, i=1,…,N, (15)

where are the scale and shape parameters, respectively. Then, the joint prior density of is given by

 p(x|kw,λw)=kwλkwwN∏i=1xkw−1iexp(−λ−kwwN∑i=1xkwi). (16)

Fig. 1 (top left) shows qualitatively the shape of the considered prior in the bivariate case.
Based on (16) and (2), we can relate the problem to constrained ML estimation. First, let us consider an interpretation in terms of MAP estimation as in [44], by calculating or, equivalently,

 argminx∥y−ΦA(θ)x∥22+μ1N∑i=1log(xi)+μ2N∑i=1xkwi, (17)

where and with and . In order to formulate a related constrained ML problem, let us define two functions,

 g1=N∑i=1xkwi−λkw1  and  g2=N∑i=1log(xi)−λ2, (18)

where are related to the coefficients , respectively. The functions in (18) can represent inequality constraints of the form and , that account for the impact of the prior by restricting the search space. Hence, a constrained version of the ML problem can be formulated by

 argminx≻0 ∥y−ΦA(θ)x∥22 (19) s.t. ∥x∥kw ≤ λ1 (20) and N∑i=1log(xi) ≤ λ2. (21)

In this non-convex problem, denotes the -norm with

. The hyperparameters

control the shrinkage effects. Fig. 1 (top right) depicts the search space restricted by the constraints (20)-(21). The borders are shown for a fixed value of and in the bivariate case.

5.1 Local covariance model for augmented sparsity

In analogy to the concept of block sparsity [26], we can use the specific sparse structure of the signal with respect to the shift-invariant dictionary for CFS to exploit sparsity among groups of variables. The signal contains only reflections that arrive at temporally separated delays, indicated by the significant components in . Therefore, we can assume that a significant coefficient is always surrounded by larger groups of non-significant coefficients and any two significant components are always well separated. Also, it is likely that the amplitudes of adjacent non-significant coefficients are similarly close to zero. Borrowing from the ideas of MRFs [45], such local similarity can be modeled by a prior on the differential coefficients, , where . It restricts the variation of adjacent amplitudes and establishes a MRF relation between neighboring coefficients in . Then, non-significant coefficients with larger amplitudes are pulled down to match the majority with almost-zero amplitudes, which promotes additional collective shrinkage. However, if a significant coefficient follows a non-significant one (or vice versa), the model should allow for larger changes. Therefore, the differential variation must be locally specified, dependent on the respective amplitudes, in order to avoid undesired shrinkage or equalization.

To this end, we define a kernel function for all adjacent pairs of sparse coefficients, i.e. , with hyperparameter :

 K(xi,xi+1|λ\tinyΔ) = exp(−λ\tinyΔ|xi+1−xi|f\tinyK(xi,xi+1)). (22)

The bivariate function controls the similarity level between adjacent coefficients. Within the scope of this work we consider cases, where this function takes the form , , with positive constants , . They can be incorporated in to yield a modified joint prior density,

 ~p(x|kw,λw,λ\tinyΔ)  =  1Z\tinyKW(xN|kw,λw)
 (23)

with normalization constant . For any , it holds that and

 ~p(x|kw,λw,λ\tinyΔ)∣∣Z\tinyK=1 ≤ p(x|kw,λw) (24)

is bounded. Hence, there exists a positive constant that normalizes (23) to make a proper density. Fig. 1 (bottom) visualizes the function and its impact on the original prior in the bivariate case.
In the view of constraint ML estimation, the modified prior density in (23) can be related to the optimization problem in (19)-(21) by imposing additional constraints

 |xi+1−xi|f\tinyK(xi,xi+1)≤μi,i=1,…,N−1. (25)

Fig. 1 (top right) depicts a bivariate example. In order to show the MRF relation between the coefficients, we calculate the conditional densities . To this end, we conveniently define and get

 ~p(xi|x∖i,kw,λw,λ\tinyΔ) = ~p(xi|xi−1,xi+1,kw,λw,λ\tinyΔ% )

 ∝ W(xi|kw,λw)K(xi−1,xi|λ\tinyΔ)K(xi,xi+1|λ\tinyΔ), (26)
 ~p(x1|x∖1,kw,λw,λ\tinyΔ)   ∝ W(x1|kw,λw)K(x1,x2|λ\tiny% Δ), (27)
 ~p(xN|x∖N,kw,λw,λ\tinyΔ) ∝W(xN|kw,λw)K(xN-1,xN|λ\tinyΔ), (28)

where dependencies appear only between directly adjacent coefficients.
In order to account for deviations from prior assumptions, we consider randomization of the hyperparameters and assign conjugate inverse Gamma priors to the scale parameters and . Finally, given and a normalization constant , the shape parameter,

, is assigned the conjugate prior distribution according to

[28]:

 p(kw|a′,b′,(d′)kw,λw)=ka′wZkwexp(−b′kw−(d′)kwλw), (29)

Fig. 2 shows a factor graph for the complete sparsity model with randomized hyperparameters.

6 Approximate Inference: Hybrid MCMC

In order to accomplish inference in the sparse model, we apply a hybrid MCMC technique, i.e. HMC within Gibbs sampling. The reasons for using HMC are twofold: Firstly, it only requires an analytic expression for the posterior density to be sampled. Secondly, it is efficient in sampling high-dimensional spaces in the presence of correlation. However, as pointed out in [47], it can be more efficient to sample the hyperparameters separately, as their posterior distributions are often highly peaked and require a small step size in the HMC algorithm, which limits the general performance. Therefore, we employ an outer Gibbs sampler for approximate inference of the latent variables. In each iteration,

is sampled using HMC, while all other variables are fixed. Since we are also interested in estimating the noise variance,

, it is assigned an inverse Gamma () prior and sampled along with the other variables. The resulting model is summarized below:

 x|kw,λw,λ% \tinyΔ ∼ ~p(x|kw,λw,λ\tinyΔ)  in (???), λw ∼ Inv-Γ(λw|a,b), kw|λw ∼ p(kw|a′,b′,(d′)kw,λw)in (???), λ\tinyΔ ∼ Inv-Γ(λ\tinyΔ|a′′,b′′) σ2n ∼ Inv-Γ(λ\tinyΔ|aσ,bσ). (30)

We also define as a representative variable with corresponding positive, real-valued parameters and , that belong to the respective density functions. Further, the set denotes the set without the respective variable . Fig. 3 shows a graphical model that helps to visualize the dependencies in this model. Herein, and are only valid for strategy S2, which is discussed in Section 7. For the particular model in (30), we assume that the variables and are mutually independent. Gibbs sampling requires the full conditional distributions for each parameter of interest. Based on these assumptions, we obtain the relation

 ∝ p(y|x,C)p(ζ|x,C∖ζ) (31) ∝ p(y|x,C)p(ζ|C∖ζ)~p(x|C). (32)

Since the prior distributions are all conjugate to the Gaussian likelihood function in (2), a simple calculation yields the posterior distributions of the parameters involved in the Gibbs sampling procedure. For , we obtain

 ζ|y,x,C∖ζ∼ Inv-Γ(ζ|aζ+\scriptsizeM2, bζ+\scriptsize12) ~p(x|C), (33)

and for , we obtain

 kw|y,x,C∖kw ∼  p(kw|~a′,~b′,~c′) ~p(x|C), (34)

with parameters , , and . Samples of the posterior variables can be obtained using Metropolis Hastings [8] or HMC.

The sparse coefficients are sampled using HMC. We briefly describe the idea of this method according to [47], adapted to our model for :
Within the framework of HMC, the sampling process is described in terms of Hamilton dynamics, a concept known from classical physics. It is used to describe the trajectory of a physical system in phase space, based on its potential and kinetic energy. HMC assigns to every sparse coefficient, , an associated momentum variable, , , that is responsible for the sampling dynamics. The posterior density to be sampled is related to the potential energy, given by [47]

 U(x|y,C) = −log~p(x|y,C)−log(Zu), (35)

where is a suitable normalization constant. Since and are fixed, we may drop them and write instead. The kinetic energy, , depends only on the auxiliary variables . A standard choice for corresponds to independent particles in free space with mass , i.e. . The dynamics of the sampling process are governed by the Hamiltonian function, which is given by and represents the total system energy. The joint density of is defined by [47]

 p(x,ξ)=1Zce−H(x,ξ)T\scriptsize sys= ~p(x|y,C)N∏i=1N(ξi|0,mi). (36)

Herein, is called the system temperature and is a normalization constant. The last equation is obtained by setting and , while the Gaussian density arises from the special choice of the kinetic energy term. In HMC, a proposal for a new sample is obtained by the final points () of a trajectory described by Hamilton’s equations of motion. They are calculated , [47]:

 dxidt=ξimi,dξidt=−∂∂xi~p(x|y,C)~p(x|y,C). (37)

A Metropolis update decides, whether a proposed sample is accepted or rejected, with acceptance probability

[47]

 P(accept)=min(1, exp(−H(x∗i,ξ∗i)+H(xi,ξi)) ). (38)

7 Parametric DL strategies for CFS

In this section, we present two strategies for parametric dictionary learning in CFS. In the first strategy (S1

), we follow the ideas of hybrid Bayesian inference

[64, 65] and AM-based DL [6], where is a deterministic parameter, that is estimated using the Monte Carlo EM algorithm in [8]. In the second strategy (S2), we pursue a full Bayesian approach and consider a probabilistic model for . Herein, approximate inference is accomplished by extending the Gibbs sampler in Section 6 to jointly estimate . Fig. 3 depicts the dependency graph for both strategies, where belong exclusively to S2.
As pointed out in [64, 65], hybrid and full Bayesian strategies have their individual advantages in certain situations. For small sample sizes, Bayesian methods can be superior if good prior knowledge is available [64]. Nonetheless, they are often computationally more complex and insufficient prior information can lead to a small-sample bias, even if a non-informative prior is used [64]. In CFS, the sample size is small and only vague prior knowledge of is available. Therefore, we investigate the performance of both DL strategies based on our probabilistic sparse model. The computational complexity of both strategies is comparable. It is dominated by HMC, i.e. by sampling the high-dimensional vector in each iteration of the Gibbs sampler. Regarding , the following prior knowledge is assumed: In S1, we roughly restrict the range of values that can take, while in S2, we define a non-informative prior over the same range. Recall that effectively describes the filter characteristics of the lowpass filter . To create the dictionary for a certain value of using (3

), the inverse Fourier transform in (

4) has to be evaluated for each atom. Thus, the dictionary is not a simple function of and we restrict ourselves to a discrete set of parameters, with lower and upper bound, and , respectively. Since the bandwidth should be positive and bounded, we have and . Then, the set contains the discrete values ,

7.1 Hybrid DL: iterative estimation of θ and (x,C) (S1)

The dictionary parameters in the CFS problem can be iteratively estimated using a Monte Carlo EM algorithm. First, an initial value, , has to be chosen. In subsequent iterations with indices , we obtain joint samples , by Gibbs sampling and HMC according to Section 6. Then, we determine the posterior expectation of , using the previous estimate :

 ^ζ(d) = ∫dom(ζ)ζp(ζ|y,^θ(d−1))dζ (39) ≈ 1L\tiny MCL\tiny MC∑l=1 ζ(d)lp(ζ(d)l|y,^θ(d−1)), (40)

where is the domain of . The current estimates of the reflection delays, , are determined by identifying the indices of the largest elements in the posterior mean of , denoted by . It is obtained by exchanging with in (40). Besides, we also estimate the amplitudes of the significant components in . They can be useful to assess the sparsity level of the solution and to determine the amount of optical power reflected from the FBGs. Since the posterior of is multimodal with one narrow peak around zero and another peak at some larger amplitude, the MAP is more suitable for this task. It is given by

 {^x,^C}(d)\tiny MAP = argmaxx,C logp(x,C|y,^θ(d−1)) (41) ≈ argmax{xj,Cj}∈{xl,Cl}(d)l=1,..,L\tiny MClogp({xj,Cj}(d)|y,^θ(d−1)). (42)

However, the estimates of obtained from are less accurate than those obtained by the posterior mean. Therefore, the empirical MAP solution is only used to estimate the reflection amplitudes. Next, we calculate the current estimate by taking the expected value over given (E-step):

 (43) = ∫RN+∫Ψlogp(y,x,C|θ)p(x,C|y,θ)dCdx ≈ 1L\tiny MCL\tiny MC% ∑l=1 logp(y,{xl,Cl}(d−1)|θ) ≜ Q(θ|^θ(d−1)). (44)

Herein, is the product space formed by the individual domains of all variables in . In the -step, a locally optimal value, , is obtained by maximizing over the set , i.e.

 ^θ(d) = argmaxθ∈Θ Q(θ|θ(d−1)). (45)

7.1.1 Initialization of θ via bisectional search

An adequate initialization, , can alleviate the problem of local optima in the EM algorithm. In CFS, the desired sparsity level is known to be the number of reflections, . Hence, a good choice for yields a solution for with significant non-zero elements. Starting at an arbitrary value , a bisectional search within can quickly determine a suitable initial value. After choosing the first value at random, is subdivided into two parts, containing all larger and all smaller values, respectively. When the number of peaks is too high, the next trial is chosen as the median of the lower division. If it is too low, the next trial is the median of the upper division, and so on. For a properly selected , S1 converges faster and is more likely to approach (or even attain) the global optimum.

7.2 Bayesian DL: joint estimation of (x,C,θ) (S2)

In strategy S2, we treat

as a random variable. Due to its discrete nature, each element

is assigned a probability mass, , where . Then, is categorically (Cat) distributed over the set of discrete dictionary parameters, , with corresponding probability masses in . Uncertainty in the a priori assigned probability masses is taken into account in terms of a prior on . The Dirichlet (Dir) distribution can be used as the conjugate prior with parameters , i.e.

 p(Ξ)= 1B(ν)RΘ∏r=1pνrr, (46)

where denotes the Beta function and the variables , , describe the number of occurrences of the values in . When a new element, , is sampled, a posterior count is assigned to that value. After sampling another value in the next iteration, this count is reassigned to the new value. Let indicate the current sample, i.e. for one index , while all other elements are zero. A non-informative prior is obtained if all values are equally likely and each element is assigned a single count. Then, and a new sample has a strong impact on the posterior distribution. In contrast, for large values, e.g. , a new count leaves the distribution almost invariant. The complete model is then given by (30) and, in addition,

 Ξ ∼ Dir(Ξ|ν) (47) θ|Ξ ∼ Cat(θ|RΘ,Ξ). (48)

To accomplish approximate inference in this model, the variables and are included in the Gibbs sampling procedure of Section 6. Therefore, the conditional distributions must be determined. Based on the dependencies in Fig. 3, and since and are assumed to be mutually independent, we find

 Ξ|θ = ˜Ξ ∼ Dir(Ξ|ν+˘c), (49) θ|y,˜Ξ ∼ Cat(θ|RΘ,˜Ξ). (50)


text:
Astronomy 2e

# Figuring for Yourself

Astronomy 2eFiguring for Yourself

### Figuring for Yourself

32.

In the future, astronomers discover a solid moon around a planet orbiting one of the nearest stars. This moon has a diameter of 1948 km and a mass of $1.6×10221.6×1022$ kg. What is its density?

33.

The Moon was once closer to Earth than it is now. When it was at half its present distance, how long was its period of revolution? (See Orbits and Gravity for the formula to use.)

34.

Astronomers believe that the deposit of lava in the giant mare basins did not happen in one flow but in many different eruptions spanning some time. Indeed, in any one mare, we find a variety of rock ages, typically spanning about 100 million years. The individual lava flows as seen in Hadley Rille by the Apollo 15 astronauts were about 4 m thick. Estimate the average time interval between the beginnings of successive lava flows if the total depth of the lava in the mare is 2 km.

35.

The Moon requires about 1 month (0.08 year) to orbit Earth. Its distance from us is about 400,000 km (0.0027 AU). Use Kepler’s third law, as modified by Newton, to calculate the mass of Earth relative to the Sun.

Order a print copy

As an Amazon Associate we earn from qualifying purchases.


text:
# Conditioning on zero probability event

I have a somewhat trivial question (no homework):

Suppose $X_1, X_2$ are i.i.d. and uniform on $[0,1]$, and the realization of their maximum is $k \in (0,1]$. What is the conditional distribution of the other random variable?

Does that make any sense? In words: given that the realization of the maximum of 2 random variables attains some value, what is the conditional distribution of the other random variable? In the example, is it uniform on $[0,k]$?

Thanks!

-
No, I think you are asking for the distribution of $X_1$ given $max(X_1,...,X_n) = k$, but $X_1$ will be the max with probability $\frac 1 n$. I'm guessing that they are jointly uniform on the surface $max(x_1,...,x_n) = k$, which I think implies an atom at k and otherwise uniform. – mike Sep 11 '12 at 14:35

For two independent $U(0,1)$ random variables, the joint density of the maximum and minimum is uniformly distributed on the triangular region with vertices at $(0,0)$, $(1,0)$ and $(1,1)$. So, yes, given that the maximum has value $k \in (0,1)$, the minimum is uniformly distributed on $(0,k]$. Similarly, given that the minimum has value $\ell \in (0,1)$, the maximum is uniformly distributed on $[\ell, 1)$.
Let $W = \max\{X,Y\}$ and $Z = \min\{X,Y\}$. Then, for $a \geq b$, \begin{align} F_{W,Z}(a,b) &= P\{W \leq a, Z \leq b\}\\ &= P\left(\{W \leq a\}\cap \{Z \leq b\}\right)\\ &= P\left(\{X \leq a, Y \leq b\} \cup \{X \leq b, Y \leq a\}\right)\\ &= P\{X \leq a, Y \leq b\} + P\{X \leq b, Y \leq a\} - P\{X \leq b, Y \leq b\} )\\ &= F_{X,Y}(a,b) + F_{X,Y}(b,a) - F_{X,Y}(b,b). \end{align} If one of the steps puzzles you, think about $P(A\cup B) = P(A) + P(B) - P(A\cap B)$). On the other hand, if $a < b$, then $$F_{W,Z}(a,b) = P\{X \leq a, Y \leq a\} = F_{X,Y}(a,a).$$ For jointly continuous random variables $X$ and $Y$, this gives (upon taking partial derivatives with respect to $a$ and $b$ that $$f_{W,Z}(a,b) = \begin{cases} f_{X,Y}(a,b) + f_{X,Y}(b,a), &\text{if}~ a \geq b,\\ 0, &\text{if}~ a < b. \end{cases}$$ If you think of the joint density $f_{X,Y}$ as a solid sitting on the plane, just fold it over the diagonal line $a=b$ to get the joint density $f_{\max,\min}$ of the maximum and the minimum. For your instance, the unit cube becomes a right triangular prism of height $2$ with vertices at $(0,0)$, $(1,0)$ and $(1,1)$. Thus, the conditional density of one of the two random variables given the value of the other, being just a scaled version of the cross-section of the joint density, is a uniform density.
Could you elaborate on this some more? Specifically, if the maximum of two draws of a continuous random variable is $k$, how does one calculate the conditional probability density function of the other random variable? – Martin Sep 12 '12 at 9:17
Thanks for your detailed elaboration (and sorry for the late reply; I somehow missed your edit). Anyway, I'm not sure whether I fully understand the second line. To me it seems that $F_{W,Z}(a,b) = P\{W \leq a, Z \leq b\} = P\{W\leq a \cap Z \leq b\} = ...$ We can proceed with using $P(A \cap B) = P(A) + P(B) - P(A \cup B)$. For a two-dimensional distribution function $F_{W,Z}(a,b)$, both conditions $W \leq a$ and $Z \leq b$ must hold simultaneously, no? – Martin Sep 24 '12 at 10:02


text:
# Determining Valid DTFT's

Are the following frequency domain signals valid DTFT's (Discrete Time Fourier Transforms)? Answer yes or no, and justify your answer.

a) $X(\omega) = \omega + \pi$

b) $X(\omega) = i + \pi$

c) $X(\omega) = \sin(10\omega)$

d) $X(\omega) = \sin(\omega/10)$

I'm just very unsure as to how to go about this question (what methodology to use). Could anyone possibly point me in the right direction? Thanks!

• Shouldn't a valid DTFT be $2\pi$-periodic? – Matt L. Mar 17 '14 at 8:27
• Maybe consulting a table of DTFTs will give you some ideas as to what typical DTFTs look like. – Dilip Sarwate Mar 17 '14 at 12:42


text:
# Amplitude flatness

When the Fourier transform is used to analyze the frequency content of signals, the signal is often windowed to make the Fourier transform more precise. For similar reasons, the signal segments over which the Fourier transform is used are often selected to overlap. Depending on how the overlap is chosen, the overlapping windows change the amplitude of the signal. This change is different for different points of the signal.

The amplitude flatness of a window is the ratio of the minimum to maximum amplitude that is applied to samples of the signal during the windowing of the signal.

The following graph for example shows six Hann windows of length 50 points that overlap by 40% (by 20 samples). The total amplitude that this window configuration will apply to each sample of the signal varies between 0.69 in the middle between windows and 1 at the peak of each window (the dotted line below; this total amplitude is simply the sum of the window values over the timeline).

Thus, the amplitude flatness of the Hann window at 40% overlap is 0.69. This number will increase as the overlap increases.

## Optimal overlap

With the Hann window specifically, when the overlap is 50%, the amplitude flatness becomes 1. In other words, the total weight applied by the windows to each sample of the signal is the same (it is 1). Incidentally, with this overlap, the difference between the amplitude flatness and the overlap correlation of the Hann window is the largest. The 50% overlap then is sometimes called the "optimal overlap" for the Hann window, in the sense that it gets a maximum amplitude flatness for minimum overlap correlation. The maximum amplitude flatness means that the amplitude of all samples is the same (for the Hann window, almost the same for most other windows) and so no sample is less important in the spectral analysis – no data is lost. The minimum overlap correlation means no unnecessary overlap and computational intensity of the spectral analysis. The "optimal overlap" then is the overlap that achieves a relatively small loss of data for relatively few computations. The type of overlap where the amplitude flatness becomes 1usually does not exist with other windows. The optimal overlap, however, can still be defined in the same way.

## Power flatness

The power flatness of a window is defined in the same way, but instead of summing the values of the overlapping windows, it sums the squared values of the overlapping windows. The power flatness is a measure that is more appropriate for signals that are less similar to sinusoids and more resembling noise.

## Amplitude flatness for common windows

The following is the amplitude flatness of some common windows (at 50% overlap, at 75% overlap, with the window definitions on this site).

 Bartlett-Hann 1.000, 1.000 BlackmanExact BlackmanGeneralized Blackman  α = 0.05  α = 0.20  α = 0.35 0.680, 1.0000.695, 1.000 0.900, 1.0000.600, 1.0000.300, 1.000 Blackman-Harris 0.435, 1.000 Blackman-Nuttall 0.454, 1.000 Bohman 0.637, 0.982 Dolph-Chebychev  ω0 = 0.1  ω0 = 0.2  ω0 = 0.3 0.272, 0.9140.154, 0.5790.127, 0.377 Flat top -0.110, 0.938 Gaussian  σ = 0.3  σ = 0.5  σ = 0.7Approximate confined Gaussian  σ = 0.3  σ = 0.5  σ = 0.7Generalized normal  α = 2  α = 4  α = 6 0.497, 0.9980.936, 0.9730.878, 0.969 0.498, 0.9980.841, 0.9440.720, 0.926 0.936, 0.9730.825, 0.9480.821, 0.900 Hamming 1.000, 1.000 Hann 1.000, 1.000 Hann-Poisson  α = 0.3  α = 0.5  α = 0.7 0.861, 0.9770.779, 0.9600.705, 0.942 Kaiser  α = 0.5  α = 1.0  α = 5.0 0.895, 0.9740.829, 0.9580.691, 0.991 Kaiser-Bessel 0.608, 1.000 Lanczos 0.785, 0.947 Nuttall 0.423, 1.000 Parzen 0.869, 0.966 Planck-taper  ε = 0.2  ε = 0.4   ε = 0.5 0.500, 0.8600.672, 0.9231.000, 1.000 Poisson  α = 0.2  α = 0.5  α = 0.8 0.995, 0.9990.970, 0.9920.925, 0.980 Power of cosine  α = 1.0  α = 2.0  α = 3.0 0.707, 0.9241.000, 1.0000.707, 0.990 Rectangular 1.000, 1.000 Sine 0.707, 0.924 Triangular 1.000, 1.000 Tukey  α = 0.3  α = 0.5  α = 0.7 0.616, 0.9780.500, 1.0000.500, 0.776 Ultraspherical (x0 = 1)  μ = 2  μ = 3  μ = 4 0.684, 0.9140.859, 0.9820.908, 0.992 Welch 0.670, 0.910

### Filtered HTML

• Freelinking helps you easily create HTML links. Links take the form of [[indicator:target|Title]]. By default (no indicator): Click to view a local node.


text:
# Heating water by dropping it from a high height.

by LocalStudent
Tags: dropping, heating, height, water
 P: 18 I was reading through my notes and this idea popped into my head: If you had to drop a liter of water from a certain height, could that potential energy before it's dropped be used to heat the water when it hits the ground? Like you got this equation ΔE = C ΔT Could one use that value of E in this equation Ep = mgh to work out the height that has to be dropped?
 P: 127 This is just common sense (well, to me anyway). Assuming all the energy gets transferred into heating the water and none of that heat gets lost, then yes, all the kinetic energy heats up the water. But this never happens in reality due to the nature of materials and their properties. In real life, some of the energy is given out as sound (which is how you hear the splash), and as energy in the form of heat or other energy forms (can't think of any others). If you drop the water from a bowl into another bowl and none of the water splashes out then some of the heat will be lost into the bowl and then through the bowl and into the air, and so on. You'll lose some energy due to sound. In fact, I imagine most of the energy transfered into the bowl is kinetic energy which then runs through you if you're holding the bowl, or the table if the bowl is resting on a table. Then the kinetic energy the bowl gains immediately transfers into the ground, which is similar to my next point... If you drop water onto the ground then I think most of the energy will be lost in the Earth, i.e. your dropping of the water will heat the Earth up slightly and give it some kinetic energy. This "heating up" or "energy transfer" of water to the Earth is indirect and assumes the Earth's crust is rigid to some extent (I think). One litre of water dropped onto the ground might cause the Earth to heat up by somewhere between 10^-20 to 10^-50 degrees or so. i.e. not very much. However, most of the energy given to the Earth by the water will be kinetic. Similar to the transferred heat, the kinetic energy will dissipate into the Earth, actually moving the Earth slightly. However, since the Earth is very large and spherical, someone on the other side of the Earth will roughly balance out your actions, and even if they don't your effect on the Earth will be very insignificant. This is common sense... For precise calculations you'll need to know things like the material of the ground (and the material's density and the speed of sound through the material), the bowl, the Earth under your house, the height you drop the water from, the amount of water can be found by, and so on...
P: 4,663
 Quote by jewbinson For precise calculations you'll need to know things like the material of the ground (and the material's density and the speed of sound through the material), the bowl, the Earth under your house, the height you drop the water from, the amount of water can be found by, and so on...
Also, the water at the bottom of a waterfall has to have sufficient kinetic energy $\frac{1}{2}mv^2$ to move away from the point of impact, or else a big lake would form at the bottom.

P: 1,484
Heating water by dropping it from a high height.

 Quote by LocalStudent I was reading through my notes and this idea popped into my head: If you had to drop a liter of water from a certain height, could that potential energy before it's dropped be used to heat the water when it hits the ground? Like you got this equation ΔE = C ΔT Could one use that value of E in this equation Ep = mgh to work out the height that has to be dropped?
Basically, what you are considering is conservation of energy, where 1 J of energy is the same whether it be either kinetic, potential, electrical, thermal, ... Due to losses to other forms of energy that are not useful to you when acting out the conversion process as stated in the previous posts, 100% of the potential energy will not be converted to heating up the water.

You can consider 1 litre of water falling into a hydroelectric generator, producing electrical energy which you could then use to heat 1 litre of water in a pot on your stove. C ΔT would be less than the mgh.
P: 127
 Quote by Bob S Also, the water at the bottom of a waterfall has to have sufficient kinetic energy $\frac{1}{2}mv^2$ to move away from the point of impact, or else a big lake would form at the bottom.
Good point on surface tension. I guess that's as deep as we need to go for the purposes of answering OP's question.
 Homework Sci Advisor HW Helper Thanks P: 9,877 You could arrange that most of the energy goes into heating the water. E.g. roll an insulated box of water down a ramp, with the wheels braked by having to drive paddles in the water. But it would be quite hard to detect the warming. A 100m drop would only warm it by about 0.23C, if I've calculated correctly.
 P: 127 Yes but as soon as the water ends up in the tank, it moves the tank and then the Earth. I imagine most of the energy from the KE of the water gets transferred into the KE of the Earth. Think about it. If the Earth were a ball of 10cm radius then most of the KE of the water would transfer into KE of the Earth. You could more accurately model the situation by collision of two objects, rather than modeling the situation as a transfer of heat. Edit: of course the energy dissipates gradually with time. After the first 1/10th second after impact, most of the K.E. of the water will still be in the form K.E. (of the water)
Mentor
P: 11,928
 Quote by jewbinson I imagine most of the energy from the KE of the water gets transferred into the KE of the Earth.
No. While this is true for the momentum (as it is conserved), most of the energy can be used to heat the water. The earth has a really large mass, and E=p^2/(2m), therefore the energy per momentum is really small.
The real limit is the isolation of your system and purely practical - your water needs some containment, this containment will heat up as well, this containment needs some external support which gives the possibility of heat transfer and so on.
 P: 477 Unanticipated, Thomson and Joule met later that year in Chamonix. Joule married Amelia Grimes on 18 August and the couple went on honeymoon. Marital enthusiasm notwithstanding, Joule and Thomson arranged to attempt an experiment a few days later to measure the temperature difference between the top and bottom of the Cascade de Sallanches waterfall, though this subsequently proved impractical. Taken from http://en.wikipedia.org/wiki/James_Prescott_Joule
 PF Gold P: 2,022 James to Amelia Forget the honeymoon and chuck that thermometer over Ames.I'm off to meet Thomo so we can measure the temperature at the top and bottom of a waterfall.

 Related Discussions Introductory Physics Homework 10 Classical Physics 4 Introductory Physics Homework 2 Introductory Physics Homework 4 Introductory Physics Homework 1


text:
## Elementary Geometry for College Students (6th Edition)

We have to prove $c^{2} = a^{2} + b^{2}$ on putting given values $a^{2} + b^{2 }= (p^{2}-q^{2})^{2} +(2pq)^{2}$ $= p^{4}+ q^{4}-2p^{2}q^{2}+4p^{2}p^{2}$ $= p^{4}+ q^{4}+2p^{2}q^{2}$ $=( p^{2}+q^{2})^{2}$ $= c^{2}$ hence proved


text:
# VS 2012 iostream syntax error!

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

## Recommended Posts

I was writing some code and I decided to #include <iostream> in my new file.
But all of the sudden I get this error

c:\program files (x86)\microsoft visual studio 11.0\vc\include\iostream(12): error C2143: syntax error : missing ';' before 'namespace'

what happened?!?!?!? I never touched iostream header file

##### Share on other sites
Maybe you forgot a ';' in the file you include right before iostream.

##### Share on other sites
Indeed I did. Such a weird error message it gave me.

##### Share on other sites
The thing to remember here is that the pre-processor handles the includes, and the compiler only sees the pre-processed source file (called a translation unit). Thus, from the compilers point of view you wrote something like this:
 class SomeClass { // ... } // <-- whoops namespace std { class iostream { // ... } } // ...

• 11
• 11
• 9
• 12
• 10


text:
×
Get Full Access to Fundamentals Of Fluid Mechanics - 8 Edition - Chapter 8.4.2 - Problem 8.53
Get Full Access to Fundamentals Of Fluid Mechanics - 8 Edition - Chapter 8.4.2 - Problem 8.53

×

# Water flows at a rate of 0.040 m3/s in a 0.12-m-diameterpipe that contains a sudden

ISBN: 9781119080701 456

## Solution for problem 8.53 Chapter 8.4.2

Fundamentals of Fluid Mechanics | 8th Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants

Fundamentals of Fluid Mechanics | 8th Edition

4 5 1 405 Reviews
14
4
Problem 8.53

Water flows at a rate of 0.040 m3/s in a 0.12-m-diameterpipe that contains a sudden contraction to a 0.06-m-diameter pipe.Determine the pressure drop across the contraction section. Howmuch of this pressure difference is due to losses and how much isdue to kinetic energy changes?

Step-by-Step Solution:
Step 1 of 3

Tulsa Community College Nutrition Course Syllabus Fall Semester 2016 Course & Section: Bio 1383-301 Nutrition CR Number: 12382 Instructor: Marcia A. Curley, RDN/LD Start and End Dates: Sept 5 – Dec 18, 2016; Mon-Wed-Fri; 8:30 – 9:30am Room Number: SEC Room 8217 Phone: 595-7673—leave messages only E-Mail: Marcia.Curley@tulsacc.edu This is the best way to contact instructor. TO CONTACT THE SCHOOL OFFICE: TO CONTACT ACADEMIC & CAMPUS School of Science and Mathematics SERVICES: Southeast Campus Director: Susan Burlew Office: SEC 8125 Office: SEC 2202 Phone Number: 918-595-7742 Phone: 918-595-7673 CAMPUS SECURITY: 918-595-8888 OTHER COMMUNICATION TOOLS: Outlook e-mail and Blackboard COURSE PREREQUISITES: None TEXTBOOKS AND OTHER SUPPLIES: Nutrition: An Applied Approach, 4 Edition, Thompson and Manore, with the MasteringNutritionandHealth access code. OR, An eText and the MasteringNutritionandHealth access code may be purchased at http://www.pearsonmylabandmastering.com/northamerica/masteringhealthandnutriti on/ Chapter Outlines, Chapter Quizzes, and other course documents are located on both Blackboard and MasteringNutritionandHealth. CATALOG DESCRIPTION: This course is an evaluation of basic composition of nutrients and accessory factors required for adequate human nutrition. Students will learn the application of nutritional principles to the planning of normal and spe

Step 2 of 3

Step 3 of 3

##### ISBN: 9781119080701

The answer to “Water flows at a rate of 0.040 m3/s in a 0.12-m-diameterpipe that contains a sudden contraction to a 0.06-m-diameter pipe.Determine the pressure drop across the contraction section. Howmuch of this pressure difference is due to losses and how much isdue to kinetic energy changes?” is broken down into a number of easy to follow steps, and 44 words. Fundamentals of Fluid Mechanics was written by and is associated to the ISBN: 9781119080701. This full solution covers the following key subjects: . This expansive textbook survival guide covers 112 chapters, and 1357 solutions. Since the solution to 8.53 from 8.4.2 chapter was answered, more than 328 students have viewed the full step-by-step answer. The full step-by-step solution to problem: 8.53 from chapter: 8.4.2 was answered by , our top Science solution expert on 03/16/18, 03:21PM. This textbook survival guide was created for the textbook: Fundamentals of Fluid Mechanics, edition: 8.

## Discover and learn what students are asking

Calculus: Early Transcendental Functions : Product and Quotient Rules and Higher-Order Derivatives
?Using the Product Rule In Exercises 1–6, use the Product Rule to find the derivative of the function. $$h(t)=\sqrt{t}\left(1-t^{2}\right)$$

Statistics: Informed Decisions Using Data : Discrete Random Variables
?In your own words, provide an interpretation of the mean (or expected value) of a discrete random variable.

Statistics: Informed Decisions Using Data : The Normal Approximation to the Binomial Probability Distribution
?In Problems 5–14, a discrete random variable is given. Assume the probability of the random variable will be approximated using the normal distributio

Statistics: Informed Decisions Using Data : Comparing Three or More Means (One-Way Analysis of Variance)
?The acronym ANOVA stands for _________ __ ______.

#### Related chapters

Unlock Textbook Solution