Thursday, January 26, 2017

Statistical Analysis Overview

Statistical Analysis Overview1
Major Entities
There are two major entities in Applied Statistics:
• Data
• Meta Data
Data
Data comprise the raw sample information we collect as well as the results of analyzing the samples.
Canonical notation presents these as multivariate variables2 in an array, e.g.:
A sequence or other collection of random variables is independent and identically distributed ("i.i.d.") if each random variable has the same probability distribution as the others and all are mutually independent.3
The results of a function of a variable are also data:
R = F(X)
These are our test data for the R Project for Statistical Computing4 program that we are using:
We will use these for demonstration in the remainder of this paper.
Metadata
Metadata present the overlying processes and methods that interrelate the data.
Processes, functions, and analytic parameters are metadata.
The processes of statistical analysis comprise models and tests on both the model and its results.5
Statistics
Descriptive Statistics
Descriptive Statistics comprise calculations that describe the sample set:
Models
We build a mathematical model (a “regression”) to describe the relationships between input variables and the observed results. Most frequently the model is a linear regression of the form:
[R] = [A]x[X]+[B]
in standard matrix algebra notation.
Correlation analysis6
The first step is to validate the model. We do this with correlation analysis to determine how closely the model matches the observed samples. The sample data are used to compute r, the correlation coefficient for the sample. The symbol for the population correlation coefficient is ρ, the Greek letter "rho":
• ρ = population correlation coefficient (unknown)
• r = sample correlation coefficient (known; calculated from sample data)
If the test concludes that the correlation coefficient is significantly different from 0, we say that the correlation coefficient is "significant".
Significance is indicated by the value:
α = 1-ρ
α = 5 indicates a 95% correlation and is considered “significant”.
Factor Analysis
The analyst must seek the causes if the model does not adequately match the samples. Factor Analysis is one tool for this purpose.
Statistical Control
The process of statistical quality control37 is one of determining whether a process and its results are “under control” or “out of control”.
A process that is operating with only chance causes of variation present is said to be in statistical control.
A process that is operating in the presence of assignable causes is said to be an out-of-control process. A process is considered to be out of control when its results exceed the Upper Specification Limit (USL) or Lower Specification Limit (LSL):
Control Charts
The USL/LSL correspond to the Upper Control Limit (UCL) or Lower Control Limit (LCL) in a control chart. These limits typically are taken to be three standard deviations (3σ) above and below the process mean:

The latter chart is an example of the R program output.
Hypothesis Testing8
A hypothesis test examines two opposing hypotheses about a population: the null hypothesis and the alternative hypothesis. The null hypothesis is the statement being tested. Usually the null hypothesis is a statement of "no effect" or "no difference". The alternative hypothesis is the statement you want to be able to conclude is true.
Based on the sample data, the test determines whether to reject the null hypothesis (to decide that the second hypothesis is correct). You use a “p-value”, to make the determination. If the p-value is less than or equal to the level of significance α then you can reject the null hypothesis.
p-value
The p-value is defined as the probability of obtaining a result equal to or "more extreme" than what was actually observed, when the null hypothesis is true. In layman's terms, it is the probability of being wrong by rejecting the null hypothesis. So we reject the null hypothesis when the p-value is sufficiently small, that is, less than the significance level α, which is a cut-off point that you define.
We cannot know the exact p-value, but there are a number of different tests for estimating the p-value depending on the known characteristics of the sample sets at hand:9

t-test10

This delivers a random variable t that approximates the p-value. A t-test is used for testing the mean of one population against a standard or comparing the means of two populations if you do not know the populations’ standard deviation and when you have a limited sample (n < 30).
R returns the following paired t-test result:
data: y and V2
t = -4.2636, df = 5, p-value = 0.007987
indicating a close correlation between y and V2

z-test

A z-test is used for testing the mean of a population versus a standard, or comparing the means of two populations, with large (n ≥ 30) samples whether you know the population standard deviation or not.
Other tests
We may wish to compare other statistics (characteristics) of different sample sets.

F-test

An F-test is used to decide if 2 populations’ variances are the same, assuming both populations are normally distributed. The samples can be any size.

Levene's test

Levene's test is used to decide if 2 populations’ variances are the same, assuming both populations are continuous but NOT normally distributed.

Anderson–Darling test11

The Anderson–Darling test is a statistical test of whether a given sample of data is drawn from a given probability distribution. 

Confidence interval

A confidence interval is a range of likely values for a population parameter (such as the mean μ) that is based on sample data.
Use a confidence interval to make inferences about one or more populations from sample data, or to quantify the precision of your estimate of a population parameter, such as μ.

Test and CI for Two Variances

This calculates the ratio of the variances (Σ) of two sample sets.
This summarizes the various tests:12

1©Privus Technologies LLC, P.O. Box 149, Newport, RI 02840, 2017
21 Richard A. Johnson and Dean W. Wichern, Applied Multivariate Statistical Analysis, 6th Ed., ISBN 0-13-187715-1
5Douglas C Montgomery, Introduction to Statistical Quality Control, 6th Edition, ISBN 978-0-470-16992-6
6Barbara Illowsky. “Testing the Significance of the Correlation Coefficient.” Collaborative Statistics Boundless, 26 May. 2016. Retrieved from https://www.boundless.com/users/235422/textbooks/collaborative-statistics/linear-regression-and-correlation-13/testing-the-significance-of-the-correlation-coefficient-181/testing-the-significance-of-the-correlation-coefficient-424-15972/
7Montgomery, Section 5.2

Thursday, January 12, 2017

Wireshark question: How to get Wireshark to see usbmon0?

I seem to have a habit of embarking on projects and getting to a point at which neither I nor anyone else seems able to find an answer.
Typically, I then go find a forum to post a question. This usually works. But this time it has not.
So, it occurred to me, since all my hours of Googling have failed me, perhaps I should try having Google do the work by posting the question to a blog. That way, anyone halfway interested in the components of my question will be directed here.It may be gratifying to them to know that someone else has the same problem. Perhaps then we can all contribute and we all win.
So here goes. I'll let you know how it works out... If you have thoughts please leave comments by clicking Comments at the bottom of the post. Thanks in advance.
=======================================================
How to get Wireshark to see usbmon0?
 ls -l /dev/usbmon shows 
crw-r--r-- 1 root root 248, 0 Jan 10 14:50 /dev/usbmon0 
crw-r--r-- 1 root root 248, 1 Jan 10 14:50 /dev/usbmon1 
crw-r--r-- 1 root root 248, 2 Jan 10 14:50 /dev/usbmon2
but Wireshark only sees the latter two.
1. We have a piece of boat gear (RayMarine C120W) that bridges NMEA 0183 (ASCII) and EtherNet ("SeaTalk-HS") data for transmission to Windows software (RayTech Navigation System—RNS). The bridged data are wired to a DB-9F chassis connector near the laptop. We did have a Serial to Ethernet cable that connected to an older laptop running the software that had an Ethernet Socket. It worked fine.
2. We have not touched the boat wiring, but have lost the cable and necessarily moved the software to a new laptop (openSUSE Leap 42.1 Linux) that does not have an Ethernet socket, only USB.
3. We have a Gigaware 2603487 USB-A to Serial Cable. It is recognized by the laptop and connected to ttyUSB0. We can read that port at the command line interface—CLI—with cat /dev/ttyUSB0 and see the NMEA 0183 ASCII sentences but not the Ethernet stream. 
3.1 I understand that the EtherNet traffic is higher frequency and multiplexed, yada yada, so will address that aspect ("EtherNet over USB") in due course, but first we need Wireshark to see the basic USB data that we can see on the CLI (presumably on usbmon0) to ensure that Wireshark is reading the USB connection.
4. We have laboriously followed https://wiki.wireshark.org/CaptureSetup/USB and many of its adherents, particularly http://stackoverflow.com/questions/31054437/how-to-install-wireshak-on-linux-and-capture-usb-traffic — yes, they misspelled Wireshark. As a result we have:
4.1 Sorted out usbmon. It needs to be restarted after each reboot (modprobe usbmon), a PITA we'll address later.
4.2 Added the requisite capabilities to dumpcap
4.3 Changed permissions as directed (644) on /dev/usbmon*, added the wireshark group and added the user to the group.
4.4. Configured Wireshark for non-root use, but that shows the same results as running it as root (yes, I know, a no-no).
5. https://wiki.wireshark.org/CaptureSetup/USB says the special "usbmon0" interface receives events from all USB buses.
5.1 After a new modprobe usbmon after a reboot ls -l /dev/usbmon* returns
crw-r--r-- 1 root root 248, 0 Jan 10 14:50 /dev/usbmon0 
crw-r--r-- 1 root root 248, 1 Jan 10 14:50 /dev/usbmon1 
crw-r--r-- 1 root root 248, 2 Jan 10 14:50 /dev/usbmon2
so others (user, wireshark group) should be able to read.
5.2 So indeed usbmon0 exists but it does not appear in Wireshark. Wireshark only shows usbmon1 and usbmon2.  Neither has any interesting traffic, certainly not the ASCII stream that we can see on the CLI.
6. We have attempted using a USB connected EtherNet to USB adapter with a Serial to Ethernet cable. It is recognized by the OS and Wireshark sees it as eth0 but there is zero traffic on it.
We can proceed further with EtherNet over USB once we have determined that Wireshark can read usbmon0 (ttyUSB0).
How to get Wireshark to see usbmon0?

Monday, October 17, 2016

Replacement Smartphone

I love my Nexus 4. But like Hank the cat, it has a finite life.

It's done well for about six years. Hank lasted 14. Good work both.

But the Nexus won't hold a charge and times (and smartphones) have changed.

AT&T said I had an upgrade available.

The upgrade is to pay for a ~$600 phone at $20 per month for 30 months, or words to that effect, at zero interest.

Nice, but, hmmm.

20x30 = 600

So where's the beef? I guess in stretching it out.

OK, but you also have to sign a contract for 30 months, during which the phone is locked to AT&T.

May work for some, but I move around a lot, so it doesn't work for me.

-----

OK, back  to the drawing board: Find Another Phone.

Well, thank you very much:
     http://newatlas.com/smartphone-comparison-2016/43277/

Outstandingly comprehensive review of all the current versions and the many alphabet soup options (OIS, AMOLED, etc. (and I'm an engineer...)).

Good, indeed excellent, work, Will Shanklin, thank you.

He only lacks an easy comparison chart that I constructed today. My choice is the Samsung Galaxy S7 edge

YMMV:


Parameter LG Nexus 4 HTC 10 Samsung Galaxy S7 Samsung Galaxy S7 edge LG G5 Huawei/ Google Nexus 6P
H mm 140 146 142 151 149 159
W mm 72 72 70 73 74 78
D mm 10 9 7.9 7.7 7.7 7.3
Wt g
161 152 157 159 178
Build Aluminium Aluminium Glass Aluminium Glass Aluminium Aluminium Aluminium
Black x
x x
x
Silver
x x x x
Gray
x

x x
Display in 4 5.2 5.1 5.5 5.3 5.7
Resolution
2560x1440 2560x1440 2560x1440 2560x1440 2560x1440
ppi
564 577 534 401 518
Display type
IPS AMOLED AMOLED IPS AMOLED
Pressure sensitive
No No No No No
Always on
No Optional Optional Optional No
mAh
3000 3000 3600 2800 3450
Fast charging
Yes Yes Yes Yes Yes
Wireless charging No No Yes Yes No No
Removable battery No No No No Yes No
Camera megapixels
12 12 12 16 12
Aperture (rear) f/
1.8 1.7 1.7 1.8 2
OIS
Yes Yes Yes Yes No
Processor
Snapdragon 820 Snapdragon 820 Snapdragon 820 Snapdragon 820 Snapdragon 810
RAM
4GB 4GB 4GB 4GB 3GB
Storage GB
32, 64 32, 64, 128 32, 64, 128 32 32, 64, 128
MicroSD
Yes Yes Yes Yes No
Fingerprint sensor
Yes Yes Yes Yes Yes
Water resistance
IP53 IP68 IP68 Yes No
Price
$650.00 $670.00 $790.00 $630.00 $500.00

Friday, June 17, 2016

Just_so_totally_arcane

Wow. Just so totally weird.

I finally deconflicted xinetd from Dovecot.

I've been working this for months:

Reboot the machine:

     xinetd starts
     Dovecot does not
     Check the logs
     Something is listening on dovecot's ports
     netstat -plnt
     The culprit is xinetd

How to prevent xinetd from listening on the desired ports?

ITOT you must INSTALL /etc/xinetd.d/imap

and then go into it and disable = yes

the services for which you do not want xinetd to listen. Is that backwards or what???

xinetd must have default listening conditions. If you don't explicitly tell it to ignore them then it grabs them and prevents anyone else from using them.

Sigh.

But at least now it is working.


Wednesday, June 15, 2016

Log into Chromium as a different user

Chromium requires "users" to be added. The users must have been created in Google accounts.

It creates a profile for each "user". The first user is "Default", the next is "Profile 1" and so on.

It stores the profiles in the Home directory. Under linux this is
/home/andy/.config/chromium/

It will start with the Default profile unless you give it something else. Do the following to open it with "Profile 1":
chromium --profile-directory="Profile 1"

You can add a text file (e.g., urls_treas.txt) containing the desired URLs to be opened on start:
chromium --profile-directory="Profile 1" --new-window $(cat /data/develop/bin/comms/urls_treas.txt) &

Friday, June 10, 2016

Red wine reduction sauce

This adaption of Joy of Cooking (p. 346) brown sauce is lovely over tenderloin, potatoes, and green beans. It can be reserved and adapted for lamb by adding rosemary. It sounds like a Bordelaise, but on steroids... :-) It helps if you have an herb garden. :-)

This quantity serves one person. Multiply linearly for more people.

Ingredients:

     2 cloves Fresh garlic
     ½ cup Fresh parsley
     6 leaves Fresh sage
     (1 tbsp Fresh rosemary leaves—for lamb)
     2 tbsp Fresh thyme leaves
     1 cup Heavy red (Malbec, Sangre de Toro, Cabernet Sauvignon) wine
     1 tbsp Beef Better than Bouillon (or two beef bouillon cubes, dissolved)
     ¼ Lemon
     4 dash Maggi sauce
     4 dash Worcestershire sauce
     2 tbsp (4 pats) Butter
     2 tbsp Extra virgin olive oil (e.g., Colavita)
     1 tbsp Black truffle olive oil (e.g., Virgin and Aged)

     ⅓ lb Tenderloin filet
     1 small (1½" diameter) red potato
     ½ cup "Exotic" mushrooms (e.g., shiitake, oyster, portabella, baby bella)
     ~24 French (or hand selected regular) green beans

Tools:
     Spatula
     Double boiler
     ½ quart sauce pan
     8" frying pan
     Whisk

Time:
     • Preparation ("sous-chef"):
          This takes about an hour: 15 minutes to slice, dice, and combine; 45 minutes to simmer, reduce,
           and combine, during which you prepare the remainder of the meal.

     • Combining, cooking and presenting:
          This takes about twenty minutes.

Sous-chef:

     • The potato takes the longest time. Remove the eyes from the potato and put it to boil in a saucepan (I prefer bottled water). Bring the water to boil (four minutes) then reduce to a simmer. After ten minutes turn the potato over.

     • The waterbased portion of the sauce is referred to as the "brown sauce":

          + Wash and dry the mushrooms and remove the stems
               - Cut off the bottom of the stems
               - Slice the mushroom caps (e.g., ¼" slices) and reserve

          + Finely mince garlic, mushroom stems, parsley, sage, (rosemary for lamb), thyme. Combine in a saucepan with wine.

          + Dissolve the bouillon in the liquid. Squeeze the lemon juice in. Add the dashes of Maggi and Worchester sauces.

     • Set to simmer on a very low (gas) heat with the top on for ten minutes to combine flavors and then another 35 minutes with the top off to reduce. Check at least every ten minutes to prevent burning.

     • Meanwhile combine butter, olive, and truffle oil in the top of a double boiler and set to simmer on low heat while the brown sauce reduces satisfactorily.

     • Prepare the rest of the meal while this simmering is going on:

          + Trim the tenderloin of any gristle

          + Trim the ends of the green beans

          + Heat the dinner plate (e.g., heat for 30 seconds in a microwave) and remove the potato when almost done. It will finish softening on the warm plate.

Combining, cooking and presenting:

     • Either wait until the reduction is to your satisfaction (e.g., ⅛ cup or less) or until about five minutes before you think it will—if you're in a hurry— put the green beans on to steam on a low heat. Beans take about fifteen minutes to be tender but still crunchy.

     • Five minutes after putting the beans on, start cooking the tenderloin in a small frying pan:

          1 tbsp Extra virgin olive oil
          Touch Truffle oil

          + Heat on high for about two minutes. Test with small droplets of water. Put the tenderloin in when the droplets start to sizzle. Wait 15 seconds and turn over to sear the meat then reduce the gas to ¾ and cover the pan.

          + Continue to cook for about three minutes, then turn over for another four minutes for medium rare. It is medium rare when it has the firmness of your palm edge under your thumb.

     • While this proceeds, squeeze the brown sauce into the top of the double boiler through a sieve and stir to combine with the butter and oil.

     • As the meat nears readiness remove the beans from the steamer and put on plate. Remove the meat when done and put on the plate.

     • Cook the mushrooms: Add a touch of water to the meat brownings in the frying pan and use a spatula to dissolve them (15 seconds). Return the heat to high and add the mushrooms. "Shuffle" the frying pan to keep the slices moving and not sticking, for about 30 seconds. As the liquid is absorbed pour the mushrooms over the tenderloin.

     • Giving the sauce a final whisk, pour it over all the elements.

     • Serve with a glass of aforesaid heavy red wine, candlelight, and friends.

Enjoy.

Tuesday, May 31, 2016

Gazpacho

Had a fun afternoon making gazpacho. It is so scorchy hot here in Newport that it reminds me of Spain.

Well, it's all relative. 65°F is scorchy hot in Newport at this time of year. Spain is more like 105°F. I know. I've been there.

Anyhow, fired up a glass of Jeréz Fino and proceeded to do the do.

Bottom line up front:

How long does it take? About thirty minutes, but if you use the Fino, it can take a while longer, but no more than an hour...

:-)



Adapted from p. 171 Joy of Cooking

Chilled clear soup full of fresh vegetables with fresh herbs.

Serves 6. Halve the recipe for one person.

Assemble:
4 garlic cloves
3 cups (2 cans) beef consommé
2 Beefsteak tomatoes or 4 tomatoes on the vine.
1 Sweet bell pepper
1 Cucumber
1 Spanish (red) onion
1 Lemon
1 cup or more of mixed chopped fresh herbs:
     Tarragon
     Parsley
     Basil
     Chervil
     (Cilantro appears too strong)
½ cup Extra Virgin Olive Oil

Remove top and root of garlic. Remove green germ from the center of the cloves:
     http://www.davidlebovitz.com/2014/01/should-you-remove-the-green-germ-from-garlic/
     Chop finely and set aside.

Blanch the tomatoes for 30 seconds, then immerse in cold water to remove the peel. Cut them in quarters and remove the seeds. Continue to dice them (~½" square dices) and set aside.

Halve the sweet pepper and remove seeds and blanched flesh. Continue to dice it (~½" square dices) and set aside.

Peel the cucumber. Slice lengthwise in half, us a teaspoon to scrape out the seeds. Dice it (~½" square dices) and set aside.

Chop off the root and top of the onion and peel it. Dice it (~½" square dices) and set aside.

Combine and chop the herbs finely.

Combine all of the above in a bowl (e.g., 2 quart bowl) and toss with a cooking spoon to mix the ingredients in a pretty colorful pattern. Reserve one scoop in a small bowl to use as garnish.

Put the remainder in a blender,

Add the consommé and olive oil and pulse lightly until uniform. Do not blend excessively.

Return to the 2 quart bowl and chill (with the reserved garnish) at least two hours.

To serve:
     Place in each bowl
          1 tablespoon chopped parsley
          ½ cup of the reserved garnish
     Add the soup.
     Season and garnish to taste. JOC suggests bread crumbs.
     Accompany with a Spanish Riója, chilled Sangria, or chilled dry sherry (Jeréz Fino).

Savory & James 'Fino' Dry Sherry

Saludos!