Skip to content

Instantly share code, notes, and snippets.

View AngelBerihuete's full-sized avatar
🌳

A. Berihuete AngelBerihuete

🌳
View GitHub Profile
@AngelBerihuete
AngelBerihuete / EmpiricalDualElasticity.R
Last active October 13, 2016 10:49
R function to calculate elasticity of the dual Lorenz curve
EmpiricalDualElasticity <- function(dataset){
# ###########################################################################
# R function to calculate elasticity of the dual Lorenz curve
# ---------------------------------------------------------
#
# Authors: Berihuete, A.; Ramos, C.D; Sordo, M.A. and Ramos, H.
#
# input: a dataset formatted with rtip package (https://cran.r-project.org/web/packages/rtip/)
#
# output: abscissas and ordinates of the elasticiy of the dual Lorenz curve.
Existe un problema cuando se instala Rmath en julia (OpenSUSE)
julia> Pkg.build("Rmath")
INFO: Building Rmath
INFO: Attempting to Create directory /home/angel/.julia/v0.5/Rmath/deps/downloads
INFO: Directory /home/angel/.julia/v0.5/Rmath/deps/downloads already created
INFO: Downloading file https://github.com/JuliaLang/Rmath-julia/archive/v0.1.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (77) error setting certificate verify locations:
@AngelBerihuete
AngelBerihuete / mvnormal-extension.py
Created July 12, 2016 10:52 — forked from brandonwillard/mvnormal-extension.py
Somewhat fixed MvNormal implementation
from scipy import stats
from theano.tensor.nlinalg import det, matrix_inverse, trace, eigh
from pymc3 import transforms
from pymc3.distributions.distribution import Continuous, Discrete, draw_values, generate_samples
from pymc3.distributions.special import gammaln, multigammaln
from pymc3.distributions.dist_math import bound, logpow, factln
class MvNormal(Continuous):
r"""
@AngelBerihuete
AngelBerihuete / tab_trans.py
Created June 1, 2016 12:25 — forked from PBarmby/tab_trans.py
Transpose tables in astropy
import numpy as np
from astropy.table import Table, Column
def transpose_table(tab_before, id_col_name='ID'):
'''Returns a copy of tab_before (an astropy.Table) with rows and columns interchanged
id_col_name: name for optional ID column corresponding to
the column names of tab_before'''
# contents of the first column of the old table provide column names for the new table
# TBD: check for duplicates in new_colnames & resolve
new_colnames=tuple(tab_before[tab_before.colnames[0]])
# Multiple plot function
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
#
@AngelBerihuete
AngelBerihuete / query_argonaut.pro
Created May 2, 2016 16:30 — forked from gregreen/query_argonaut.pro
Query Argonaut Server (for 3D Dust Map)
;+
; NAME:
; query_argonaut
;
; PURPOSE:
; Query the Argonaut server for 3D dust information or SFD
;
; CALLING SEQUENCE:
; qresult = query_argonaut(/struct, /debug, _extra=coords)
;
#Load library mass and set seed
library(MASS)
set.seed(100)
# We are going to use 3 random variables
m <- 3
# Number of samples to be drawn
n <- 2000
@AngelBerihuete
AngelBerihuete / rgl_installation_R.txt
Created February 18, 2016 09:21
Problems with glu.h in the installation of rgl package under Linux OpenSuse distribution
When yo try to install rgl in R you have an error about glu.h
%%%%%%%%%%%%%%%
checking GL/glu.h usability... no
checking GL/glu.h presence... no
checking for GL/glu.h... no
configure: error: missing required header GL/glu.h
ERROR: configuration failed for package ‘rgl’
* removing ‘/home/angel/R/x86_64-suse-linux-gnu-library/3.2/rgl’
Warning in install.packages :
library(MCMCpack)
x <- 0.5
shape <- 2
scale <- 3
dinvgamma(x, shape, scale)
#from scipy.stats import invgamma
@AngelBerihuete
AngelBerihuete / server.R
Last active August 29, 2015 14:08 — forked from yihui/server.R
library(shiny)
shinyServer(function(input, output) {
# Make three independent, repeatable copies of rnorm so that the underlying
# random values don't change
rnorm1 = repeatable(rnorm)
rnorm2 = repeatable(rnorm)
rnorm3 = repeatable(rnorm)