Wikipedia:Reference desk/Archives/Computing/2011 July 7
Computing desk | ||
---|---|---|
< July 6 | << Jun | July | Aug >> | July 8 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
July 7
[edit]how to make Perl more random
[edit]I was trying to come up with 10 random numbers, using Perl, and absentmindedly just wrote perl -we 'for (1..10){print int rand 10000, " "} but I got the result: 21211 68448 21458 58026 25746 90499 21777 93404 86137 93633! This doesn't seem very "random" to me at all, as it doesn't have a single small number in it!
I would like a more random assortment of numbers, more like, 5, 23423, 12312, 342, 42, 1, 53, 191, 3423, 634234. How could I tweak my code to be more "random"? (and less random). Thanks... 188.28.246.47 (talk) 01:51, 7 July 2011 (UTC)
- If you select at random a number between 0 and 99999, or whatever the limits for Perl are, the chances of it being less than 10 are extremely remote - think about it. 01:59, 7 July 2011 (UTC)
- (e/c)
- The list of numbers that you want to see is very unusual. The majority of the numbers are under 500! The odds against that happening at random are astronomical.
- What you need to do is think about the distribution of numbers you WANT to see.
- If you don't need a smooth distribution, perhaps you could simply rig it so fifty percent of the time it gives you a number between one and a million, and the other fifty percent of the time it gives you a number between one and 100. APL (talk) 02:03, 7 July 2011 (UTC)
- A better way to match the human intuition for randomness would be to generate a random number in the range 0 to 10 (call it X), then output 10X, rounded down to the nearest integer. Looie496 (talk) 02:08, 7 July 2011 (UTC)
- Except the OP wants 10X to be in the range between 0 and 10000, so
X should be between 0 and 100. --COVIZAPIBETEFOKY (talk) 02:16, 7 July 2011 (UTC)- Er, sorry, X should be between 0 and log(10000) = 4. --COVIZAPIBETEFOKY (talk) 02:17, 7 July 2011 (UTC)
- The Perl program
for (1..10){print int 10 ** rand 5, " "}
printed339 35 22574 11 21 5758 590 4 2516 9
in my test, which seems like roughly what the OP wants. This is a log-uniform distribution, as opposed to the uniform distribution produced byrand
by itself. There's nothing strange about it. Numbers generated in this way obey Benford's law, and so do a lot of numbers in the real world. Nature likes log-uniform (or at least log-normal) distributions. -- BenRG (talk) 06:29, 7 July 2011 (UTC)- Wow, that's... a pretty satisfying explanation, contrary to what cracked has to say.
- Although that suggests that the perturbations which impact election results in Iran must be predominantly multiplicative, to produce a log-normal distribution. Is there any explanation as to why that might be? --COVIZAPIBETEFOKY (talk) 11:26, 7 July 2011 (UTC)
- The Perl program
- Er, sorry, X should be between 0 and log(10000) = 4. --COVIZAPIBETEFOKY (talk) 02:17, 7 July 2011 (UTC)
- Except the OP wants 10X to be in the range between 0 and 10000, so
- A better way to match the human intuition for randomness would be to generate a random number in the range 0 to 10 (call it X), then output 10X, rounded down to the nearest integer. Looie496 (talk) 02:08, 7 July 2011 (UTC)
- If you want a headache, you can find many papers on Google Scholar which argue about which is really more natural, log-normal distributions or Zipf-Mandlebrot distributions. I found a lot when I was looking for some good tricks to generate a pink distribution random number generator. -- kainaw™ 02:43, 8 July 2011 (UTC)
Focus follows mouse on a mac: how to do this?
[edit]Hi. Title says it all really. macosx 10.6.7. Googling gave nothing useful. I can't believe it's not possible. Can anyone advise, please? Robinh (talk) 02:41, 7 July 2011 (UTC)
- I vaguely remember that there is a hack, but can't remember the details. I prefer sloppy focus under X11, but any kind of FFM is a mixed blessing under Aqua, since the global menu bar also reflects the application that has the focus (and, I think, it auto-raises windows). But see [1]--Stephan Schulz (talk) 17:27, 7 July 2011 (UTC)
- More information on this subject than you could possibly desire. As you might guess, it's only sort of possible. Paul (Stansifer) 19:26, 7 July 2011 (UTC)
- thanks guys. That blog by Steve Yegge just hit the spot. The bit about the BLONK! BLONK! BLONK! alarm was a perfect piece of writing. I guess every large company has its "we know everyone hates this but we are going to be utter jerks about it, and we aren't going to change it" issues. Google has left navigation, and apple has this. Best wishes, Robinh (talk) 20:18, 7 July 2011 (UTC)
Struggling with Computer
[edit]I have a refurbished laptop (I will never buy another one after this) and I struggling with it. After running Kaspersky and deleting 4 infected files, my computer will no longer connect wirelessly to the internet. In fact, it no longer recognizes that it even once did connect wirelessly; I can't find "wireless network connections" under the "network connections" screen. Is there another way to access the wireless network connections screen? I am running Windows XP. Also, could deleting those files via Kasperky have affected the computer's ability to connect wirelessly? 24.88.86.197 (talk) 09:25, 7 July 2011 (UTC)
- Well, you could boot off a Linux "live CD" and see whether that found wireless connections. If it did, then you'd know that there was no hardware problem. -- Tama1988 (talk) 09:40, 7 July 2011 (UTC)
- Seems obvious the deleted files were something critical (network drivers?) If Kaspersky keeps "deleted" files in a quarantine area, then examine that first. Restore each file in turn and see which one(s) make the wireless network work again. Have a look and see what Kaspersky said they were infected with and search the internet (perhaps from a different PC) to see if there are alternatives to deleting the files. Of course, if they are not quarantined but have been deleted, you might get them back with Window's system restore utility. The final method might be to reinstall the deleted files, by downloading new ones off the internet (remember to choose official sites only rather than blogs or torrents) but to do that you will need to know the manufacturer of the network drivers. Astronaut (talk) 11:53, 7 July 2011 (UTC)
- FWIW, software problems haven't anything to do with refurbishment. ¦ Reisio (talk) 18:00, 7 July 2011 (UTC)
- Well, they could, if the refurbished computer still has bits of the old software (and maybe viruses) on it. StuRat (talk) 05:34, 9 July 2011 (UTC)
- FWIW, software problems are easily fixed and haven't anything to do with refurbished hardware, if you like. ¦ Reisio (talk) 23:50, 10 July 2011 (UTC)
Online maps with heights
[edit]Which free online mapping service, covering cities in England, can display elevation information, perhaps as different shades or as contour lines? Card Zero (talk) 12:20, 7 July 2011 (UTC)
- The only thing I know of is the OS get-a-map service -- Finlay McWalter ☻ Talk 15:04, 7 July 2011 (UTC)
- I think with a bit of print screening and stitching together and picking out the contours, that might just about solve my problem. Thanks Finlay! Card Zero (talk) 16:01, 7 July 2011 (UTC)
- OpenStreetMap can show you contour maps, if you choose the "Cycle Map" format (accessible via the + sign on the upper right edge). Looie496 (talk) 16:40, 7 July 2011 (UTC)
- Interesting - can you give me an example location (or perhaps zoom level) where this works? In the city I'm looking at now, all the "cycle layer" does is display one cycle track (inside a park), and it shows no contour lines. Card Zero (talk) 09:19, 8 July 2011 (UTC)
- A sample location where it works. Are you perhaps looking at a very flat area? Otherwise, I know OpenStreetMap is missing contour details for a few areas, but not many. Warofdreams talk 09:38, 8 July 2011 (UTC)
- Looks like my mistake was to visit "OpenStreetBrowser" (the second link in the article) rather than the site you linked to. Not sure why they have two sites. (If the idea is for the "browser" one to be more accessible to casual users, it probably shouldn't have a mysterious "+" button which I didn't click on my first visit because I assumed it meant "edit", and the functions concealed by the button probably shouldn't be broken.) This is ideal, now that I'm on the main site: nice big maps with clear contours. Ta. Card Zero (talk) 13:46, 8 July 2011 (UTC)
- A sample location where it works. Are you perhaps looking at a very flat area? Otherwise, I know OpenStreetMap is missing contour details for a few areas, but not many. Warofdreams talk 09:38, 8 July 2011 (UTC)
- Interesting - can you give me an example location (or perhaps zoom level) where this works? In the city I'm looking at now, all the "cycle layer" does is display one cycle track (inside a park), and it shows no contour lines. Card Zero (talk) 09:19, 8 July 2011 (UTC)
Bizarre Problem with Gmail & Thunderbird
[edit]I have recently purchased a domain for my business, and set up Google Apps so that I now have a Gmail address, but with my own domain in the address instead of gmail.com, and everything works perfectly if I send email from within Gmail in my browser. However, if I use Thunderbird, any email I send has the name I use for online gaming in the 'From' field, rather than my real name, under which the new address is registered in Gmail. I am also using Thunderbird to download email from [my_gaming_name]@gmail.com. These accounts are not linked in any way. Is there something I should have done? --KägeTorä - (影虎) (TALK) 12:36, 7 July 2011 (UTC)
- EDIT - I can send email, but I can't receive any..... --KägeTorä - (影虎) (TALK) 12:41, 7 July 2011 (UTC)
- Fixed. --KägeTorä - (影虎) (TALK) 12:46, 7 July 2011 (UTC)
USB Flash drive locks up laptop at bootup. Why?
[edit]I recently bought a regular Micro Center 16 GB USB flash drive. Odd thing is, whenever it is plugged into my computer and I turn the computer on, it will lock up at the Gateway screen and not boot into the OS at all. The only options on the Gateway screen are F2, to enter the BIOS setup, and F10, for a system setup. Pressing either of them presents me with a 'Loading... Please wait' message that never loads. When I power down the machine and take out the flash drive, everything works fine. I perplexed as to why this happens. There's nothing bootable on the flash drive that I can think of, and previous flash drives have worked fine with no problem. (Well, I did have the same problem a few months ago, but I can't remember if had the same solution of pulling out a USB flash drive...) Can anyone shed some light onto this topic? Thanks. 141.153.215.98 (talk) 14:36, 7 July 2011 (UTC)
- The flash drive might still have its bootable flag set. I'm not sure of an easy way to clear this, short of using a partition editor. However, you can go into the BIOS settings and change the boot order to HDD (drive c:) first. This will stop it from attempting to boot off another drive. CS Miller (talk) 15:40, 7 July 2011 (UTC)
- It may be useful to try putting in the flash drive after logging onto the computer... Dubious Status How's it going? 17:59, 8 July 2011 (UTC)
Preventing a reformat
[edit]While I'm here, another quick question: Is there any way to prevent someone (such as a thief, for example) from reformatting a hard drive? My guess is no, as any tech savvy user could find a way around it, such as booting up for a LiveCD and doing what you will. Nevertheless, I'm interested to hear any ideas. The reason I ask is being I've loaded some tracking software onto my laptop in the case it ever gets stolen, but like all software tracking the major flaw is it has to connect to the internet to work (and thus won't if the thief reformats the disk right off the bat). The Computrace BIOS solution would probably work better, yet I've yet to find an alternative (and doubt there would be one) that doesn't require payment. 141.153.215.98 (talk) 14:36, 7 July 2011 (UTC)
- As above. Set the BIOS to boot from the hard drive first, and then set a BIOS password to stop anyone changing the settings. Hopefully the OS will protect itself from being overwritten. However, this won't stop the thief from opening the case, and reformatting the drive in another computer, or using the BIOS reset jumper. -- CS Miller (talk) 15:42, 7 July 2011 (UTC)
- This is totally not what you want, but the literal answer to your first sentence is "yes, on some hard disks", because some hard disks let you set a jumper to actually write-protect the hard disk. Comet Tuttle (talk) 06:47, 10 July 2011 (UTC)
New Computer Programs
[edit]Is there a good place to read up on new programs and computer languages? Dubious Status How's it going? 18:01, 7 July 2011 (UTC)
- That's a very broad question. Generally speaking, the Association for Computing Machinery (ACM) is widely regarded as the foremost organization for computer research topics. They have numerous research and industry publications, listed at their publications catalog website. New computer language topics are probably best served by the SIGPLAN, ACM's special interest group for programming languages. What sort of resource are you looking for, more specifically? Nimur (talk) 20:20, 7 July 2011 (UTC)
- Are you interested in theory or practice? Tragically, popular programming languages don't have much to do with programming languages research these days. You might be interested in learning a Lisp-derived language, since they have a The Blob-like ability to absorb new ideas and techniques. (Racket is the Lisp that I always suggest.) Paul (Stansifer) 17:01, 8 July 2011 (UTC)
Beginner's Question - Installing Windows 7
[edit]I have a PC running Vista and have ordered Windows 7. I have read about the problems with upgrading and the advisability of a clean install. But does the install process of Windows 7 give me the chance to repartition my hard drive (it currently has C: & D: and I want only one partition) and do I get the chance to do a low level format - all this before I install Windows 7? — Preceding unsigned comment added by Gurumaister (talk • contribs) 18:26, 7 July 2011 (UTC)
- Yes, the setup has the option to create, delete and format partitions before you select one to install Windows on. I'm not sure what a low level format is or how it differs from a regular format, so I am not sure if Windows 7 setup offers this. AvrillirvA (talk) 18:45, 7 July 2011 (UTC)
AvrillirvA - thank you very much. I am much releived. By the way, a low level format is the format done at DOS level such as when you install an operating system. Any format done afterwards BY the operating system is . . . . (excuse me, I am not a techie) it is less thorough shall we say. Thanks again. Gurumaister (talk) 18:57, 7 July 2011 (UTC)
- Thoroughness has nothing to do with it. I think your confusions is that certain operating systems are unable (or unwilling) to permit a format of the disk partition that the operating system resides on. An operating system can deny access to formatting its own partition for safety reasons, to prevent accidental self-destruction; or it can deny such access because of its own technical limitations, such as an inability to place the entire operating system resident in main memory so that the entire disk (including swap space) can be written or erased. This is not a hard limit to all systems; for example, many small distributions of Linux permit formatting of the entire hard-disk while the system is up and running. And, many bootable instances of disk utility programs constitute a "very small operating system," yet they clearly permit formatting of the entire hard-disk. Nimur (talk) 20:28, 7 July 2011 (UTC)
- True low-level formatting is not normally possible, but Disk partitioning is an option. Are you wishing to erase all traces of files previously stored so that they cannot be recovered? If so, then the article on Data erasure might be useful, though normal overwriting of the sectors after a high-level format or just file or partition deletion is considered sufficient to destroy data on modern drives. Dbfirs 21:49, 7 July 2011 (UTC)
Actually, it isn't so much the deletion of the files I am interested in but 1) to be able to put the disk back to a single partition where it currently has two, and 2) to erase all trace of the Vista OS before I install a clean version of Windows 7. Thanks for the help. Gurumaister (talk) 06:32, 8 July 2011 (UTC)
- One of my laptops had Vista on it - one partition with the OS on it, and another 'for me', so to speak. I put Ubuntu on it to remove Vista and join the two partitions, then wrote over that with Win7. Now the laptop has only Win7 and essentially one partition (except that it has a tiny 100MB partition with nothing on it). --KägeTorä - (影虎) (TALK) 07:30, 8 July 2011 (UTC)
- Win7 setup has a partition manager that lets you create, delete, format and resize partitions. I don't know whether it will merge two partitions, preserving the files on both. One gotcha is that when you create a new partition on an empty drive, it will insist on creating a second, small boot/recovery partition also. If you really want just one partition, you can work around that by letting it create both partitions, deleting the big one, then resizing the small ("system") partition to fill the disk.
- You can also press Shift+F10 once the setup GUI appears to bring up a command prompt from which you can run a bunch of command-line utilities including diskpart. If you wanted to, say, delete the Windows folder while preserving other files, you could do it from there. -- BenRG (talk) 01:01, 9 July 2011 (UTC)