Skip to content

Instantly share code, notes, and snippets.

@jverzani
jverzani / Rts.jl
Last active April 17, 2018 16:24
modify Roots to work with Unitful
## new framework for Roots
module Rts
using Compat
if VERSION < v"0.7.0"
using Missings
end
using ForwardDiff
@jverzani
jverzani / amvw.jl
Last active March 7, 2017 03:26
Julia implementation of AMVW algorithm
module AMVW
## Julia implementation of
## Fast and backward stable computation of roots of polynomials
## https://lirias.kuleuven.be/bitstream/123456789/461961/1/TW654.pdf
## Derived from fortran code https://people.cs.kuleuven.be/~raf.vandebril/homepage/software/companion_qr.php?menu=5
## License is unclear, but hopefully can be MIT licensed
## TODO
## handle case on non convergence
@jverzani
jverzani / gist:7207719
Created October 29, 2013 01:22
plot_interfaces.jl updated for mplot, oplot
## Various possible plot interfaces
## Plot interfaces for functions
## plot(x, [y], args..., kwargs...) lineplot
## plot(x::Tuple{Vector}, args...; kwargs) scatter plot
## plot(f, a::Real, b::Real, args...; kwargs) function plot using adaptive point, a, b length two atleast
## plot(fs::Vector{Function}, a::Real, b::Real, args...; kwargs) function plot, overlay
## plot(fs::Array{Function, 2}, a::Real, b::Real, args...; kwargs...) table of plots
@jverzani
jverzani / factor-editor.R
Last active December 20, 2015 09:40
Mock up of factor editor for gdf
##' I want
##' * relabel a factor
##' * collapse one or more factors
##' * append a level to a factor
##' * Select a factor to be the reference
##' * reorder factors (and make ordered along the way)
##'
##'
library(gWidgets2)
@jverzani
jverzani / D.jl
Last active December 11, 2015 02:29
Julia functions for MTH 229. These functions are used to illustrate some basic algorithms used for numerical approximations to calculus.
module ADiff
## Code to take automatic derivative modeled after
## http://www.davidson.edu/math/neidinger/SIAMRev74362.pdf Numeric
## derivatives via finite differences have errors due to the
## mathematical approximation and the floating point approximation,
## that latter can be large as most compuations end with a difference
## of similar-sized values. Automatic derivatives avoid this, by
## adding information to each step of a function evaluation to also
## evalute the derivative. Errors are due to floating point
@jverzani
jverzani / Comments.md
Created November 3, 2012 22:02
Some comparisons using shiny and gWidgetsWWW2

RStudio developers are really hard working. Somehow in their spare time they have worked on their shiny package for making interactive web pages. This gist compares writing a shiny web app to writing a similar app using gWidgetsWWW2.rapache. We only look here at the code, not the deployment. In general, deploying a shiny app widely seems best suited for RStudio's service, currently in beta, though clearly a local shiny app is also quite useful. Deploying an app under gWidgetsWWW2.rapache is fairly easy -- though not very widely tested.

We follow the tkdensity.R GUI from the tcltk package for comparison. This is a standard example with some controls and a resulting graphic. It is right up shiny's alley. We compare to the manipulate commands which mimic RStudio's manipulate pacakge and to straight gWidgetss:

There are 4 files:

  • a file showing how to do this with manipulate (this is an example from the gWidgetsWWW2.rapache package)
  • a file showing gWidgetsWWW2.rapache style (both have a w
@jverzani
jverzani / singleton
Created March 1, 2012 22:19
example of singleton pattern
## Singleton pattern
Singleton <- setRefClass("Singleton",
fields=list(
Class="ANY",
instance="ANY"
),
methods=list(
initialize=function(...) {
"Override this by defining Class"
@jverzani
jverzani / simex.R
Created February 17, 2012 04:17
Simluation code for manipulate
library(manipulate)
svalue <- identity
runSim <- function(nSamples, sizeSample, thePop, theStat, plotSamps, plotDist, plotPop) {
m <- svalue(nSamples)
n <- svalue(sizeSample)
pop <- svalue(thePop)
stat <- svalue(theStat)