New York, NY, March 12th, 2015: Jeffrey Hayzlett, former Fortune 100 CMO, bestselling author and Bloomberg TV host, announced John Zaleski has been inducted into C-Suite Book Club, the premier source for the world’s leading business books for c-suite leaders, bus... Read More

View Next Project View Complete Portfolio

Book III–Connected Medical Devices–April 2015

Connected Medical Devices: Integrating Patient Care Data in Healthcare Systems. A new book by John Zaleski. This is my latest in the line of MDI texts, focused principally on the essentials of implementation. ... Read More

View Next Project View Complete Portfolio

Contributing Author–Dictionary of Computer Science, Engineering, and Technology

Zaleski, JR, (contributing Author), Dictionary of Computer Science, Engineering, and Technology, (CRC Press, Phil Laplante, Editor-in-Chief). ... Read More

View Next Project View Complete Portfolio

Book I–Integrating Device Data into the Electronic Medical Record

The seminal book on the medical device integration into health information technology systems. John Zaleski, Ph.D. A book on empirical practice of medical device interoperability, based on years of experience in the field. A Developer’s Guide to Design and a ... Read More

View Next Project View Complete Portfolio

Book II–Medical Device Data and Modeling for Clinical Decision Making

This work combines much of the experience learned in medical device interoperability and clinical informatics I have gained over the course of the past 20+ years. I have leveraged work from my  PhD and experience in product management of critical care. The devic... Read More

View Next Project View Complete Portfolio

PENN Dissertation ’96–Weaning from Postoperative Mechanical Ventilation

Modeling Post-Operative Respiratory State in Coronary Artery Bypass Graft Patients: A Method for Weaning Patients from Mechanical Ventilation. This PhD research developed a model for real-time assessment of patient postoperative recovery and viability for weaning f... Read More

View Next Project View Complete Portfolio

Latest happenings from the blog

View All Posts In My Blog »

Example of an Excel Macro-based Kalman Filter


Data and Kalman Filter trace on top of data

Data and Kalman Filter trace on top of data

Kalman Filter enumerated.

Kalman Filter enumerated.

Spin buttons associated with modifying process and measurement noise.

Spin buttons associated with modifying process and measurement noise.

Microsoft Excel is an extremely powerful computing tool. I have had a number of people contact me privately asking me to include examples of processing algorithms developed over the years. A key algorithm which I use and of which am fond is the Kalman Filter. In the figures above I provide a sample plot of raw data with the tracked values (estimated by the Kalman Filter) overlaid. Below this figure are included a screen snapshot of the columns of data and calculations associated with the filter. Finally, the screen snapshot below this includes the macro code associated with the spinner buttons used to adjust the process and measurement noise of the filter.

The code is saved in a macro-enabled workbook (.xlsm), included below as a download below:



Gauss-Markov Random Variate Noise Generation



Every so often different types of mathematical models require the modeling of imperfections or noise. The use of the normal distribution is commonly employed to represent the population of events and measurements about some sample mean with some sample standard deviation. In reality, nothing is truly normally-distributed — this is only an approximation. Furthermore, the use of pure Gaussian noise (“white noise”) is rarely the situation when it comes to physical events. More often than not, the use of a form of “colored” noise (i.e., normally-distributed random variates with a Markov “coloration”) is closer to the operational behavior of physical system.

This post focuses on a simple random noise generator, written in an MS Excel macro, that creates random variates using a Gauss-Markov process.

Sub CreateRand()
' (c) John Zaleski 15 March 2015
' Demonstration Macro to illustrate creation of normally-distributed random numbers
' with and without correlated noise.
' Demonstration uses a random number generator of normally-distributed random variates
' that provides the option to apply the previous random number to "color" the value of
' the new random number. This is a form of Gauss-Markov random noise model.
' Variable      Description
' ----------    ------------------------------------------------------------------------
' dt            Time interval between random variates
' i             For-Next loop counter
' StartCount    Start interval for random number generation
' EndCount      End interval for random number generation
' Offset        Offset value for counters to take into account first row label
' PRN           Previous random number
' sampleMean    Sample mean of Gaussian random variates
' sampleBeta    Sample Gauss-Markov noise "memory" terms. sampleBeta = 0 -> current
'               variates dependent on current random number plus previous random number;
'               sampleBeta = 100 -> newest measurements completely independent of
'               previous random number.
' sampleDev     Sample standard deviation of Gaussian random variates
    Dim dt As Double
        dt = 1#
    Dim StartCount As Integer
        StartCount = 1
    Dim EndCount As Integer
        EndCount = 100
    Dim Offset As Integer
        Offset = 2
    Dim PRN As Double

    Dim sampleBeta As Double
        sampleBeta = Worksheets("sheet1").Cells(1, 4)
    Dim sampleMean As Double
        sampleMean = Worksheets("sheet1").Cells(2, 4)
    Dim sampleDev As Double
        sampleDev = Worksheets("sheet1").Cells(3, 4)
    ' Create first row of random number entries
    Worksheets("sheet1").Cells(Offset, 1) = 0
    PRN = GaussMarkovNormalDist(0, _
                                sampleMean, _
                                sampleDev, _
                                dt, _
    Worksheets("sheet1").Cells(Offset, 2) = PRN
    ' create (EndCount-StartCount] random numbers
    For i = (Offset + StartCount) To (Offset + EndCount)
        Worksheets("sheet1").Cells(i, 1) = (i - Offset) * dt
        PRN = Worksheets("sheet1").Cells(i - 1, 2)
        Worksheets("sheet1").Cells(i, 2) = GaussMarkovNormalDist(PRN, _
                                                                 sampleMean, _
                                                                 sampleDev, _
                                                                 dt, _
End Sub

Function GaussMarkovNormalDist(Optional sPrev = 0#, _
                               Optional sMean As Double = 0#, _
                               Optional sDev As Double = 1#, _
                               Optional sDt = 0#, _
                               Optional beta = 1#)
' John Zaleski
' Uses Box-Muller method originally coded in <b>Numerical Recipes in C</b> by
' Donald Knuth etal.
' Summary Box-Muller Method:
' s = u*u + v*v
' while s == 0 or s >= 1
'  s = u*u + v*v
' wend
' z0 = u * sqrt( -2*ln(s)/s )
' z1 = v * sqrt( -2*ln(s)/s )
' z0, z1 are two independent & normally-distributed random numbers

    Dim u As Double
    Dim v As Double
    Dim s As Double
    Dim z As Double
    Dim g As Double

    ' get two uniform random variates

    u = 2# * Rnd - 1
    v = 2# * Rnd - 1
    s = u * u + v * v

    Do Until s <= 1
        u = 2# * Rnd - 1
        v = 2# * Rnd - 1
        s = u * u + v * v

    ' Box-Muller transformation

    z = u * Sqr((-2# * Log(s)) / s)

    ' translate into Gauss-Markov derivative
    ' Current random number + Previous random number de-weighted by time

    g = (sMean + sDev * z) + (sPrev * Exp(-beta * sDt))

    GaussMarkovNormalDist = g

End Function

In this model, the random number generator can be set to create Gaussian white noise or can be set to incorporate colored noise on top of the Gaussian white noise.

GMbeta1The following figure (left) shows the Excel Macro running with no Markov noise (i.e., beta set to 100 — effectively infinity). This is the case in which the current random variate is not dependent on the previous variate. In the following figure, the Markov variable (beta) is set to zero, implying that the current random variate is dependent only on the time interval between the previous measurement and the current measurement.

This time interval is set to 1 (unity). Hence, the current random variate is influenced by the previous measurement by the amount exp (-1):


X[i+1] = X[i] + X[i-1]*exp(-b*dt)


X[i] is the current Gaussian random variate;

X[i+1] is the new random variate;

X[i-1] is the previous random variate;

b (beta) is the Markov factor; and,

dt is the time interval between the previous and current measurement.



New Book 2015 | Connected medical devices



Connected Medical Devices: Integrating Patient Care Data in Healthcare Systems.

This is the latest in the line of books by John Zaleski on connected patient care devices. This text focuses on the practical aspects of implementing MDI in the hospital. Book contents are as follows:


  • The Mechanics of MDI;
  • Medical Device Driver Software;
  • The MDI Intermediary between the Medical Device and the Health IT system;
  •  Major MDI Solution Providers;
  • Vendor Agnostic Representation of MDI Solutions;
  • Some Tips on Selecting an MDI Solution; and,
  •  Chapter Summary.

Chapter 1: Medical Device Types and Classes Used in Hospital Departments and How They Communicate

  • Healthcare Enterprise Departments most often in need of MDI;
  • Medical Device Topologies;
  • Surgical Services Environments (Operating Room, OR; Post-Anesthesia Care Unit, PACU);
  • Essential OR Data Elements;
  • Parameter Transmission Intervals – OR;
  • Redundant Parameter Transmission;
  • Intensive Care Unit (ICUs) / Critical Care Units (CCUs);
  • Physiologic Monitors;
  •  Mechanical Ventilators;
  • Infusion Systems and Tourniquet Pumps;
  • Specialty Medical Devices;
  • Emergency Departments (EDs);
  • Medical Surgical / Step-Down Units;
  • Chapter Summary.

Chapter 2: MDI Solution Acquisition and Implementation

  • Starting the MDI acquisition process: build or buy
  • Building an MDI solution;
  • Acquiring an MDI solution;
  • The Request for Information (RFI) / Request for Proposal (RFP) Process;
  • Communicating Enterprise Requirements to MDI Solution Providers;
  •  Medical Device Driver Development & Timelines;
  • Communicating with the Health IT system;
  • Hospital Facilities and Enterprise Networking Requirements;
  • Building the MDI Implementation Team;
  • Project Management;
  • Staging the MDI Solution Implementation;
  • Assembling the MDI Implementation Team;
  • Estimating Timelines for MDI Implementation Completion;
  • Installation;
  • Testing;
  • Transition to go-live;
  • Chapter Summary.

Chapter 3: Semantic Data Alignment and Time Synchronization of Medical Devices

  • Interoperability Continuum;
  • Semantic Harmonization of Medical Device Data;
  • Temporal Alignment of Medical Device Data;
  • Validating Medical Device Data in the Health IT System Patient Chart;
  • Preparation for Go-Live Checklist; and,
  • Chapter Summary.

Chapter 4: Standards Surrounding Medical Device Integration to Health IT Systems

  • Medical Device Standards Specific to Medical Device Integration;
  • Health Level Seven (HL7) Standards Developing Organization;
  • IEEE 11073 Medical / Personal Health Device;
  • Health Level Seven (HL7) Observation Reporting;
  • Conditioning and Translating Connected Medical Device Data for IT System Consumption;
  • Patient Administration;
  • A Few Words About HL7 Fast Health Interoperable Resources;
  • Integrating the Healthcare Enterprise® (IHE);
  • Other Medical Device Integration-Related Standards; and,
  • Chapter Summary.

Chapter 5: Notification, Alerts & Clinical Uses of Medical Device Data

  • Interface Health and Status Notification and Technical Alerts;
  • Clinical Alerts and Notifications;
  • Aperiodic versus Periodic Data Collection;
  • Clinical Uses of Medical Device Data; and,
  • Chapter Summary.

Chapter 6: Patient Identification and Medical Device Association

  • Methods for Patient Identification;
  • Barcode and RFID;
  • Medical Device Association Workflows;
  • Chapter Summary.

Chapter 7: Regulatory and Security Considerations of MDI

  • Medical Device Data Systems (MDDS);
  • Regulatory Classification and Identification of Risk;
  • Medical Device Security;
  • IEC 80001;
  • Software Development Methodologies and Testing;
  • Chapter Summary.

Appendix A.1: Medical Device Quantity Planning Table

Appendix A.2: Testing Tools

Appendix A.3: HL7 Testing Simulator

Book Cover - Zaleski

Book III Cover



Wordpress SEO Plugin by SEOPressor

Switch to our mobile site