Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Metaconcert
Nov 28, 2010

"And my answer is when there are nine"

hooah posted:

I'm not sure if this would be better here or in a math thread, but I'll start here since it is computer science in nature. In my distributed systems class, we've been talking about safety and liveness. I understand the professor's definition of safety well enough:


However, it seems weird to me to define something by exclusion. The definition in the (apparently) landmark paper,

is a little complex for me to understand all at once, however, but it seems like it might also be definition by exclusion? If that's the only way to define a safety property, that's fine, but I'd like to be able to understand that more complex definition anyways, if anyone could help me out.

mystes is right, and I'll try to unpack it for clarity. This really just comes down to decomposing the notation. We're looking at page 182, the second in that PDF.

We're considering S^omega, the set of infinite traces of program states, and we have the notation sigma_i for the first i states of the trace sigma. A property P is just a subset of S^omega. Alpert and Schneider use "sigma ⊨ P" when the execution trace sigma is in the property P. Read ⊨ as "satisfies" for this purpose.

So, fix a property P. Then, it is a safety property if sigma failing to satisfy P means that I can find a finite prefix, sigma_i, with the properties that all infinite traces with this as a prefix also fail to satisfy P – intuitively, safety properties are precisely those that cannot be recovered from.

I'm not sure I'd characterise it as a definition by exclusion – that suggests to me that you're saying "something isn't a safety property if this holds" (and you could obviously flip that around). It's just that the safety concept is "something bad irrevocably occurs".

Adbot
ADBOT LOVES YOU

hooah
Feb 6, 2006
WTF?
That clarifies it, thanks.

fritz
Jul 26, 2003

Cmake question: I have a bunch of targets that I want to compile with a particular flag, but also a target that I need to compile with a different (mutually exclusive) one. I'd rather not have to add a shitload of set_target_properties(target PROPERTY COMPILE_FLAGS "-flag") lines, and instead do something to remove "-flag" from the one special target, but I'm stumped.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
At what point should you suck it up and start refactoring a horrible mess of a file? I'm dealing with a relatively small 500-line morass that I have to make changes to every couple of months, between bug fixes and feature requests. I've been very hesitant to start cleaning it up because it has absolutely zero tests and it's a very heavily used part of our system. It's also a horrible mess so I'm worried that even with Cover-and-Modify I'm going to cause some parts to fail. Is there any particular strategy that would be helpful in doing this, or am I just going to have to work through this inch by inch?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Metaconcert posted:

I'm not sure I'd characterise it as a definition by exclusion – that suggests to me that you're saying "something isn't a safety property if this holds" (and you could obviously flip that around). It's just that the safety concept is "something bad irrevocably occurs".

When you define a set with an implicit domain of elements, the set theorists will yell at you. When set theorists start yelling at you, you're eventually going to find yourself talking to a set theorist.

Don't talk to set theorists. Always define the domain of your elements.

ufarn
May 30, 2009
Can someone explain why my tidy runs the old, HTML<5 tidy instead of the HTML5 one?

code:
$ tidy -v
HTML Tidy for Mac OS X released on 31 October 2006 - \
Apple Inc. build 15.15

$ which tidy
/usr/local/bin/tidy

$ /usr/local/bin/tidy -v
HTML Tidy for HTML5 (experimental) for Mac OS X https:\
//github.com/w3c/tidy-html5/tree/c63cc39

$ echo $PATH
/opt/local/bin:\
/opt/local/sbin:\
/Users/me/.rbenv/shims:\
/Users/me/.rbenv/bin:\
/Users/me/.rvm/gems/ruby-2.1.0/bin:\
/Users/me/.rvm/gems/ruby-2.1.0@global/bin:\
/Users/me/.rvm/rubies/ruby-2.1.0/bin:\
/usr/local/bin:\
/usr/local/bin:\
/usr/bin:\
/bin:\
/usr/sbin:\
/sbin:\
/usr/local/git/bin:\
/usr/local/MacGPG2/bin:\
/Users/me/.rvm/bin:\
/Users/me/Downloads/go/bin:\
/Users/me/go/bin

$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

aerique
Jul 16, 2008

ufarn posted:

Can someone explain why my tidy runs the old, HTML<5 tidy instead of the HTML5 one?

No but why is your $PATH printed with backslashes like that? Mine is printed on one line when I do "echo $PATH". Maybe the issue can be found there?

(I know what the backslashes do in scripts, I just cannot recall ever having them seen printed out like that when echo'ing an environment variable.)

ufarn
May 30, 2009
I just put them there to indicate that I had put each entry on their own line rather than crash the tables of the thread. :)

The output is one line.

ufarn
May 30, 2009
Never mind, I fixed it; I'm an idiot who didn't re-start his terminal.

Polio Vax Scene
Apr 5, 2009



Any reason why a user@domain login would be required for one site but domain\user for another? Some config somewhere? AD being lovely?

JawKnee
Mar 24, 2007





You'll take the ride to leave this town along that yellow line
sounds like it's asking for old win 2000 credentials for some reason?

raej
Sep 25, 2003

"Being drunk is the worst feeling of all. Except for all those other feelings."
Is there any easy way to set up a find and replace against a file using a set of rules?

An example would be source file:
code:
(Hello)
&#40;Foo&#41;
…bar
Appleton Brewing\/Adler Brau
St. James\u2019s Gate
and the rules would be
code:
&#40; -> (
&#40; -> )
… -> ...
\/ -> /
\u2019 -> '
It's not just for html codes, but a wide variety of crap data that needs cleaning up. Right now I'm searching for "&#" finding an example, running a find/replace on it, and repeat. Ideally, I'd like to add a rule to the ruleset that way when I receive a new file, I can apply all of the same rules.

salisbury shake
Dec 27, 2011

raej posted:

Is there any easy way to set up a find and replace against a file using a set of rules?

An example would be source file:
code:
(Hello)
&#40;Foo&#41;
…bar
Appleton Brewing\/Adler Brau
St. James\u2019s Gate
and the rules would be
code:
&#40; -> (
&#40; -> )
… -> ...
\/ -> /
\u2019 -> '
It's not just for html codes, but a wide variety of crap data that needs cleaning up. Right now I'm searching for "&#" finding an example, running a find/replace on it, and repeat. Ideally, I'd like to add a rule to the ruleset that way when I receive a new file, I can apply all of the same rules.

(g)sed (syntax differs if you're on a Mac or a BSD flavor) and a regex?
http://robots.thoughtbot.com/sed-102-replace-in-place

wolffenstein
Aug 2, 2002
 
Pork Pro
A client wants url.com/foo/bar to exist, even if foo is not an actual directory. if a visitor went to url.com/foo/bar, the URL would stay the same, but the server would intepret it to be url.com/biz/bar while keeping a reference to whatever foo is for various reasons. I know mod_rewrite is the answer here, but that's all I know. Any suggestions or examples that implement such a thing?

No Gravitas
Jun 12, 2013

by FactsAreUseless
I need the fastest possible random number generator, to be written in C. Ideally two or three x86 instructions. Every cycle matters.

Good news: The output quality can be anything besides complete poo poo, needs only be numbers from the range 1:32 but each number must be hit at least once in the period.

Any ideas? Xorshift looks decent, but can we do faster?

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

No Gravitas posted:

I need the fastest possible random number generator, to be written in C. Ideally two or three x86 instructions. Every cycle matters.

Good news: The output quality can be anything besides complete poo poo, needs only be numbers from the range 1:32 but each number must be hit at least once in the period.

Any ideas? Xorshift looks decent, but can we do faster?

You're going to have to give us some idea why you have these strange requirements first, and "anything besides complete poo poo" is not sufficient to figure out what characteristics you need the output to have. Also, requiring that every number be hit at least once runs completely counter to what an RNG is usually supposed to do, and makes me think you aren't looking for randomness at all.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

No Gravitas posted:

I need the fastest possible random number generator, to be written in C. Ideally two or three x86 instructions. Every cycle matters.

Good news: The output quality can be anything besides complete poo poo, needs only be numbers from the range 1:32 but each number must be hit at least once in the period.

Any ideas? Xorshift looks decent, but can we do faster?

If you don't care about periodicity, just do what Doom did - make a table of 256 numbers, fill it randomly with numbers in your range once at startup, and have rand just return table[i++] where i is a uint8.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
code:
short random;
_rdrand16_step(&random);
return (random & 31) + 1
Assuming you trust Intel, of course. Even if you don't, the hardware generator is at least going to pretend that's it's sufficiently random, which is good enough for any non-cryptographic needs. And it easily fits in your "two or three x86 instructions" target. Speed, maybe not so much though.

Or shuffle an array, and just return values from it in a loop. If you're actually in a situation where "every cycle matters", startup time is mostly irrelevant.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

When I read the requirement to hit every number, I thought of a LFSR, which might do what you want if you find a set of taps that make a pattern you like. I think it is going to be more than 3 instructions, though. The precomputed table seems like the best idea unless you are also memory constrained. On a typical PC, you could make a huge table of precomputed 32-number sets in random orders to avoid people noticing repeats.

JawnV6
Jul 4, 2004

So hot ...

Jabor posted:

And it easily fits in your "two or three x86 instructions" target. Speed, maybe not so much though.

Yeah I'm not following why "x86 instructions" is being used as a metric.

No Gravitas
Jun 12, 2013

by FactsAreUseless

Blotto Skorzany posted:

If you don't care about periodicity, just do what Doom did - make a table of 256 numbers, fill it randomly with numbers in your range once at startup, and have rand just return table[i++] where i is a uint8.

We have a winner here!

JawnV6 posted:

Yeah I'm not following why "x86 instructions" is being used as a metric.

My 4am brain using shorthand.

Thanks guys.

1337JiveTurkey
Feb 17, 2005

If each number needs to be hit at least once in the period, you're looking for a permutation so that narrows down the methods of generating the result. Those boil down to shuffling the possible numbers, going through the set and then shuffling again. Shuffling is going to be more expensive than generating one number but you're amortizing the cost over 32 random numbers.

Since the numbers fit in one byte and there's no advantage to packing them further, the most logical representation is an array of 32 bytes. Luckily that also happens to be the width of a ymm register if you're using an x86 with AVX support. Failing that it's a couple of xmm registers. What that gives us is the oh-so-handy PSHUFB instruction which rearranges the bytes of an xmm/ymm register based on the contents of a second xmm/ymm register. See http://www.felixcloutier.com/x86/PSHUFB.html for details.

So long as each byte in the second register is non-negative and different mod 32, then the operation will perform a permutation rather than copying some of the values more than once or zeroing out bytes. In other words if the second register is a permutation on the numbers 0-31 then it permutes the values of the first register. So for the bare minimum, create two arrays with two random shuffles using whatever expensive operations you please at the beginning of the program. Then each time you loop through the first array, PSHUFB it with the second to generate a new permutation.

That'll have ugly issues like orbits with a period of 1 so an alternative is to make more than one array (say three) and pick one of the three arrays using a PRNG and PSHUFB using that. If you imagine a Rubik's cube with numbers written on the faces instead of colors, it's like twisting it in one of the dimensions, then reading off the numbers from the faces.

1337JiveTurkey
Feb 17, 2005

JawnV6 posted:

Yeah I'm not following why "x86 instructions" is being used as a metric.

So we can search through the instruction set and come up with some sort of deranged :v: solution involving group theory, permutations and assembly.

hooah
Feb 6, 2006
WTF?
For my distributed systems class, we're supposed to do some research on a problem with the idea that our work would be publishable if there were no existing literature. That's all well and good, but my partner and I don't really have any idea where to start; I feel like we're not familiar enough with the field to even know what might be interesting and feasible. We asked the professor and he was sort of coy about it, saying that he didn't want to give us ideas since he wanted us to come up with something he hadn't. How can I go about finding out what sorts of topics we should consider?

nielsm
Jun 1, 2009



Consider some practical uses that can be relevant for you, which involve multiple devices working together.

It's definitely a solved problem, but for instance multiple integrated speaker/amplifier/media playback devices playing in perfect sync. You could assume that every device has a local copy of the media, but they need to discover each other, their capabilities, and negotiate sync.
I think that would qualify as a distributed system.

Xerophyte
Mar 17, 2008

This space intentionally left blank

hooah posted:

For my distributed systems class, we're supposed to do some research on a problem with the idea that our work would be publishable if there were no existing literature. That's all well and good, but my partner and I don't really have any idea where to start; I feel like we're not familiar enough with the field to even know what might be interesting and feasible. We asked the professor and he was sort of coy about it, saying that he didn't want to give us ideas since he wanted us to come up with something he hadn't. How can I go about finding out what sorts of topics we should consider?

Not to be rude here, but ... have you considered google? Or wikipedia? I mean, asking the internet is also research, but it seems like there are easier ways.

For some kind of example, one of the neater distributed system I know of is actually in finance. It consists of a domain-specific language for describing financial offerings and futures that can be sent off to a server farm to be simulated and evaluated on-demand. For instance, a client of the bank would say something like "I would like an option to buy either X units of Apple stock or 20 units of Google stock on April the 15th at a fixed price set now, what would that cost?" The bank rep can write down that specific and arbitrarily complicated transaction in a formal language, which is then sent out to a server farm that spawns a few million market simulations (In Haskell! See, it's actually used for something...) in order to derive a price for that specific and unique service in a few seconds.

If in doubt, you can always pick your favorite method of transportation and extrapolate. How would a distributed, ad hoc cars & stop signal network function? How would you revolutionize the already exciting world of model trains?

Polio Vax Scene
Apr 5, 2009



Manslaughter posted:

Any reason why a user@domain login would be required for one site but domain\user for another? Some config somewhere? AD being lovely?

So we solved this by keeping the domain in the username. Like if you're setting up a NetworkCredentials in c# you can pass username, password, domain, well we ignored the domain and just used domain\username for the username.

Subyng
May 4, 2013
Not sure if there is a better thread to ask this, but for anyone familiar with MATLAB:

How can I go about identifying the peaks of a function?

Linear Zoetrope
Nov 28, 2011

A hero must cook

Subyng posted:

Not sure if there is a better thread to ask this, but for anyone familiar with MATLAB:

How can I go about identifying the peaks of a function?

Do you mean the maxima? Because that's kind of an open problem, unless it's a very well behaved convex function. I'm not too familiar with Matlab in specific, but they do appear to have an optimization package.

Linear Zoetrope fucked around with this message at 05:31 on Feb 11, 2015

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If it's a continuous, differentiable function, you can take the derivative and look for zeros, then determine which of those are local maxima. The actual maximum value of the function is going to be either a local maximum or the limit as x tends to either infinity.

Of course, there could be an infinite number of local maxima...

Linear Zoetrope
Nov 28, 2011

A hero must cook
Right, I should have said "unless you can take the derivative", but in that case it's probably better to either do it by hand or go to something like Sage, Mathematica, or Sympy. Matlab does appear to have a symbolic computation library, but it costs money.

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

Jsor posted:

Matlab does appear to have a symbolic computation library[...]

But it's absolute garbage compared to all four of those options...

Subyng
May 4, 2013
Using MATLAB's signal processing toolbox, I was able to use the findpeaks function. However that only works for functions that are numerically defined (ie findpeaks takes in a vector as an argument) and I'm using symbolic functions right now.

I suppose I could try taking the derivative, I also considered trying to turn the symbolic function into a vector (still trying to figure out how to do this) so I could use findpeaks on it.

Linear Zoetrope
Nov 28, 2011

A hero must cook
You probably want the Numeric Computing thread, but at its simplest "turning the symbolic function into a vector" is basically just going to be sampling it at intervals. Selecting a good interval is tricky. You're traversing well covered ground trying to figure out how to get the maxima of a function. Helping you is very dependent on exactly what type of function you're working with, otherwise we can only give very general answers like "take a derivative" or "try using convex or constraint-based optimization libraries"

The simplest thing you can do if you need to do this numerically and not symbolically is gradient ascent (hill climbing), which has been implemented many times, but it will only find you a single local maximum.

Linear Zoetrope fucked around with this message at 07:05 on Feb 11, 2015

Subyng
May 4, 2013
Thanks for the link to that thread and for the responses.

To be more specific what I'm trying to do is identify the frequency of a "messy" function with some small minima/maxima and some large ones. And at this point I've gotten my function into vector form so I think my next step will be to filter it to eliminate the smaller peaks and leave only the large ones?

aerique
Jul 16, 2008

Subyng posted:

To be more specific what I'm trying to do is identify the frequency of a "messy" function with some small minima/maxima and some large ones. And at this point I've gotten my function into vector form so I think my next step will be to filter it to eliminate the smaller peaks and leave only the large ones?

I'm totally not a maths guy but FWIW:



When I was still into EVE Online market trading I also needed to detect peaks and what I did was compare the the 20d average to the 5d average. The 5d was 'peakier' than the 20d graph and I grabbed the maximum of each peak above the 20d graph and the minimum of each valley below the 20d graph.

It's been a while but if the above graph looks good enough for you I can look up the specifics and perhaps post some code (which might be horrible, I can't recall).

Adverbially
Sep 17, 2013

Soiled Meat
If I want to write a linter similar to jscs, csslint, and semantic linters for npm, is there a preferred way of doing that, or do people tend to go about it in their own ways?

I just don't want to throw myself into it only to realize there was a much simpler, proven way to do it that would have saved me days and weeks.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
For what language? If you can piggy back some existing tooling, for example something that turns the plain text into an abstract syntax tree, you'll save yourself a lot of effort in terms of interpreting the code.

Maluco Marinero fucked around with this message at 13:01 on Feb 11, 2015

fritz
Jul 26, 2003

n/m solved it well enough

fritz fucked around with this message at 17:09 on Feb 11, 2015

Adbot
ADBOT LOVES YOU

Subyng
May 4, 2013

aerique posted:

I'm totally not a maths guy but FWIW:



When I was still into EVE Online market trading I also needed to detect peaks and what I did was compare the the 20d average to the 5d average. The 5d was 'peakier' than the 20d graph and I grabbed the maximum of each peak above the 20d graph and the minimum of each valley below the 20d graph.

It's been a while but if the above graph looks good enough for you I can look up the specifics and perhaps post some code (which might be horrible, I can't recall).

I'm not a maths dude either. What's 20d/5d average?

e: 20-day/5-day average you mean?

Subyng fucked around with this message at 18:29 on Feb 11, 2015

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply