Saturday, January 11, 2014

How to calculate 95th percentile of values with grouping variable in Excel

Sample data:
     A            B           C          D
1 Watershed   WQ
2 50500101    62.370661    50500101     {formula here}
3 50500101    65.505046
4 50500101    58.741477
5 50500105    71.220034
6 50500105    57.917249
 
Excel formula in D2 :
 
{=PERCENTILE(IF($A2:$A6=C2, $B$2:$B$6), 0.95)} 

Also, be sure to enter the formula as an array formula. 
Do so by pressing Ctrl+Shift+Enter when entering the formula. 
 
http://stackoverflow.com/questions/5473537/how-to-calculate-95th-percentile-of-values-with-grouping-variable-in-r-or-excel

Wednesday, October 2, 2013

Reshape data in R



hsb2 <- br="" faq="" header="T," hsb2.csv="" http:="" r="" read.table="" sep="," stat="" www.ats.ucla.edu="">hsb2[1:10,]
l <- br="" hsb2="" reshape="">  varying = c("read", "write", "math", "science", "socst"),
  v.names = "score",
  timevar = "subj",
  times = c("read", "write", "math", "science", "socst"),
  new.row.names = 1:1000,
  direction = "long")

l[1:10,]
 
l.sort <- br="" id="" l="" order=""> 
l.sort[1:10,]

l.sort

w <- br="" l.sort="" reshape="">  timevar = "subj",
  idvar = c("id", "female", "race", "ses", "schtyp", "prog"),
  direction = "wide")
 
w

w[1:10,]

Saturday, September 7, 2013

Restoring iPod when you forgot your passcode

1. Connect your iPod to the computer where you normally sync your iPod.
2. Make a backup of the iPod (you will use this later when your restore the contents of the iPod)
3. Restore to factory setting, see: http://support.apple.com/kb/ht1808

Friday, June 28, 2013

Calculate Normal Distribution Using R



#:************************************************************************
#: Author: Alex Madriaga
#: Date: 06/06/2013
#: Time: 11:11:11
#: File: dnorm.r
#: Status: Working using the data in C:/workspace/ecdf/d176m.csv
#: Version: 0.98
#: Description: Latest version of the normal distribution for R scripting
#: Revision history:
#:
#:************************************************************************

# load the csv file, ignoring the header
mainDir <- "C:/workspace/ecdf"
setwd(mainDir)
mainDir <- getwd()
rawCSVFile <- "d176m.csv"
rsm <- read.csv(rawCSVFile,header=TRUE)

# check structure and convert vector values to numeric
str(rsm)
rsm$HEAP <- as.numeric(rsm$HEAP)

# calculate the mean and standard deviation
mean <- mean(rsm$HEAP)
sd <- sd(rsm$HEAP)

#plotting the density function of a normal distribution
heap <- rsm$HEAP

# plot the data
plot(heap, dnorm(heap, mean, sd), type="l")


Bash Script using Flags and Options


#!/bin/bash

#:########################################################################
#: The option-string
#:
#: The option-string tells getopts which options to expect and which of them
#: must have an argument. The syntax is very simple . every option character
#: is simply named as is, this example-string would tell getopts to look
#: for -e, -d and -m:
#:
#: getopts fAx VARNAME
#:
#: When you want getopts to expect an argument for an option, just place
#: a : (colon) after the proper option flag. If you want -e to expect an
#: argument (i.e. to become -e ENVIRONMENT ) just do:
#:
#: getopts ed:m VARNAME
#:
#:########################################################################

function checkParam()
{

  # if no paramter was supplied, show usage
  text="Usage: $0 -e ENVIRONMENT -d DATE_FILENAME.TXT -m METRIC_FILENAME.TXT" 
  [ $# -eq 0 ] && { echo "$text"; exit 1; }

  # parse the flags and options
  while getopts "e:d:m:" opt; do
    case $opt in
      e)
        echo "-$opt $OPTARG $OPTIND $OPTERR was triggered!" >&2
        env=$OPTARG
        ;;
      d)
     echo "-$opt $OPTARG $OPTIND $OPTERR was triggered!" >&2
        fdate=$OPTARG
        ;;
      m)
     echo "-$opt $OPTARG $OPTIND $OPTERR was triggered!" >&2
        fmetric=$OPTARG
        ;;
      *)
        echo "Invalid option: -$opt $OPTARG $OPTIND $OPTERR" >&2
        ;;
    esac
  done

  # show the flags and options that were parsed
  echo "Environment: [$env]"
  echo "Date filename: [$fdate]"
  echo "Metric filename: [$fmetric]"

  # Check the given files exist #
  [ ! -f "$fdate" ] && { echo "Error: $fdate file not found."; exit 2; }
  [ ! -f "$fmetric" ] && { echo "Error: $fmetric file not found."; exit 2; }

  # Check the given files are not empty #
  [ ! -s "$fdate" ] && { echo "Error: $fdate file is empty."; exit 2; }
  [ ! -s "$fmetric" ] && { echo "Error: $fmetric file is empty."; exit 2; }
}

#: ## [ MAIN ] ###
checkParam $@



Sunday, June 23, 2013

Enable SSH on WD MyBook

Link
       

To login use /UI/login, example: http://192.168.1.150/UI/login

Open Mybook UI go to Import / Export Current 
Configuration (under Utilities)

Export the current configuration, open the file, update: 
ssh_enable="disabled", to ssh_enable="enabled", import 
the configuration file

After reboot SSH is enabled.

Default is root / welc0me as per other WD devices.

Change root password right away.


If you want to enable SFTP, modify /etc/ssh/sshd_config 
and add the user who needs to access through SFTP. 
For example: “AllowUsers root malex” enables the user 
“malex” to connect to the device by both ssh and sftp.

Twonky is available at port 9000, example: http://192.168.1.150:9000
FTP when enabled is available using the user you created.

Saturday, June 22, 2013

Load a CSV file and plot the normal distribution curve



# load the csv file, ignoring the header
mainDir <- "C:/workspace/ecdf"
setwd(mainDir)
mainDir <- getwd()
rawCSVFile <- "heap.csv"
rsm <- read.csv(rawCSVFile,header=TRUE)

# check structure and convert vector values to numeric
str(rsm)
rsm$HEAP <- as.numeric(rsm$HEAP)

# calculate the mean and standard deviation
mean <- mean(rsm$HEAP)
sd <- sd(rsm$HEAP)

#plotting the density function of a normal distribution
heap <- rsm$HEAP

# plot the data
plot(heap, dnorm(heap, mean, sd), type="l")


Wednesday, June 19, 2013

Theory on Cross- over ratio of powers

My theory is that the ratio of the electrical power with respect to the software power is constant .Thus, the economics of cost is easily computed in terms of monies.

Theory on Electrical power vs. Soft power

The power consumed by the server and all the devices connected to the whole application platform expressed in electrical Watts is proportional to the power generated by the server expressed in S-WATTS or soft watts or watts subscript small s. This power must also be equal to the power consumed by the users at the receiving end.

Tuesday, June 18, 2013

Theory on Powet factor correction on JVM

Having understood that the JVM is indeed comparable with an AC generator, we are now able to calculate the power factor and efficiency of the server using the vast theories and formula in electrical engineering.

Calculation of R on a system

To measure the R constant of the system, we need to conduct several heap samples at varying number of users. Then calculate the R constant based on the empirical data. That is, R is equal to HSU divided by users.