Tuesday, August 31, 2010

Sharp EL-2196BL Heavy Duty Color Printing Calculator with Clock and Calendar


Sharp EL-2196BL Heavy Duty Color Printing Calculator with Clock and Calendar
From Sharp








Customer Reviews

printing calculator4
Product meets expectations and was very reasonably priced. Arrived well packed and in exceptional time.

NO ON NO TIME4
WHEN IT STATES CALENDAR & CLOCK FUNCTION THE AVERAGE PERSON WOULD BELIEVE THAT WHEN YOUR UNIT IS OFF (NOT A CALCULATOR) THAT THE TIME OR TIME CALENDAR WOULD SHOW ON THE DISPLAY. IT IS NOT EXPLAINED THAT THE UNIT "MUST BE ON" TO SEE THE TIME OR CALENDAR AND EVEN THE INSTRUCTIONS FOR SETTING THE TIME AND DATE DO NOT SAY IT HAS TO BE ON.
I WAS NOT VERY HAPPY THAT THE UNIT MUST STAY ON FOR THIS FUNCTION AS THERE IS A BACKUP BATTERY IN THE UNIT.
AS FOR THE FUNCTION AND EASE OF THE KEYS FOR A CALCULATOR IT IS GREAT, BUT HAD I KNOW ABOUT THE TIME FUNCTION I WOULD HAVE GONE FOR THE LESS EXPENSI! VE ONE WITHOUT THE TIME.

Me! t my exp ectations4
For the price I recommend this printing calculator. It fulfills my need for such a product within my home.

Editorial Reviews

From the Manufacturer
The Sharp EL-2196BL is a 12-digit AC-powered desktop calculator with two-color printer.

Features:

  • Large Display - 12-digit (12.0 mm) blue fluorescent display with punctuation
  • Quick and Crisp Two-Color Printing - prints at approximately 3.5 lines/sec. in 2 colors (positive numbers in black, negative numbers in red) on standard size paper rolls
  • Tax Keys - allow for easy tax calculations
  • Mark-Up Key - used to perform mark-ups, cost/sell/margin calculations, percent changes, and automatic add-on/discounts
  • Rate Keys -! allow simple conversion functions
  • Grand Total Key - adds the grand total of several calculations such as the total prices times units on an invoice
Additional features include floating (F) or fixed decimal (6,3,2,1,0), adding and constant modes, item count, print and non-print settings, and round up/down selector. Convenient AC power means no batteries to run down.

What's in the Box
Calculator, power cord/AC adapter, two-color ink roller, paper roll, instructions, warranty information

Product Details

  • Color: White
  • Brand: Sharp
  • Model: EL-2196BL
  • Released on: 2004-12-15
  • Number of items: 1
  • Dimensions: 3.00" h x 9.00" w x 13.00" l, .0 pounds

Features

  • Large 12-digit blue fluorescent display with punctuation
  • 2-color black and red printing at approximately 3.5 lines per second
  • Tax keys, mark-up, rate, and grand total keys!
  • Floating point or fixed decimalEasy to use; operates ! on AC po wer

weighted mean calculator

Skirmish of Wit

I used to love looking at Skirmish of Wit. Now it's been protected and I can't visit it any more. It's very disappointing when that suddenly happens!

I miss Miranda's posts about touring historic houses, visits to the theatre, and books that she'd read. I used to look at it a lot.

tutornext free demo

The Javascript Grid Editor

Current Version 1.0.10
Last Updated 2010.07.15
Download GitHub
  CodePlex

 

Introduction:

The Javascript Grid Editor is a 100% Javascript program that extends the functionality of CRM Grids by providing a way to edit records and add records, in place, by providing input elements in the cells of a CRM Grid and relevant functions to write any input provided to the CRM application via SOAP interaction.


Caveats:

Firstly, please review the list of Known Bugs.

A major caveat to this code is that whomever uses it must have Read privileges to Entities, Attributes, and Relationships.  This must be provisioned through a security role they have.  Without it, the Javascript Grid Editor is unable to ascertain important elements of the entity’s configuration.  At this time, exclusion of these security attributes will cause the script to fail when executed.

Also, the Javascript Grid Editor works only to create or edit records in with a statecode value of “1” (Active, Open, etc.).  This ensures that no matter what entity for which the Javascript Grid Editor is enabled, records will only ever be created in this state, and this state is valid for editing any/all fields for those records.  There is no restriction on the value of the statuscode attribute.

Additionally, the Javascript Grid Editor is currently incapable of importing, parsing, or otherwise executing customized javascript that has been placed into the form for the entity it targets.  It’s unable to execute platform specific code for the same reason.  Therefore, interactive fields, or codependent fields that have been scripted together will not behave similarly if presented in the Javascript Grid Editor.

Finally, the Insert Mode will only work when all Business Required and System Required attributes are present on the Grid.  The Edit Mode will work with any set of attributes present in the Grid.

Installation:

Please read the Caveats on this page for deployment considerations.

  1. Download the script using the link at the top of this page.
  2. Set the variable GEO_ENTITYNAME to the schema-name of the record type to which the script will be tied.
  3. Export your existing ISV.config.xml settings from CRM.
  4. Open the exported ISV.config.xml file in an editor.  Personally, I use Visual Studio.
    WARNING: Do not use XML Notepad for this, as the script exceeds its allowed length for attribute content, and will result in a broken script.  Many other XML editors may behave similarly.
  5. Create XML elements for buttons to execute the script.
    1. Identify or create an Entity element for the entity targeted by the script in step 2
    2. Establish or use an existing Grid element within the Entity element.
    3. Establish or use an existing MenuBar element within the Grid element.
    4. Establish or use an existing Buttons element within the MenuBar element
    5. Establish two (2) new Button elements within the Buttons element.  Set their JavaScript attribute to nothing (“”) for now.
    6. Establish Titles elements within each Button element.
    7. Establish Title elements within each Titles element.  Set the LCID attribute to “1033” for English.  Set the Text attribute of one to “Edit Mode”.  Set the other to “Insert Mode”.
      WARNING: The titles of the buttons are essential to the operation of the script.  For additional language support, see Advanced Configuration for details.

      (Example: Completion of Steps 5.1 – 5.7)
      <?xml version="1.0" encoding="utf-8"?> <ImportExportXml version="4.0.0.0" languagecode="1033" generatedBy="OnPremise">   <Entities></Entities>   <Roles></Roles>   <Workflows></Workflows>   <IsvConfig>     <configuration version="3.0.0000.0">       <Root />       <!-- Microsoft Customer Relationship Management Entities (Objects) -->       <Entities>         <Entity name="serviceappointment">           <Grid>             <MenuBar>               <Buttons>                 <ToolBarSpacer />                 <Button Icon="" JavaScript="">                   <Titles>                     <Title LCID="1033" Text="Edit Mode" />                   </Titles>                   <ToolTips>                     <ToolTip LCID="1033" Text="Action Button: Edit/Save" />                   </ToolTips>                 </Button>                 <Button Icon="" JavaScript="">                   <Titles>                     <Title LCID="1033" Text="Insert Mode" />                   </Titles>                   <ToolTips>                     <ToolTip LCID="1033" Text="Action Button: Insert/Cancel" />                   </ToolTips>                 </Button>               </Buttons>             </MenuBar>           </Grid>         </Entity>       </Entities>
    8. Encode the modified script for XML safety.  Personally, I use the XML Escape Tool.
    9. Copy and paste the encoded script into the JavaScript attribute of each Button element.
  6. Save the modified XML.
  7. Upload and import the modified ISV.config.xml file.

Usage:

Using the Javascript Grid Editor is fairly straightforward.  When a Grid presenting the configured entity is displayed, two buttons, “Insert Mode” and “Edit Mode” will appear.  Clicking either one of these buttons the first time initializes the script, and the JGE will enter the appropriate mode: allowing you either to create new records, or edit existing ones directly in the grid, without the necessity of opening the record’s form.

When in either Insert or Edit modes, the names and functions of the buttons change to “Save [New/All]” and “Cancel [New/All]”.  Use these buttons to save all changes/inserts or to cancel them.

In Insert Mode, a green-arrow icon will present itself in the left-most column for the new line.  Click it to create additional insert rows for creating multiple records at once.  Additional insert rows contain a red-X icon that can be clicked to delete its row.

In Edit Mode, changing your selected records dynamically changes the records that are being edited.  Be warned, however, that if you make a change on a record, and then deselect it, your changes will be silently discarded.

Advanced Configuration:

The idea behind the script is to allow both ease of deployment for simple requirements, and complicated configuration for complex requirements.  There are many ways to configure the Grid Editor to fit your needs.  The advanced configuration options are these:

Option Function Global Variable Code Location, or [CL]
Provide support for alternate languages GEO_REGISTEREDBUTTONLABELS Internal
Restrict an attribute from receiving input controls GEO_RESTRICTEDATTRIBUTES Internal
Disable an attribute’s input controls GEO_DISABLEATTRIBUTES Internal, Internal Conditional, External
Specify default values for an attribute on insert mode. GEO_ADD_DEFAULTVALUES Internal, Internal Conditional, External

The “Code Location” specifies where you should put the customizations, and can be defined in one of three scenarios:

  • Internal:  This is the default location for all globally defined values, and overrides all other “Code Locations”.  In the code these are identified with the tag “[CL]:  Internal”.
  • Internal Conditional:  This is where values for attributes are set that predicate on the absence of External definition of the same.  In other words, if you want the attribute set with a default only when it hasn’t been set by External code, do it here.  In the code these are identified with the tag “[CL]:  Internal Conditional”.  By nature, this does not override any other location.
  • External:  This is a description of any code that externally from the Grid Editor’s code.  (See Advanced Scenarios for examples.)

Provide support for alternate languages (Internal):

By default, the Grid Editor is configured for button labels using the American English code “1033”.  In Step 5.7 of the Installation instructions, you may wish to use a different language.  If you wish to use multiple languages, this is also allowed by repeating Step 5.7 once for each language with the language-specific LCID value (Microsoft Locale ID Reference).

Once the ISV.config file has a Title element for each language specified for both buttons, it’s time to update the script with those titles.  (Note: I’m not certain how document encoding will affect this process, but I haven’t worked with anyone yet who indicated it was a problem.)

  1. The GEO_REGISTEREDBUTTONLABELS object contains two members: EditSaveButton and NewCancelButton.  Both are arrays.  Configure an index for each LCID, in each array, to be an array itself.  Example:
    GEO_REGISTEREDBUTTONLABELS.EditSaveButton[1033] = new Array(); GEO_REGISTEREDBUTTONLABELS.NewCancelButton[1033] = new Array();
  2. Use the three constants, GEO_CONSTANT_MODE_VIEW, GEO_CONSTANT_MODE_EDIT, and GEO_CONSTANT_MODE_ADD to define indexes of the sub-array with values of the labels each button will have for each mode the Grid Editor may enter.  By design, the “Edit Mode” button becomes the “Save” button, and the “Insert Mode” button becomes the “Cancel” button.  (You’re not configuring the functionality of the button, just what label it uses.)  Example:
    GEO_REGISTEREDBUTTONLABELS.EditSaveButton[1033][GEO_CONSTANT_MODE_VIEW] = "Edit Mode"; GEO_REGISTEREDBUTTONLABELS.EditSaveButton[1033][GEO_CONSTANT_MODE_EDIT] = "Save All"; GEO_REGISTEREDBUTTONLABELS.EditSaveButton[1033][GEO_CONSTANT_MODE_ADD] = "Save New";  GEO_REGISTEREDBUTTONLABELS.NewCancelButton[1033][GEO_CONSTANT_MODE_VIEW] = "Insert Mode"; GEO_REGISTEREDBUTTONLABELS.NewCancelButton[1033][GEO_CONSTANT_MODE_EDIT] = "Cancel All"; GEO_REGISTEREDBUTTONLABELS.NewCancelButton[1033][GEO_CONSTANT_MODE_ADD] = "Cancel New";

Restrict an attribute from receiving input controls (Internal):

There are times when it is inconvenient or undesirable for a field to be edited or created with user input.  The GEO_RESTRICTEDATTRIBUTES variable defines an array of strings which are attribute schema-names.  Any attribute which has its schema-name added to the array will not receive input controls in either Insert or Edit mode.  Example:

var GEO_RESTRICTEDATTRIBUTES = new Array("statuscode", "expireson");

Disable an attribute’s input controls (Internal, Internal Conditional, External):

Disabling input controls offers one advantage to restricting them outright: the ability to assign the value of an attribute by script, while preventing the user from entering data.  The GEO_DISABLEATTRIBUTES variable defines an array of strings which are attribute schema-names.  Specifying a disabled attribute is identical to specifying a restricted one.  Example:

var GEO_DISABLEATTRIBUTES = new Array("statuscode", "expireson");

(Note: Disabling an attribute which is already “restricted” does nothing.  Restriction takes precedence.)

Specify default values for an attribute on Insert mode (Internal, Internal Conditional, External):

The GEO_ADD_DEFAULTVALUES object has two members: Properties and Collections.  A Collection is a special type of property for Lookup attributes that contain multiple values, such as the “Resources” field on the Service Activity entity.  All other attributes belong to Properties.  (This is similar to the returned object from the RetrieveRecord() function.)

Entity attributes are defined as members of either Properties or Collections with appropriate values.

Example to define a simple text value for the title attribute:

GEO_ADD_DEFAULTVALUES.Properties['title'] = "This is a default title.";

Example to define a simple picklist value for the statuscode attribute:

GEO_ADD_DEFAULTVALUES.Properties['statuscode'] = '1';

Lookups are a little more difficult, but uncomplicated nonetheless.  They require the same information/values as you would provide a Lookup on an entity’s form with Javascript.  Two additional attributes must be defined, aside from the target-record’s GUID: the name, and the entity type.  These can be identified by appending the name of the attribute with the text “name” and “type”, respectively.

Example to define a “Case” value for the regardingobjectid lookup attribute:

GEO_ADD_DEFAULTVALUES.Properties['regardingobjectid'] = recordId; GEO_ADD_DEFAULTVALUES.Properties['regardingobjectidname'] = recordName; GEO_ADD_DEFAULTVALUES.Properties['regardingobjectidtype'] = 'incident';

…where recordId is a string containing the GUID of the target record, and recordName is the target’s value of the default attribute for the target entity type (commonly the “title”, or “name” attribute).

Finally, Collections which represent arrays of records within a single lookup attribute follow the same requirement as for regular Lookup fields.  Each record identified in the value must have 3 total attributes: id, name, and type.  However, these are assembled into an array, which is a member of the Collections object.

Example to define one value for the “Customers” of a Service activity:

GEO_ADD_DEFAULTVALUES.Collections['customers'] = new Array(); GEO_ADD_DEFAULTVALUES.Collections['customers'][0] = new Object(); GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyid'] = recordId; GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyidname'] = recordName; GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyidtype'] = 'account';

…again, where recordId and recordName identify a particular ‘account’ record.

Advanced Scenarios:

Dynamically Specifiy Configuration Parameters for Related Views:

Because the script is designed to be set once for all views for a particular entity, each view naturally performs identically.  This isn’t exactly desirable for embedded or associated views.  At this point, the Javascript Grid Editor understands practically nothing about the context of the view in which it operates.

Traditionally the “New” button on an associated view establishes new records with and automatic relationship to the parent record.  The Javascript Grid Editor, however, is WYSIWYG—if a field isn’t present in the view, or is not provided a value, it doesn’t get set.  It was for handling this situation that I designed the GEO_DISABLEATTRIBUTES and GEO_ADD_DEFAULTVALUES variables to be configured externally from the script.

Accomplishing the task of dynamically configuring these variables is somewhat tricky, for two reasons:

  1. Attempts to make their configuration dynamic in the script body itself (as deployed to ISV.config) will be generally undesirable because, as I stated before, the script is meant to simply provide static configuration information.  The script runs identically for every view.  It is better to push the dynamic configuration from the parent form, which lends to:
  2. The iFrame containing the view, for associated or embedded views, will not be loaded until first accessed.  Meaning that the configuration push must wait until the view is available.

The path I have personally taken, is to generate a configuration script in a Javascript string, and force-feed that string into execution within the iFrame, using the IncludeScript() function from my CRM Javascript Library.  Consider the example below, where I have changed the configuration of the script for use with an Embedded Advanced Find View, which places a view of Service Activities within the Case form:

SAScript = "GEO_ADD_DEFAULTVALUES = new Object();"   + "GEO_ADD_DEFAULTVALUES.Properties = new Object();"   + "GEO_ADD_DEFAULTVALUES.Collections = new Object();"   + "GEO_ADD_DEFAULTVALUES.Properties['statuscode'] = '1';"   + "GEO_ADD_DEFAULTVALUES.Properties['regardingobjectid'] = '" + crmForm.ObjectId + "';"   + "GEO_ADD_DEFAULTVALUES.Properties['regardingobjectidname'] = \"" + crmForm.all.title.DataValue + "\";"   + "GEO_ADD_DEFAULTVALUES.Properties['regardingobjectidtype'] = 'incident';"   + "GEO_ADD_DEFAULTVALUES.Collections['customers'] = new Array();"   + "GEO_ADD_DEFAULTVALUES.Collections['customers'][0] = new Object();"   + "GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyid'] = '" + crmForm.all.customerid.DataValue[0].id + "';"   + "GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyidname'] = \"" + crmForm.all.customerid.DataValue[0].name + "\";"   + "GEO_ADD_DEFAULTVALUES.Collections['customers'][0]['partyidtype'] = \"" + crmForm.all.customerid.DataValue[0].typename + "\";"   + "GEO_DISABLEATTRIBUTES = new Array('regardingobjectid','customers');";  var SAFrame = crmForm.all.IFRAME_ServiceActivities;  SAOnReadyStateChange = function() {   if (SAFrame.readyState == "complete") {     var SADoc = SAFrame.contentWindow.document;     IncludeScript(SADoc, SAScript);   } }  SAFrame.attachEvent("onreadystatechange", SAOnReadyStateChange);

In this example, I am setting the values of statuscode, regardingobjectid, and customers and disabling both regardingobjectid and customers, in Javascript contained by the string SAScript.  What I’m doing, is dynamically assembling Javascript for the iFrame to execute, when it’s ready.

I set the regardingobjectid, because this establishes the relationship to the parent Case for new records created by the Insert Mode; then, I disable it to prevent users from changing the value.  As a convenience, I’ve also dynamically set the customers and statuscode values, so that other information is inherited from the Case.  It is therefore, absolutely necessary for statuscode, regardingobjectid, and customers to appear on within the view.

Next, I isolate the iFrame’s element into SAFrame, which I can use to attach an event handler for the its “onreadystatechange” event.  This handler calls the IncludeScript() function (not shown), which forces the variable SAScript into a new <script> element within the iFrame.

The result is that when the view enters “Edit Mode”, both customers and regardingobjectid are disabled for editing.  However, when the view enters “Insert Mode”, these fields are provided the defaults I established by the script above.  Simple enough, right?  :P

The Javascript Grid Editor by David Berry is licensed under the Apache License 2.0.


standard entropy values

Tips for Chemistry Paper-1

Hi friends,
I would like to tell a few points about the preparation of Chemistry paper-1 which may be helpful in increasing the score in Chemistry paper-1....use arts optional based approach in Science subjects like preparing model answers, remembering the derivations etc...
  • Prepare all the 15 chapters of Chemistry paper-1, don't leave any chapter completely(although i left main group Chemistry) but it may be counterproductive to leave any particular chapter..
  • Make synoptic notes of all the chapters, this helps in quick revision of the entire syllabus..
  • Try to bring some innovation in ur answers, don't rely solely on Puri Sharma & Pathania and Brilliant notes for Chemistry paper-1...
  • try to include more diagrams and analysis in your answers (show the baby steps in ur answers)...there is lot of subjectivity in the answers of the questions of Chemistry paper-1. For the same question of 20 marks, marks may vary significantly based on the quality of answers...
  • ! Make! Chapter wise lists of questions that were asked in previous year's Civil Services Exam and Forest Service Exams...This will help in analyzing the trend of the question that are being asked...
  • also make a chapter wise list of all probable questions and most difficult questions, prepare model answers of such questions.
  • Every day prepare model answers to some of the previously asked questions of Chemistry paper-1 ( please prepare them in UPSC format sheets)...
  • Practice all numerical that have come in the previous CSE and IFS exam papers! ...keep in mind the sign convention to be used in thermodynamics and also the units to be used in Clausius Clapeyron Equation...
  • For Structures like NaCl, CsCl, etc practice in U.P.S.C format sheets and make a scale so that these structures looks nice in the answer sheet...
  • Some of the key points to kept in mind during examination:
  1. Choose the optional questions wisely, take some time to decide the questions( do not get tempted by the numericals, try to avoid them because if final answer of numerical is wrong then hardl! y any mark will be awarded on that question)
  2. It is not necessary to begin with the compulsory questions, start from the question that u know the best and move in the decreasing order of quality of answers rather that attempting questions in a serial order...
  3. Please make diagrams with Pencil and try to use two different colored pens Black and blue(do not use red or green colored pens).. a little improvement in presentation may improve score by 10-20 marks...Please avoid cutting in the answer sheets and hand writing should be clear & legible....
  4. Do not spend more than 12 minutes on a 20 marks q! uestions....roughly a 20 mark question should not stretch more than 2.5 pages...
  5. Do not write any thing which has no relevance for that particular question....

strong electrolytes list

Finding Phrases - Two Statistical Approaches

In my previous post, I described how I used the Binomial Distribution to find the expected probability of a word n-gram, and compared the actual probability for a phrase to figure out if the n-gram is a phrase. I first learned about using a Binomial Distribution for Phrase Detection from Dr Konchady's Building Search Applications (BSA) book. The book describes two approaches, but the explanation is a bit sketchy, and I could not understand the methods fully at first, so I developed my own.

Over the past couple of weeks, I have been trying to figure out these two methods, and I think I now understand them well enough to be comfortable using them. For the benefit of others who are as perplexed as I was by the mental leaps in the book's explanation, I have included my notes in this post. Hopefully it will help in understanding the code.

As I mentioned in my update to last week's post, I now have a pluggable interface for filtering phrases, called IPhraseFilter. There are currently four implementations available in the repository, two from last week and two from this week. The LikelyPhraseMapper calls the desired implementation. To keep the post down to a reasonable length, I'll just describe the Phrase filter implementations - if you want to see how it fits in, you can refer to my previous post for the Mappers and Reducer classes, or download the whole thing from the jtmt repository.

One thing I liked in both the approaches described below, is that there is no choosing some arbitary cutoff number to ensure results are good. In both cases the cutoff is 0, ie if the determinant is negative, then it is dropped and if it is positive, it is retained.

Likelihood Ratio Approach

This approach makes two hypothesis, and compares the likelihood of the two hypothesis. The hypothesis are as follows:

 For any word bigram {w1,w2} in the document corpus:  H0 = w2 and w1 are independent H1 = w2 is dependent on w1 

We first calculate the actual probabilities for the independent and dependent cases from the occurrence counts of the words in the corpus, like so:

     | P(w2|w1)       | P(w2|¬w1) ---+----------------+---------------------------- H0 | p00 = n2 / N   | p01 = n2 / N H1 | p10 = n12 / n1 | p11 = (N - n12) / (N - n1)  where:   n1  = number of occurrences of w1 n2  = number of occurrences of w2 n12 = number of occurrences of {w1,w2} N   = number of words 

The derivation for the pij values in the table above are shown below.

 Under the null hypothesis H0:  p00  = P(w2|w1)          P(w2 ∩ w1)      = ------------           ... by definition of conditional           P(w1)                   probability          P(w2) * P(w1)      = --------------         ... since w1 and w2 are independent           P(w1)       = n2 / N                p01  = P(w2|¬w1)       = P(w2|w1)               ... since probability of w2 being preceded                                    by w1 is same as w2 being preceded by ¬w1      = n2 / N  Under the alternative hypothesis H1:  p10  = P(w2|w1)            P(w2 ∩ w1)      = -------------          ... by definition of conditional            P(w1)                  probability           n12 / N      = -------------           n1 / N       = n12 / n1  p11  = P(w2|¬w1)          P(w2 ∩ ¬w1)      = -------------          ... by definition of conditional            P(¬w1)                 probability           (n2 - n12) / N      = ------------------          (N - n1) / N       = (n2 - n12) / (N - n1) 

We then use the Binomial distribution to calculate the expected probabilities from the observed probabilities:

    | E(w2|w1)            | E(w2|¬w1) ---+---------------------+------------------------- H0 | b(n12; n2, p00)     | b((n12-n2); (N-n1), p01) H1 | b(n12; n2, p10)     | b((n12-n2); (N-n1), p11) 

We are now able to calculate the likelihood ratio for hypothesis H0 and H1. The likelihood ratio is defined as the ratio of the probability of a true positive and the probability of a false positive.

 L(H0)    = E(w2|w1) / E(w2|¬w1)    ... by definition of likelihood               b(n12; n2, p00)          = ------------------------             b((n12-n2); (N-n1), p00)                  n2Cn12 * p00n12 * (1 - p00)(n2-n12)          = --------------------------------------------------------            (N-n1)C(n12-n2) * p01(n12-n2) * (1 - p01)(N-n1-n12+n2)   L(H1)    = E(w2|w1) / E(w2|¬w1)    ... by definition of likelihood                b(n12; n2, p10)          = --------------------------             b((n12-n2); (N-n1), p11)                  n2Cn12 * p10n12 * (1 - p10)(n2 - n12)          = ----------------------------------------------------------            (N-n1)C(n12-n2) * p11(n12-n2) * (1 - p11)(N-n1-n2+n2) 

The ratio of the likelihood tells us how much more likely the dependence assumption is compared to the independence assumption. We can cancel out the Binomial coefficients in this case.

            p10n12 * (1-p10)(n2-n12) * p01(n12-n2) * (1-p01)(N-n1-n12+n2) R(H1/H0) = ------------------------------------------------------------------            p00n12 * (1-p00)(n2-n12) * p11(n12-n2) * (1-p11)(N-n1-n2+n2) 

LikelihoodRatioPhraseFilter

The code for the LikelihoodRatioPhraseFilter is shown below. The calculations are based on the formula for R(H1/H0) developed in the last section. Rather than return a yes/no answer from the filters, the filter returns the logarithm of R. So the client should check to see if the logarithm has a value greater than 0, ie, the likelihood of the dependence H1 (that the words are dependent on each other) is higher than H0 (that the words are independent).

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
// Source: src/main/java/net/sf/jtmt/phrase/filters/LikelihoodRatioPhraseFilter.java package net.sf.jtmt.phrase.filters;  /**  * Uses the ratio of the likelihood of an dependence hypothesis to the  * likelihood of the independence hypothesis for phrase bigrams to   * filter out unlikely phrases. The log of the ratio is returned as   * the determinant.  */ public class LikelihoodRatioPhraseFilter implements IPhraseFilter {    private long n;    // number of words in the corpus   private long n1;   // number of occurrences of leading word in corpus   private long n2;   // number of occurrences of trailing word in corpus   private long n12;  // number of occurrences of phrase in corpus      public LikelihoodRatioPhraseFilter(long n, long n1, long n2, long n12) {     this.n = n;     this.n1 = n1;     this.n2 = n2;     this.n12 = n12;   }      /**    * Returns the log of the likelihood ratio between the dependence hypothesis    * and the independence hypothesis. If the value is positive, then the     * dependence hypothesis is more likely than the independence hypothesis.    */   @Override   public double getPhraseDeterminant() {     double p00 = (double) n2 / (double) n;     double p01 = p00;     double p10 = (double) n12 / (double) n1;     double p11 = (double) (n2 - n12) / (double) (n - n1);     double llr = n12 * (Math.log(p10) - Math.log(p00)) +        (n2 - n12) * (Math.log(1 - p10) - Math.log(1 - p00)) +        (n12 - n2) * (Math.log(p01) - Math.log(p11)) +        (n - n1 - n12 + n2) * (Math.log(1 - p01) - Math.log(1 - p11));     return llr;   } } 

Results are similar to the previous two approaches, I get 91 phrases with my corpus of three electronic books, and a visual inspection shows that the phrases are quite nice. The top 10 examples are shown below:

 1  2  3  4  5  6  7  8  9 10 11
sperm whale     409.39943002166274 white whale     205.1643105456127 march hare      200.58942539551933 mr holmes       191.6443128051443 baker street    151.41014908579413 captain ahab    124.85466211360614 lord st         108.17580790802768 aye aye         91.86846403214781 cape horn       74.58676644925315 ivory leg       71.68738725289398 ... 

Chi-Square Approach

With the Chi-Square Approach, we assume the independence hypothesis H0, and then attempt to prove or disprove it. This is apparently a popular technique applicable in other fields as well. A high level description of this approach is available in the BSA book, and here is a more detailed explanation. Observed frequencies are first recorded in a contingency table.

       | w2       | ¬w2           | Total ------+----------+---------------+--------------------- w1    | n12      | n1 - n12      | n1 ¬w1   | n2 - n12 | N - n12       | N + n2 - 2n12 ------+----------+---------------+---------------------- Total | n2       | N + n1 - 2n12 | N + n1 + n2 - 2n12  where: n1  = number of occurrences of w1 n2  = number of occurrences of w2 n12 = number of occurrences of phrase {w1w2} N   = number of 2 word phrases in our corpus 

We then compute a table of expected frequencies from the marginal value of the observed frequencies.

       | w2       | ¬w2           ------+------------------------- w1    | E00      | E01 ¬w1   | E10      | E11 

Values of Eij are calculated thus:

 Eij = N * Pm(i) * Pm(j)            ... by Multiplicative law of probability            Nm(i)    Nm(j)     = N * ----- * -------             N        N      = Nm(i) * Nm(j) / N  where Pm(i) = marginal probability of event i             = P(wi|wj) + P(wi|¬wj)       Nm(i) = frequency corresponding to Pm(i). 

We then calculate the Chi-Square statistic &Chi2 and the degrees of freedom ν from our sample. In our code we will just use the ChiSquare test statistic and pass in two arrays of observed and expected frequencies, but the formula below would be used if we were to do this by hand.

               (Oij - Eij)2 Χ2 = Σi Σj -----------------                   Eij  ν = (r - 1) * (c - 1) = 1           ... where r = number of rows in table (2)                                               c = number of columns in table (2) 

For given α = 0.05, we find the critical value ν of a hypothetical "fair" distribution. We use the inverseCumulativeProbability() method for this, and it returns the point where P(x < ν) = α. Thus, 95% of the hypothetical distribution lies behind the critical value. If our computed value of Χ2 exceeds the critical value ν from the table, then we conclude that the (hypothetical) independence hypothesis is incorrect, and that the words {w1,w2} are indeed related as a phrase.

The ChiSquare approach is used by LingPipe for phrase extraction, according to the BSA book.

ChiSquarePhraseFilter

The code for the ChiSquarePhraseFilter is shown below. The theory leading to the code is explained above. Essentially, we compute the Χ2 statistic from the observed and expected probabilities (based on marginal probabilities of the observations), and compare it with the critical value at a 0.05 level of significance. If the result is positive, the observed value lies outside the 95% range of expected values based on a "fair" distribution, ie one where the words are independent and equally likely, and hence can be considered to be a phrase.

 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
// Source: src/main/java/net/sf/jtmt/phrase/filters/ChiSquarePhraseFilter.java package net.sf.jtmt.phrase.filters;  import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.math.MathException; import org.apache.commons.math.distribution.ChiSquaredDistribution; import org.apache.commons.math.distribution.ChiSquaredDistributionImpl; import org.apache.commons.math.linear.Array2DRowRealMatrix; import org.apache.commons.math.linear.RealMatrix; import org.apache.commons.math.linear.RealVector; import org.apache.commons.math.stat.inference.ChiSquareTest; import org.apache.commons.math.stat.inference.ChiSquareTestImpl;  /**  * Calculates the Chi-Squared statistic for the expected vs observed   * frequencies, and finds if the statistic is higher than the critical   * value computed at a 0.05 significance level (ie 95% coverage).  */ public class ChiSquarePhraseFilter implements IPhraseFilter {    private final Log log = LogFactory.getLog(getClass());      private static final double ALPHA = 0.05D;      private long n;    // number of 2 word phrases in corpus   private long n1;   // number of occurrences of leading word in corpus   private long n2;   // number of occurrences of trailing word in corpus   private long n12;  // number of occurrences of phrase in corpus    public ChiSquarePhraseFilter(long n, long n1, long n2, long n12) {     this.n = n;     this.n1 = n1;     this.n2 = n2;     this.n12 = n12;   }      @Override   public double getPhraseDeterminant() {     // set up contingency table of observed frequencies     RealMatrix obs = new Array2DRowRealMatrix(2, 2);     obs.setEntry(0, 0, n12);     obs.setEntry(0, 1, (n1 - n12));     obs.setEntry(1, 0, (n2 - n12));     obs.setEntry(1, 1, (n - n12));     // compute marginal frequencies     RealVector rowTotals = obs.getRowVector(0).add(obs.getRowVector(1));     RealVector colTotals = obs.getColumnVector(0).add(obs.getColumnVector(1));     double total = colTotals.getL1Norm();     // flatten contingency table of observed frequencies     long[] observed = new long[4];     int k = 0;     for (int i = 0; i < obs.getRowDimension(); i++) {       for (int j = 0; j < obs.getColumnDimension(); j++) {         observed[k++] = (long) obs.getEntry(i, j);       }     }     // compute expected frequencies based on marginal frequencies     double[] expected = new double[4];     k = 0;     for (int i = 0; i < obs.getRowDimension(); i++) {       for (int j = 0; j < obs.getColumnDimension(); j++) {         expected[k++] =            (double) colTotals.getEntry(i) * rowTotals.getEntry(j) / total;       }     }     // find the test statistic     ChiSquareTest test = new ChiSquareTestImpl();     double chiSquare = test.chiSquare(expected, observed);     // find the critical value     ChiSquaredDistribution dist = new ChiSquaredDistributionImpl(6.0D);     double criticalValue = 0.0D;     try {       criticalValue = dist.inverseCumulativeProbability(ALPHA);     } catch (MathException e) {       log.warn(e);     }     // return the difference between the test statistic and critical value     return (chiSquare - criticalValue);   } } 

As before, the results look quite believable. 103 phrases are recognized from this algorithm, and the top 10 are shown below. In the full output, there is considerable overlap, even though it does not show up here.

 1  2  3  4  5  6  7  8  9 10
irene adler       1811.5261599783912 march hare        1530.794875612239 um um             1194.2290051976697 project gutenberg 1136.9018182378147 copper beeches    862.8478133287713 don sebastian     789.5537133726627 st simon          788.6790165231548 jabez wilson      727.0858527238903 boscombe valley   708.5084636022881 ... 

Resources

While figuring out this stuff, I came across couple of very good online resources, which I would like to share here.

  • An Intuitive Explanation of Bayes' Theorem by Eliezer S. Yudkowsky - As the title suggests, this is a very easy to understand explanation of Bayes' theorem based on commonsense explanations. Read the rest of the articles on his site if you have some time, I found them quite interesting, maybe you will too.

  • AP* Statistics Tutorial - The last time I used any statistics other than mean and standard deviation was in college, and that was geared to solving toy problems. This time round, I read through the entire tutorial (takes about 2-3 hours) with a view to applying it to real-life (data mining) situations. If you are in a similar situation, I highly recommend reading through it. If nothing else, it will help you understand the more statistically oriented data mining algorithms available out there.


statistics formulas cheat sheet

SBC Sentinel: Form 700 violation prosecution miscues prompt policy change

There has been a significant change in the manner in which the San Bernardino County District Attorney’s office is handling suspected or alleged violations of the state’s income disclosure requirements.Within the last month, San Bernardino County prosecutors have opted to refer such cases to the California Fair Political Practices Commission, a departure from the office’s past approach of filing criminal charges against those who have made no or inadequate disclosure of outside income.

That change follows an embarrassing episode involving district attorney Mike Ramos’s failure to make full disclosure on his California Form 700s of household income he had himself received. California Form 700s are documents used by public officials in the state to list the full range of their incomes and economic interests.

The San Bernardino County district attorney’s office announced on January 17 that it sent a referral to the California Fair Political Practices Commission relating to county Second District Supervisor Paul Biane and newly hired county administrator Greg Devereaux, asking for an opinion as to whether they violated disclosure laws by failing to report gifts they received in the form of charter jet flights.

According to available records, Biane flew to West Virginia on Sept. 26, 2008, for the purpose of “meeting donors.” His campaign fund subsequently reimbursed Ray Crebs, of Rancho Cucamonga, $380.40 for the flight and another $131 for tee fees so Biane could “golf with donors” on Sept. 28, 2008. Biane reimbursed Daniel Richards, one of two managing partners with the Colonies Partners development firm, $300 for tee fees that same day. Crebs is a partner with the Colonies Partners.

Biane did not initially report the trip on two separate Form 700s he filed in October 2008, but entered the information onto an amended form dated March 11, 2009 after a spate of negative publicity in early 2009 over other public officials’ failures to make full disclosure on their Form 700s. There appears to be a discrepancy in Biane’s reporting of the matter in that his Form 700s, which list expenses for hotel and meals during the California Republican Party Convention in Anaheim the same weekend Biane was in West Virginia.
The district attorney’s office also referred a situation involving Devereaux to the state Fair Political Practices Commission which stemmed from the same trip to Morgantown, West Virginia.

Both Devereaux and Richards are alumni at the University of West Virginia. That weekend the West Virginia University Mountaineers hosted the Marshall University Thundering Herd in an NCAA football match-up.

Devereaux failed to note the trip on his Form 700s that he was required to fill out as Ontario city manager.

Less than two weeks ago, on January 12, Devereaux was hired as San Bernardino Couinty’s chief executive officer. He has been employed as Ontario city manager for 13 years. He is scheduled to officially go to work for the county on February 13.

There are complicating considerations to both Biane and Devereaux’s acceptance of plane rides.

First, a change in the law that went into effect just prior to the September 2008 trip called for any reimbursement that government officials make for travel accommodations aboard a private plane correspond to the actual cost of chartering a private plane rather than to commercial fare.

The $380.20 Biane reimbursed Crebs does not meet that criterion.

On the advice of Ontario City Attorney John Brown, Devereaux reimbursed Crebs an amount calculated to be twice the value of a commercial trip to Morgantown. That amount falls short of the requirement under the law as well.

Typical cost of a cross country flight on a private jet can run from $2,000 to $5,000.

In November 2006, Biane voted with supervisor Gary Ovitt and then-supervisor Bill Postmus to confer upon the Colonies Partners a $102 million payment to settle a lawsuit the company had filed against the county over flood control issues at its development project in northeastern Upland.

In Ontario, the city redevelopment agency worked out a deal earlier in the decade that provided, at well below the going market rate, property to a company owned by Richards in accordance with a development plan there.

There were conflicting reports as to who actually owns the plane upon which Biane and Devereaux flew. One held that the plane belonged to Crebs. Another account was that the plane belonged to another developer, Jim Previti.

Under the standard previously applied by the district attorney’s office, criminal charges against both Biane and Devereaux could have been filed.

The Fair Political Practices Commission has the authority to levy fines of up to $5,000 for Political Reform Act violations such as failure to meet the state’s income or campaign finance reporting requirements but does not have the authority to pursue criminal charges relating to those violations.

Two former San Bernardino County officials – Bill Postmus and Jim Erwin – were charged with felonies for failure to properly report income or gifts on their Form 700s.

Postmus, who was once a county supervisor and county assessor, was charged with one count of perjury for failure to disclose the receipt of a $12,000 cashier’s check from developer John Dino Defazio on his Form 700 Statement of Economic Interest. Erwin, who served as an assistant assessor as well as chief of staff to supervisor Neil Derry, was charged with ten felony counts pertaining to his having been provided with air fare and accommodations pertaining to a round trip to New York City and Washington D.C., as well as a $12,765 Rolex watch by Jeff Burum, another managing partner with the Colonies Partners. Like Biane and Devereaux, Erwin belatedly reported receiving the gifts on an amended Form 700.

Erwin has denounced the charges against him as politically motivated and vindictive. He maintains that his transgressions should have merited no more than an FPPC fine.

Despite the district attorney’s office’s recently adopted policy of referring income reporting violations to the Fair Political Practices Commission, it has not dismissed the previously filed charges against Erwin or Postmus.

Despite the hard-nosed approach Ramos and his prosecutors have taken with Erwin and Postmus, the district attorney himself engaged in activity that was practically indistinguishable from those he has criminally charged.
Documents on file with the San Bernardino County Registrar of Voters office covering the period between January 1, 2008 and June 30, 2008, shows that The Friends of Mike Ramos paid Gretchen Ramos $10,000 for “campaign services” and $124.64 in reimbursement money for a “CDAA [California District Attorneys Association] dinner.”

Gretchen Ramos is Mike Ramos’ wife of 28 years.

Ramos’s payment of $10,000 to his wife for “campaign services” in 2008 represents a potential issue for investigators, prosecutors and regulators in that 2008 was not an election year for the district attorney’s post in San Bernardino County. Ramos elevated the issue into a potential legal question by failing to disclose the $10,000 payment to his wife on his California Form 700 he filed in 2009.

Erwin noted that discrepancy and in October 2009 filed a complaint with the Fair Political Practices Commission.

Ramos overcame that problematic legal issue by agreeing to pay a $200 fine to close out the California Fair Political Practices Commission’s inquiry into his failure to disclose income his campaign provided to his wife.
Under the Political Reform Act, elected officials in California are required to fill out the Forms 700 statements of economic interest to provide disclosure of the full range of their economic interests, including all income and gifts to his or her entire household. Since California is a community property state, Ramos should have declared the payment to his wife as income to his household.

In the district attorney’s office’s filing against Erwin, prosecutors alleged that Erwin’s failure to disclose the income from Burum constituted felonious activity since he had signed the Form 700 that omitted the report of the gifts under the penalty of perjury.

Erwin maintains that Ramos likewise signed his Form 700 under the penalty of perjury. Moreover, Erwin has suggested, Ramos’ provision of money to his wife for campaign services during a year – 2008 – during which no election for the post of district attorney in San Bernardino County was held – very likely entailed fraud on Ramos’ part.

Unlike Ramos, however, Erwin lacks prosecutorial authority.

Ramos maintains that his failure to disclose the money paid to his wife does not rise to the level of criminality and that the omission he made “was simply an oversight.”



standard form 700

A Million Dollars for Solving a Math Problem -- Will the Winner Show Up?

The Clay Mathematics Institute has announced the winner of the 1 million dollar prize for the resolution of the Poincare conjecture, which is a conjecture in a branch of mathematics known as topology. The announcement was made this week by Dr. James Carlson, the President of the Clay Institute, that Dr. Grigoriy Perelman of St.Petersburg, Russia is the winner of this prize.

Dr. Perelman in 2006 received the prestigious Fields Medal but never claimed it. The New York Times, in an article, is wondering whether he will (or will not) claim the million dollar prize for solving a longstanding mathematics problem that was one of seven selected for the Millenium Awards by the Clay Institute, which is located in Cambridge, Massachusetts.

Interestingly, Dr. Perelman, 7 years ago, in 3 papers p! osted on the Internet, provided the solution to this math problem, which was posed in 1904 by Poincare. The news of his results quickly spread (at least in math circles) and he embarked on a whirlwind series of speaking engagements, only to return back to Russia and then resign from his post at the Steklov Institute of Mathematics. He stopped answering email messages and, in a sense, disappeared professionally.

According to The New York Times, several teams of mathematicians, using Dr. Perelman’s papers as a guide, completed a full proof of the conjecture in manuscripts hundreds of pages long, showing that Dr. Perelman was right.

The Clay Institute plans to hold a conference to celebrate the solution of the Poincaré conjecture on June 8 and 9 in Paris, France. Dr. Carlson was quoted as saying that Dr. Perelman will let him know in due time whether he will accept this pri! ze.

There are 6 other math problems left as Millen! nium Pro blems, so for those who are interested, you may find the list here. The solution of any of these will garner you a million dollars.


solving math problem