Daily Archives

Articles indexed Tuesday June 15 2010

Page 6/118 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • What statistics can be maintained for a set of numerical data without iterating?

    - by Dan Tao
    Update Just for future reference, I'm going to list all of the statistics that I'm aware of that can be maintained in a rolling collection, recalculated as an O(1) operation on every addition/removal (this is really how I should've worded the question from the beginning): Obvious Count Sum Mean Max* Min* Median** Less Obvious Variance Standard Deviation Skewness Kurtosis Mode*** Weighted Average Weighted Moving Average**** OK, so to put it more accurately: these are not "all" of the statistics I'm aware of. They're just the ones that I can remember off the top of my head right now. *Can be recalculated in O(1) for additions only, or for additions and removals if the collection is sorted (but in this case, insertion is not O(1)). Removals potentially incur an O(n) recalculation for non-sorted collections. **Recalculated in O(1) for a sorted, indexed collection only. ***Requires a fairly complex data structure to recalculate in O(1). ****This can certainly be achieved in O(1) for additions and removals when the weights are assigned in a linearly descending fashion. In other scenarios, I'm not sure. Original Question Say I maintain a collection of numerical data -- let's say, just a bunch of numbers. For this data, there are loads of calculated values that might be of interest; one example would be the sum. To get the sum of all this data, I could... Option 1: Iterate through the collection, adding all the values: double sum = 0.0; for (int i = 0; i < values.Count; i++) sum += values[i]; Option 2: Maintain the sum, eliminating the need to ever iterate over the collection just to find the sum: void Add(double value) { values.Add(value); sum += value; } void Remove(double value) { values.Remove(value); sum -= value; } EDIT: To put this question in more relatable terms, let's compare the two options above to a (sort of) real-world situation: Suppose I start listing numbers out loud and ask you to keep them in your head. I start by saying, "11, 16, 13, 12." If you've just been remembering the numbers themselves and nothing more, and then I say, "What's the sum?", you'd have to think to yourself, "OK, what's 11 + 16 + 13 + 12?" before responding, "52." If, on the other hand, you had been keeping track of the sum yourself while I was listing the numbers (i.e., when I said, "11" you thought "11", when I said "16", you thought, "27," and so on), you could answer "52" right away. Then if I say, "OK, now forget the number 16," if you've been keeping track of the sum inside your head you can simply take 16 away from 52 and know that the new sum is 36, rather than taking 16 off the list and them summing up 11 + 13 + 12. So my question is, what other calculations, other than the obvious ones like sum and average, are like this? SECOND EDIT: As an arbitrary example of a statistic that (I'm almost certain) does require iteration -- and therefore cannot be maintained as simply as a sum or average -- consider if I asked you, "how many numbers in this collection are divisible by the min?" Let's say the numbers are 5, 15, 19, 20, 21, 25, and 30. The min of this set is 5, which divides into 5, 15, 20, 25, and 30 (but not 19 or 21), so the answer is 5. Now if I remove 5 from the collection and ask the same question, the answer is now 2, since only 15 and 30 are divisible by the new min of 15; but, as far as I can tell, you cannot know this without going through the collection again. So I think this gets to the heart of my question: if we can divide kinds of statistics into these categories, those that are maintainable (my own term, maybe there's a more official one somewhere) versus those that require iteration to compute any time a collection is changed, what are all the maintainable ones? What I am asking about is not strictly the same as an online algorithm (though I sincerely thank those of you who introduced me to that concept). An online algorithm can begin its work without having even seen all of the input data; the maintainable statistics I am seeking will certainly have seen all the data, they just don't need to reiterate through it over and over again whenever it changes.

    Read the article

  • clarification on yslow rules

    - by ooo
    i ran yslow and i got a bad score on expires header: Here was the message: Grade F on Add Expires headers There are 45 static components without a far-future expiration date. i am using IIS on a hosted environment. what do i need to do on my css or js files to fix this issue ?

    Read the article

  • Android: Content goes off screen

    - by James
    He is an example of my TextView, which goes off the right side of the screen. I tried setting paddings and stuff, but nothing seemed to work. Any ideas? Here is my hierarchy, ScrollView,TableLayout <TableRow> <TextView android:layout_column="1" android:id="@+id/text_price" android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textCapCharacters" android:padding="2dip" android:text="@string/game_price" /> <EditText android:id="@+id/gameprice" android:inputType="textCapCharacters" android:gravity="right" android:minWidth="120dip" /> </TableRow>

    Read the article

  • Killing all processes of current user

    - by Vi
    user@host$ killall -9 -u user Will it definitely kill all processes owned by user (including forkbombs)? No new processes is spawned to user from other users. No user's processes are in D-sleep and unkillable. No processes are trying to detect and ptrace or terminate this started killall. E.g. if killall will finish untampered and successfully is it 100% that no processes are left with this uid?

    Read the article

  • Threading in Thunderbird based on subject

    - by MrStatic
    I am in Thunderbird 3.0.4 which is the latest (as of now) for windows. I have edited the about:config as per the Mozilla Mail/News wiki I have tried with mail.correct_threading as false as well. After restarting Thunderbird it still does not thread per just subject/date. We use DeskPro which emails out to each tech every time a support ticket is created/replied to but since these are notices they do no include In-Reply-To headers. For these emails each subject line is exactly the same for each ticket. Curious if anyone can shed some light on this.

    Read the article

  • ????????????IFRS

    - by toshiyuki.sakuramoto
    ?????????????????????? ???????????????TV?????????????????? ??~?????????????????????~? ????????????????????????? ??????????! ??????????&?????????????????????????? ????????Beer??????????????? ????????????????????????????????????????????????????????????????????????????????? ?????????? (1)????????????? (2)??????? ??2?? (1)??????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????????? ????(????????)?????????????????????? ??????????????????????????????? ??????????????????? (2)????????????????????????????????????????????????????????????????????????????????????? ??????????????????????? IFRS???????????????????????????? ???????????????????!???? ?????????? ?2????????????????!!

    Read the article

  • iPad Camera Connection kit?

    - by Adam
    Does anyone know if it is possible to access the iPad's camera connection kit? I would like to read the files off the connected mass storage device. Would this be possible or is this something that only Apple can do in there apps. Thanks

    Read the article

  • How to tell a method has a varargs argument using reflection?

    - by Anthony Kong
    Here is a sample code package org.example; import java.lang.reflect.Method; class TestRef { public void testA(String ... a) { for (String i : a) { System.out.println(i); } } public static void main(String[] args){ Class testRefClass = TestRef.class; for (Method m: testRefClass.getMethods()) { if (m.getName() == "testA") { System.out.println(m); } } } } The output is public void org.example.TestRef.testA(java.lang.String[]) So the signature of the method is reported to take a array of String. Is there any mean in the reflection library I can tell that the method is originally declared to take a varargs?

    Read the article

  • Redirect for .htaccess Wildcard Subdomains

    - by waywardspooky
    Hello, I've been trying to figure out a way to redirect requests for wildcard subdomains to a specific folder ( called 'core' ) and calling the requested page/file from that specific folder. For example, making all calls to -http://johnny5.mysite.net redirect to -http://mysite.net/core/, or -http://docholliday.mysite.net/login.php redirect to -http://mysite.net/core/login.php, or a final example, -http://jamesbrown.mysite.net/images/feelgood.jpg to -http://mysite.net/core/images/feelgood.jpg. The problem I've been having has been getting the redirect to call the requested page/file from 'core'. I've been able to get the wildcard subdomains to redirect requested pages/files to the root ( -http://mysite.net ), but not to the specific folder ( -http://mysite.net/core/ ). Here's what I have: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^(www|mail|ftp)\.[a-z-]+\.[a-z]{2,6} [NC] RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC] RewriteRule ^/(.*)$ http://%1/core/$1 [L] I've tried several things like removing the http://%1 in the RewriteRule but I can't seem to get it to work in the way I described above.

    Read the article

  • Using jQuery's animate(), if the clicked on element is "<a href="#" ...> </a>", the fucntion should

    - by Jian Lin
    I was reading jQuery's page for animate() http://api.jquery.com/animate/ Its examples don't mention about if using <a href="#" id="clickme">click me</a> ... $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); }) we actually still have to return false like in the old days? $('#clickme').click(function() { $('#someDiv').animate({left: "+=60"}); return false; }) (but then, those examples didn't use a <a> for the "click me"... but used something else. Otherwise the page will jump back to the beginning of the page? Does jQuery have a more elegant or magical way of doing it?

    Read the article

  • Cut a file based on a text marker

    - by Mustafa
    I have a text file that has the following layout: text text .. CUT HERE text text .. The literal CUT HERE appears only once. What I want to do using shell scripting, is to produce another file containing all the text below CUT HERE, i.e. ignore whatever above CUT HERE. Thanks.

    Read the article

  • one page has more than one url. search engines give penalty please help me out.

    - by Ali Demirtas
    Hi I am using prestashop as the cart for my website. I have a problem; the website used to be in dynamic urls. I enabled friendly url writing. The problem is that one page has more than one url. You can access a same page from the dynamic url and static url. In fact a single page has 9 different urls. This obviously creates problems for seo as search engiones penalize my website for this. What can I do to solve this problem? I have no knowledge of programming. Here is the htaccess for the website. Any sample code or help is really appreciated. URL rewriting module activation RewriteEngine on URL rewriting rules RewriteRule ^([a-z0-9]+)-([a-z0-9]+)(-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]*).jpg$ /img/p/$1-$2$3.jpg [L,E] RewriteRule ^([0-9]+)-([0-9]+)/([_a-zA-Z0-9-]*).jpg$ /img/p/$1-$2.jpg [L,E] RewriteRule ^([0-9]+)(-[_a-zA-Z0-9-]*)/([_a-zA-Z0-9-]).jpg$ /img/c/$1$2.jpg [L,E] RewriteRule ^lang-([a-z]{2})/([a-zA-Z0-9-])/([0-9]+)-([a-zA-Z0-9-]).html(.)$ /product.php?id_product=$3&isolang=$1$5 [L,E] RewriteRule ^lang-([a-z]{2})/([0-9]+)-([a-zA-Z0-9-]).html(.)$ /product.php?id_product=$2&isolang=$1$4 [L,E] RewriteRule ^lang-([a-z]{2})/([0-9]+)-([a-zA-Z0-9-])(.)$ /category.php?id_category=$2&isolang=$1 [QSA,L,E] RewriteRule ^([a-zA-Z0-9-])/([0-9]+)-([a-zA-Z0-9-]).html(.*)$ /product.php?id_product=$2$4 [L,E] RewriteRule ^([0-9]+)-([a-zA-Z0-9-]).html(.)$ /product.php?id_product=$1$3 [L,E] RewriteRule ^([0-9]+)-([a-zA-Z0-9-])(.)$ /category.php?id_category=$1 [QSA,L,E] RewriteRule ^content/([0-9]+)-([a-zA-Z0-9-])(.)$ /cms.php?id_cms=$1 [QSA,L,E] RewriteRule ^([0-9]+)__([a-zA-Z0-9-])(.)$ /supplier.php?id_supplier=$1$3 [QSA,L,E] RewriteRule ^([0-9]+)_([a-zA-Z0-9-])(.)$ /manufacturer.php?id_manufacturer=$1$3 [QSA,L,E] RewriteRule ^lang-([a-z]{2})/(.*)$ /$2?isolang=$1 [QSA,L,E] Catch 404 errors ErrorDocument 404 /404.php Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^.com [NC] RewriteRule ^(.)$ http://www.*.com/$1 [L,R=301] Options +FollowSymLinks RewriteEngine on index.php to / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.index.php\ HTTP/ RewriteRule ^(.)index.php$ /$1 [R=301,L] Header set Cache-Control: "no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"

    Read the article

  • Visual Studio 2010 JavaScript Intellisense Behavior

    After I installed Visual Studio 2010 I was having a difficult time editing .js files in Visual Studio. I habitually type the "(" character as soon as the function I want to call is highlighted in the Intellisense window, but in 2010 this behavior was no longer auto-completing the function name. At first I thought this behavior was due to the new "suggestion mode" in Intellisense, but no amount of toggling with CTRL+ALT+SPACE would bring back the auto-complete behavior. It turns out the two...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • problems with Apache on Snow Leopard

    - by Hristo
    I kind of screwed up the Apache "stuff" on my Mac. Usually when I visit http://localhost/, I would see the "It Works!" but now it just lists the directory and files inside /Library/WebServer/Documents. When I try to stop/start/restart the server with sudo apachectl stop, I get: httpd: Syntax error on line 68 of /etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_disk_cache.so into server: dlopen(/usr/libexec/apache2/mod_disk_cache.so, 10): Symbol not found: _apr_file_info_get$INODE64\n Referenced from: /usr/libexec/apache2/mod_disk_cache.so\n Expected in: flat namespace\n in /usr/libexec/apache2/mod_disk_cache.so I don't want to do the MacPorts install, I tried it earlier but... I just want to do it via source code with the usual ./configure, make, make install. Any ideas on how to get this working? Is there a way to totally remove Apache and then reinstall a fresh version? Thanks, Hristo

    Read the article

  • Accessing we.config from Sharepoint web part

    - by philj
    I have a VS 2008 web parts project - in this project is a web.config file: something like this: ……. In my web part I am trying to access values in the appSetting section: I've tried all of the code below and each returns null: string Owner = ConfigurationManager.AppSettings.Get("MFOwner"); string stuff1 = ConfigurationManager.AppSettings["MFOwner"]; string stuff3 = WebConfigurationManager.AppSettings["MFOwner"]; string stuff4 = WebConfigurationManager.AppSettings.Get("MFOwner"); string stuff2 = ConfigurationManager.AppSettings["MFowner".ToString()]; I've tried this code I found: NameValueCollection sAll; sAll = ConfigurationManager.AppSettings; string a; string b; foreach (string s in sAll.AllKeys) { a = s; b = sAll.Get(s); } and stepped through it in debug mode - that is getting things like : FeedCacheTime FeedPageURL FeedXsl1 ReportViewerMessages which is NOT coming from anything in my web.config file....maybe a config file in sharepoint itself? How do I access a web.config (or any other kind of config file!) local to my web part??? thanks, Phil J

    Read the article

  • System.ServiceModel.CommunicationException on overloading webservice

    - by soldieraman
    I am load testing my webservice and get a System.ServiceModel.CommunicationException when I use 10 threads to communicate to it (without any sleep in between) - basically testing 10 conenctions at a time - through a windows application An error occurred while receiving the HTTP response to http://localhost/XXX/XXXService.asmx. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. Why would this happen and how to best resolve it

    Read the article

  • Fastest way to put contents of Set<String> to a single String with words separated by a whitespace?

    - by Lars Andren
    I have a few Set<String>s and want to transform each of these into a single String where each element of the original Set is separated by a whitespace " ". A naive first approach is doing it like this Set<String> set_1; Set<String> set_2; StringBuilder builder = new StringBuilder(); for (String str : set_1) { builder.append(str).append(" "); } this.string_1 = builder.toString(); builder = new StringBuilder(); for (String str : set_2) { builder.append(str).append(" "); } this.string_2 = builder.toString(); Can anyone think of a faster, prettier or more efficient way to do this?

    Read the article

  • How to raise a validation event from a key press

    - by flavour404
    Hi, I want to raise the: private void txtbox_startdate_Validating(object sender, System.ComponentModel.CancelEventArgs e) {} Function from a key leave event. The leave event looks like: private void txtbox_startdate_Leave(object sender, EventArgs e) {} The trouble is of course if I try and call it in this manner: txtbox_startdate_Validating(sender, e) An error is raised because in this case 'e' is an EventArgs whereas the validation function wants a System.ComponentModel.CancelEventArgs and so, how do I convert EventArgs to a System.ComponentModel.CancelEventArgs or create one so that I can call my validation function? Thanks, R.

    Read the article

  • Mouse over effect with jQuery in richfaces datatable and datascroller combo

    - by John
    Hi, I'm problem with defining a mouse over effect for my datatables. I have <a4j:form> <rich:dataTable id="dataTable"> ... </rich:dataTable> <rich:datascroller id="dataScroller" for="dataTable" /> </a4j:form> <rich:jQuery selector="#dataTable tr" query="mouseover(function(){jQuery(this).addClass('active-row')})"/> <rich:jQuery selector="#dataTable tr" query="mouseout(function(){jQuery(this).removeClass('active-row')})"/> which are working fine on the very first page. However if I use the datascroller to goto another page, the mouseover effect is gone. I've tried reRendering the table or the jQuery components, that didn't help with the problem at all. Any suggestion on how I can get this working? Thanks!

    Read the article

  • How to get all the updates for a Second Life Object (prim) using LIBOMV

    - by sura
    Hi All, In Second Life, I have an avatar and a primitive object that are moving with changing velocity. I use the LIBOMV library to create a text client to Second Life. Using this LIBOMV text client, I am trying to record the update packets of that avatar and object that are being sent to my text client by the server. I get frequent update packets for the avatar as its velocity changes, but I do not get update packets for the object that frequently, although it has a changing velocity. I would like to know whether there is any special setting I should use in order to solve this problem. /Su

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >