Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

BrowserUk

by BrowserUk (Pope)
on Jun 04, 2002 at 18:12 UTC ( #171588=user: print w/ replies, xml ) Need Help??


Posts by BrowserUk
Pronouncible TLA's? in Seekers of Perl Wisdom
6 direct replies — Read more / Contribute
by BrowserUk
on Apr 28, 2016 at 17:36

    Is there a metric by which the pronounceability of of a combination of letters can be judged? And is there anything that Perl can do to measure it?

    Pronounceable by whom is a variable, xkz might be pronounceable in Czech or Polish; but since I am chronically monoligual; let's stick to 'by native English speakers'.

    That still leaves plenty of scope for sounds made by the native English speakers from some parts of the world that are totally unreproducible by those from others; but its a place to start.

    To be useful, the pronunciations would need to be distinct; and changing the pronunciation of known word, to enable a less common spelling to (re)use that sound defeats the purpose.

    Ie. Deciding to pronounce 'are':ah-rey, so that 'aar' can be pronounced as ah doesn't work.

    Also, I think that the Dutch could intone a difference between 'six' and 'syx' and hear the difference; but I'm pretty sure I can't do either.

    For the 'Perl content' and 'what have you got' criteria, this produces all 17,576 3-letter combinations. Can you add code to eliminate the unpronounceable?:

    use Algorithm::Combinatorics qw[ variations_with_repetition ];; $i = variations_with_repetition( [ 'a'..'z' ], 3 );; $" = ''; print "@$_" while $_ = $i->next;; aaa aab aac aad ...

    I thought perhaps that any combination that contained a vowel or y might work:

    $" = ''; $_ = join( '', @$_ ), m[[aeiouy]] and print while $_ = $i->ne +xt;;

    But I don't think any of these would qualify: xxa xxe xxi xxo xxu xxy xza xze xzi xzo xzu xzy.

    And there is a distinguish-ability problem with things like gga gja jga & jja. Again the Dutch might get something like kh-yah & ye-gah for the middle two, but I probably wouldn't be able to pronounce either to their satisfaction.

    The application, albeit a light-hearted speculation rather than yet a serious pursuit, is the Huffman encoded (I really just mean 'short' here) naming of a few (3-7?) thousand items (variables; values) in a phonetically pronounceable way, for clarity of verbal communication, and memorability.

    And why not just use numbers? The hope is that at least some of the more common items could be named in some vaguely mnemonic way; to aid in the second of the above goals in a way that "Item 237' never will.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
The process cannot access the file because it is being used by another process?[Problem disappeared!] in Seekers of Perl Wisdom
6 direct replies — Read more / Contribute
by BrowserUk
on Apr 27, 2016 at 17:44

    Update!

    Before I posted, I tried a bunch of things and ran it at least a dozen times getting the exact same failure. I the cut the script of the top of the data, renamed the file .dat and stuck the script into a new file of the old name. I changed <DATA> to <> and supplied the data file on the command line and it worked first time.

    I've just recreated the all in one script; and now it runs perfectly. I have no explanation for the error or the cure; but I suspect 1nickt called it.

    Thanks for your help guys.


    I'm getting this error when I try to run the following code:

    C:\Motor>parseAns.pl The process cannot access the file because it is being used by another + process.

    Another process is accessing the DATA pseudo-handle?

    The data is large 2.4 million, but I'm sure I've processed much larger datasets from <DATA> before; and I've commented out the storing of the data to the array, so it isn't running out of memory. Cluebats anyone?

    #! perl -slw use strict; my @data; my $i = 0; #$data[ $i++ ] = [ split ' ' ] ++$i while <DATA>; print $i; __DATA__ -69.282032302755084 40.000000000000014 0 -1 -69.123493781255831 39.908467741935496 -1.4443382565142906e-006 -1 -68.748013135538145 40.911009397420145 0 -1 -68.964955259756593 39.816935483870985 -2.990721348858345e-006 -1 -68.370049396495517 40.298149116372635 -6.3944096502804299e-006 -1 -68.202015544462682 41.814890597403163 0 -1 ... 2.4 million lines omitted.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Contour mapping? in Seekers of Perl Wisdom
5 direct replies — Read more / Contribute
by BrowserUk
on Apr 27, 2016 at 15:42

    I have a (large) dataset that consists of and X,Y coordinate pair and a real number (0.0 -> 3.0) representing an attribute, call it a height, and I want plot contour lines connecting points of similar heights.

    Any thoughts or pointers on how to start?

    The data looks like this, but there is not enough (of the 2.4 millions points) here to do anything useful with:

    -69.282032302755084 40.000000000000014 0 -69.123493781255831 39.908467741935496 -1.4443382565142906e-006 -68.748013135538145 40.911009397420145 0 -68.964955259756593 39.816935483870985 -2.990721348858345e-006 -68.370049396495517 40.298149116372635 -6.3944096502804299e-006 -68.202015544462682 41.814890597403163 0 -67.658222977894795 40.432681542784742 -1.1025156665695599e-005 -68.80641673825734 39.725403225806467 -4.7264009945253546e-006 -68.647878216758102 39.633870967741949 -6.7019561401411285e-006 -68.489339695258849 39.542338709677438 -8.9173860088063258e-006 -67.970337613779577 39.892083135646438 -1.3463345566431798e-005 -67.644134662322315 42.711486110711832 0 -66.168460737542475 40.816251240724036 -7.7940171180040021e-006 -66.403424513471577 39.677023978360658 -3.2568451287380103e-005 -67.417482219894339 39.751269670319942 -2.2905275056155327e-005 -68.330801173759596 39.45080645161292 -1.132337127325882e-005 -68.172262652260343 39.359274193548401 -1.4263293915609116e-005 -68.013724130761105 39.267741935483883 -1.7815964293169953e-005 -67.074467692415936 43.600639717542869 0 -65.320216546227712 42.631856022495803 -2.5121171527202102e-005 -64.452638549546535 41.120575875191086 4.5678927263972832e-005 -65.2313333965173 39.144242118219182 -1.7497211352324817e-005 -66.154489394499308 39.00980515543462 -6.3610401599566315e-005 -66.84644386289331 39.27582098868416 -4.1213274977535648e-005 -67.855185609261852 39.176209677419372 -2.1907142377233984e-005 -67.696647087762614 39.084677419354854 -2.6613602927452167e-005 -67.538108566263361 38.993145161290336 -3.1880809503868505e-005 -66.493113891610946 44.482196494745864 0 -63.455014677037695 42.328563579380834 -6.7791580746250923e-005 -63.743298666018838 43.86849215765006 -0.00012339986352570304 -63.010618308126652 40.142191039199616 0.00028666487947822099 -63.74890107758462 38.983319224147046 0.00022091344000053716 -62.272335538668685 41.301062854252187 9.8592328446381225e-005 ...

    I also have another set of data that connects the points as triangles. The numbers are indexes into the dataset above, and the indexes are "given in counter-clockwise direction". Whether that means that the first node of each triangle is the right-most I'm not sure, but otherwise I'm not quite sure why that is specified, beyond completeness.

    My thoughts so far are:

    • First, find the lowest and highest 'heights'; and the x/y bounds.
    • The establish the period of the contours: either divide the range into an arbitrary subdivisions; or some equally arbitrary numerical subdivisions 0.0-0.999999, 0.1-0.199999, 0.2->0,29999 etc.
    • Then ... I'm kinda blank at the moment.

    Note: I'm not actually wanting to plot the mesh and contours at this point; though that's a possibility later. What I need to determine is the angle, relative to the origin, of each of the (short) lines between nodes that make up each contour. That's easy once I have the set of points and their order than make up each contour.

    Some contours will be partial -- starting and/or ending at the edge of the data space.

    I'm certainly not expecting code; but just clues on how to begin. Thanks.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
[OT] A prediction. in Meditations
8 direct replies — Read more / Contribute
by BrowserUk
on Apr 06, 2016 at 22:32

    The speed of light is not constant!
    It is, in fact, accelerating, year by year, decade by decade, century by century; but on astronomical time-scales.

    It may take ten years; it make take one hundred. Or even a thousand.

    But, it will eventually be proved that the speed of light is not a constant. (And this has nothing to do with frames of reference; or General, or Special Relativity.)

    If you set up a series of light beams, every cm(inch) across a road, 1 km(mile) long; and measured the (instantaneous) speed of a car starting from standstill and accelerating along that road to 100k(m)ph; and then viewed the data from the last 100cm(inches); it would appear (within the bounds of accuracy available) that the speed of the car was some fixed(constant) value.

    Now consider that we (human kind) have only been attempting to measure the speed of light for 300 or 400 years -- depending upon your references -- and that light has been traveling for ~13.something billion years(*); and maybe the above analogy will make sense.

    Now think about the consequences, if that is true.

    Distances -- and thus times -- of astronomical points and events -- including the age of the Universe/time since the big bang -- are no longer reliable.

    The calculations that "prove" that the Universe is expanding and will continue to expand until heat death; are unreliable. Unproven.

    The mass calculations that indicate the existence of both Dark Matter and Dark Energy are moot.

    The vast majority of current astrophysical and particle physical research are looking in the wrong place, for the wrong thing.

    Wanna join the 21st Century's version of the flat Earth society?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
How would you code this? in Seekers of Perl Wisdom
6 direct replies — Read more / Contribute
by BrowserUk
on Apr 06, 2016 at 14:48

    The problem I'm dealing with is the removal of test equipment artifacts from experimentally derived datasets. In layman's terms, the sensing circuit has a tendency to oscillate a little occasionally; which introduces inflections into the data which must be removed before the data can be used for the next part of the processing which requires monotonic data.

    This is a case where a picture is worth a thousand words: http://oi63.tinypic.com/2z72xbr.jpg. The blue is (a small subset of) the raw data and the red is the desired output.

    This code performs the cleanup. (It runs as a pipe filter, and I've adapted it to use __DATA__ for the small subset shown in the graphic for posting purposes.):

    The basic mechanism is to compare the points as successive pairs and look for a negative slope. When a negative slope is found, *both* points are removed from the dataset.

    The complication is that pairwise comparisons have to continue with the next point against the *previous* unremoved point.

    To (I hope) clarify, in the following:

    H G F E D C B A
    • Point A is passed through
    • Points A & B are compared, positive slope: pass B through.
    • Points B & C are compared, positive slope: pass C through.
    • Points C & D are compared, negative slope: block D and remove C.
    • Points B & E are compared, positive slope: pass E through.
    • Points E & F are compared, negative slope: block F and remove E.
    • Points B & G are compared, positive slope: pass G through.
    • Points G & H are compared, positive slope: pass H throught.

    Resultant dataset: A, B, G, H.

    The above code works; but is there a better way of coding it?

    I'm not going to define "better"; I'd simply like to see a range of alternative codings.

    (Please note: this is not about filtering or smoothing or interpolating the data; just removing spurious values.)

    The output from the sample code:


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
It's so easy to become complacent. in Meditations
3 direct replies — Read more / Contribute
by BrowserUk
on Feb 22, 2016 at 11:03

    For the last few weeks I've been forced into using Lua, because it is the embedded language in the simulation software I'm using.

    I've had brief causes to use it a few times in the past for simple things; but this time I'm having to make far more extensive forays into it. And it has highlighted just how spoilt I've been using Perl for most of my scripting needs for the last 13 years. Even just the trivial things, like the fact that Perl detects and reports syntax and even some semantic errors, up front when the script is first loaded.

    Having just had a Lua script run for almost 5 days before trapping out at the eleventh hour with an utterly trivial and inconsequential typo, I've once again had my respect for Perl (5) renewed by the experience.

    Which makes the current state of the community all the more depressing.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
[OT] Forces. in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by BrowserUk
on Feb 14, 2016 at 04:43

    I'm trying to solve a problem to do with forces as represented by this freebody diagram.

    The large circle represents a body, that is free to rotate about axis A, that has a complex of external, non-contact forces acting upon it represented by the wiggly red arrows. The composite of these forces is calculated (by a library call using Stress Tensor integration), and the combined result is returned as (ex.) X: 335.123 N Y: -74.2858 N.

    In addition to the body being free to rotate about A, the short (10 units) link arm it is attached to can rotate about the axis B.

    The problem is to work out what position the combined mechanism will end up in as a result of the forces acting upon it.

    For now, I'm ignoring the possibility that forces acting may change as the assembly rotates. This is part of a complex simulation and the basic idea is that from a known starting point, I use the library to calculate the net force acting at some instance in time; from that work out the position the assembly moves to; adjust the model to reflect that movement, and then re-calculate the stress tensor integration for the next instance. If the time-step is small enough and the iteration count high enough, then it should give a reasonable approximation of the affects of the forces over time.

    In keeping with the "what have you got so far" ethic, the second (lower) state diagram in the image shows what I think will happen.

    • The short link A-B will rotate anticlockwise about B by an angle (to the horizontal) represented by the purple line that connects B to a point F, which is a point on the periphery of the circle through which the resultant of the X/Y force acts through A in the original position.
    • The body will rotate clockwise around A such that the position of the point F on its periphery will end up in the same place(ish) as it was in before the movement takes place.

    I realise that the position of F in the resultant is slight displaced from its original position in space, but as shown, the angles involved are greatly exaggerated. The actual actual angles will be very small at each iteration, so the inaccuracy at each step will also be small. In the end, it is the position of the body in space that is important, not its rotation, nor the exact position of any point on it.

    I'm fairly sure I can handle coding the trig to resolve the two rotations; what I'm looking for here is any kind of argument for or against my assessment of what will happen?

    My thanks to anyone with enough math to tackle the problem and bored enough to bother :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Context, pedantry and appropriate response. in Meditations
6 direct replies — Read more / Contribute
by BrowserUk
on Jan 02, 2016 at 05:51

    Nit-picking pedantry is the bane of productive discourse.

    A not uncommon question in life is: "How much do you weigh"? To which we generally respond with something like: "nn pounds" or "nn kilos".

    Of course, if we last weighed ourselves naked having just stepped out of the shower, and we are currently wearing a full set of skiing gear; or if a holiday weekend or half a year has intervened, then our responses may be slightly or even wildly inaccurate. Which may or may not be okay depending on who is asking and why; but we generally know how much thought we should give to the accuracy and qualification of our responses from the context of the question.

    Of course, we don't really "weigh" what we weigh. We have a mass of a certain number of Newtons that only becomes a weight in the presence of a particular value of gravity.

    Ie. we 'weigh' differently on the surface of the Earth than we would on the Moon or in the ISS. And we would 'weigh' differently again if we were bridge of the Enterprise at Warp factor 10 and the inertial stabilizers failed.

    But no one ever responds to the target question with "nn Newtons"; or qualifies their "nn pounds/kilos" with "whilst naked, at a distance of nn miles/meters from the center of the Earth, whilst traveling at sub-relativistic speeds, and after a week or more of nominally average calorific intake and expenditure".

    And thank Dog they don't! Without we tailor and truncate our answers to the contexts in which the questions are asked, life would become quagmired in a treacle of inferable verbiage. And intolerable.

    Which is why mealy-mouthed, oneupmanship, pedantry posts like this deserve the response it got.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Mixed Unicode and ANSI string comparisons? in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by BrowserUk
on Dec 14, 2015 at 17:04

    What happens if you pass a list containing a mix of Unicode and non-Unicode scalars to sort?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Tri state string compare? (Solved! see update2) in Seekers of Perl Wisdom
3 direct replies — Read more / Contribute
by BrowserUk
on Dec 13, 2015 at 13:22

    I have two strings to compare.

    1. String 1 consists of a mix of 3 characters, a, b & c. Eg. AABCBAABCCCCAB
    2. String 2 consists of a mix pf 2 characters; a & b.   Eg. AABABAABABABAB

    I need to determine if string 2 contains As everywhere there is an A in string 1; and Bs wherever string 1 contains Bs. I don't care what string 2 contains where string 1 contains Cs.

    All I need is a boolean result whether string 2 'matches' string 1. (The above example is a 'match'.)

    If it helps, the choice of the 3 characters used is open to change.

    The strings can be quite long and there are lots of string 2s to be compared against each string 1; so I'd rather avoid a byte by byte (at the Perl level) comparison.

    I think it ought to be possible to get my boolean using some combination of byte-wise boolean string ops; but I haven't hit on which?

    Update: The above two samples match because:

    AABCBAABCCCCAB AABABAABABABAB AAB BAAB AB ## I don't care what's in string 2 where there is a C +in string 1.

    Update2: Solution

    Solved it with:

    $ab = "AABABAABABABAB";; $abmatch = "AABABAABABABAB";; print +(( $abc & $abmatch ) eq $abmatch) ? 'yes' : 'no';; yes $abnomatch = "ABBABAABABABAB";; print +(( $abc & $abnomatch ) eq $abmatch) ? 'yes' : 'no';; no

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
    In the absence of evidence, opinion is indistinguishable from prejudice.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2016-05-05 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?