text:
User's Guide
PDF
Top

Installation Guide
User's Guide
Version 8.2

Expand All
Contract All

Chapters

• Installing the Binary Release
• Building and Installing Erlang/OTP
• Cross Compiling Erlang/OTP
• How to Build Erlang/OTP on Windows
• Patching OTP Applications

4 How to Build Erlang/OTP on Windows

4.1  Introduction

This section describes how to build the Erlang emulator and the OTP libraries on Windows. Note that the Windows binary releases are still a preferred alternative if one does not have Microsoft’s development tools and/or don’t want to install Cygwin, MSYS or MSYS2.

The instructions apply to versions of Windows supporting the Cygwin emulated gnuish environment or the MSYS or MSYS2 ditto. We’ve built on the following platforms: Windows 2012, Windows 7, Windows 8 and Windows 10. It’s probably possible to build on older platforms too, but you might not be able to install the appropriate Microsoft SDK, Visual Studio or OpenSSL, in which case you will need to go back to earlier compilers etc.

The procedure described uses either Cygwin, MSYS or MSYS2 as a build environment. You run the bash shell in Cygwin/MSYS/MSYS2 and use the gnu make/configure/autoconf etc to do the build. The emulator C-source code is, however, mostly compiled with Microsoft Visual C++™, producing a native Windows binary. This is the same procedure as we use to build the pre-built binaries. Why we use VC++ and not gcc is explained further in the FAQ section.

If you are not familiar with Cygwin, MSYS, MSYS2 or a Unix environment, you’ll probably need to read up a bit on how that works. There are plenty of documentation about this online.

These instructions apply for both 32-bit and 64-bit Windows. Note that even if you build a 64-bit version of Erlang, most of the directories and files involved are still named win32. Some occurances of the name win64 are however present. The installation file for a 64-bit Windows version of Erlang, for example, is otp_win64_19.exe.

If you feel comfortable with the environment and build system, and have all the necessary tools, you have a great opportunity to make the Erlang/OTP distribution for Windows better. Please submit any suggestions to our JIRA and patches to our git project to let them find their way into the next version of Erlang. If making changes to the build system (like makefiles etc) please bear in mind that the same makefiles are used on Unix/VxWorks, so that your changes don't break other platforms. That of course goes for C-code too; system specific code resides in the $ERL_TOP/erts/emulator/sys/win32 and$ERL_TOP/erts/etc/win32 directories mostly. The $ERL_TOP/erts/emulator/beam directory is for common code. We've used this build procedure for a couple of releases, and it has worked fine for us. Still, there might be all sorts of troubles on different machines and with different setups. We'll try to give hints wherever we've encountered difficulties, but please share your experiences by using the erlang-questions mailing list. We cannot, of course, help everyone with all their issues, so please try to solve such issues and submit solutions/workarounds. Lets go then! We’ll start with a short version of the setup procedure, followed by some FAQ, and then we’ll go into more details of the setup. 4.2 Short Version In the following sections, we've described as much as we could about the installation of the tools needed. Once the tools are installed, building is quite easy. We have also tried to make these instructions understandable for people with limited Unix experience. Cygwin/MSYS/MSYS2 is a whole new environment to some Windows users, why careful explanation of environment variables etc seemed to be in place. This is the short story though, for the experienced and impatient: • Get and install complete Cygwin (latest), complete MinGW with MSYS or complete MSYS2 • Install Visual Studio 12.0 (2013) • Install Microsofts Windows SDK 8.1 • Get and install Sun's JDK 1.6.0 or later • Get and install NSIS 2.01 or later (up to 2.46 tried and working) • Get, build and install OpenSSL 0.9.8r or later (up to 1.0.2d tried & working) with static libs. • Get the Erlang source distribution (from http://www.erlang.org/download.html) and unpack with Cygwin's/MSYS's/MSYS2's tar. • Set ERL_TOP to where you unpacked the source distribution •$ cd $ERL_TOP • Modify PATH and other environment variables so that all these tools are runnable from a bash shell. Still standing in$ERL_TOP, issue the following commands (for 32-bit Windows, remove the x64 from the first row and change otp_win64_19 to otp_win32_19 on the last row):

$eval ./otp_build env_win32 x64$ ./otp_build autoconf
$./otp_build configure$ ./otp_build boot -a
$./otp_build release -a$ ./otp_build installer_win32
$release/win32/otp_win64_19 /S Voila! Start->Programs->Erlang OTP 19->Erlang starts the Erlang Windows shell. 4.3 Frequently Asked Questions • Q: So, now I can build Erlang using GCC on Windows? A: No, unfortunately not. You'll need Microsoft's Visual C++ still. A Bourne-shell script (cc.sh) wraps the Visual C++ compiler and runs it from within the Cygwin environment. All other tools needed to build Erlang are free-ware/open source, but not the C compiler. The Windows SDK is however enough to build Erlang, you do not need to buy Visual C++, just download the SDK (SDK version 8.1 == Visual studio 2013). • Q: Why haven't you got rid of VC++ then, you ******? A: Well, partly because it's a good compiler - really! Actually it's been possible in late R11-releases to build using mingw instead of visual C++ (you might see the remnants of that in some scripts and directories). Unfortunately the development of the SMP version for Windows broke the mingw build and we chose to focus on the VC++ build as the performance has been much better in the VC++ versions. The mingw build will possibly be back, but as long as VC++ gives better performance, the commercial build will be a VC++ one. • Q: OK, you need VC++, but now you've started to demand a quite recent (and expensive) version of Visual Studio. Why? A: Well, it's not expensive, it's free (as in free beer). Just download and install the latest Windows SDK from Microsoft and all the tools you need are there. The included debugger (WinDbg) is also quite usable. That's what I used when porting Erlang to 64bit Windows. Another reason to use later Microsoft compilers is DLL compatibility. DLL's using a new version of the standard library might not load if the VM is compiled with an old VC++ version. So we should aim to use the latest freely available SDK and compiler. • Q: Can/will I build a Cygwin binary with the procedure you describe? A: No, the result will be a pure Windows binary, and as far as I know, it's not possible to make a Cygwin binary yet. That is of course something desirable, but there are still some problems with the dynamic linking (dynamic Erlang driver loading) as well as the TCP/IP emulation in Cygwin, which, I'm sure of, will improve, but still has some problems. Fixing those problems might be easy or might be hard. I suggest you try yourself and share your experience. No one would be happier if a simple ./configure && make would produce a fully fledged Cygwin binary. • Q: Hah, I saw you, you used GCC even though you said you didn't! A: OK, I admit, one of the files is compiled using Cygwin's or MinGW's GCC and the resulting object code is then converted to MS VC++ compatible coff using a small C hack. It's because that particular file, beam_emu.c benefits immensely from being able to use the GCC labels-as-values extension, which boosts emulator performance by up to 50%. That does unfortunately not (yet) mean that all of OTP could be compiled using GCC. That particular source code does not do anything system specific and actually is adopted to the fact that GCC is used to compile it on Windows. • Q: So now there's a MS VC++ project file somewhere and I can build OTP using the nifty VC++ GUI? A: No, never. The hassle of keeping the project files up to date and do all the steps that constitute an OTP build from within the VC++ GUI is simply not worth it, maybe even impossible. A VC++ project file for Erlang/OTP will never happen. • Q: So how does it all work then? A: Cygwin, MSYS or MSYS2 is the environment, which closely resembles the environment found on any Unix machine. It's almost like you had a virtual Unix machine inside Windows. Configure, given certain parameters, then creates makefiles that are used by the environment's gnu-make to built the system. Most of the actual compilers etc are not, however, Cygwin/MSYS/MSYS2 tools, so we've written a couple of wrappers (Bourne-shell scripts), which reside in$ERL_TOP/etc/win32/cygwin_tools and $ERL_TOP/etc/win32/msys_tools. They all do conversion of parameters and switches common in the Unix environment to fit the native Windows tools. Most notable is of course the paths, which in Cygwin/MSYS/MSYS2 are Unix-like paths with "forward slashes" (/) and no drive letters. The Cygwin specific command cygpath is used for most of the path conversions in a Cygwin environment. Other tools are used (when needed) in the corresponding MSYS and MSYS2 environment. Luckily most compilers accept forward slashes instead of backslashes as path separators, but one still have to get the drive letters etc right, though. The wrapper scripts are not general in the sense that, for example, cc.sh would understand and translate every possible gcc option and pass correct options to cl.exe. The principle is that the scripts are powerful enough to allow building of Erlang/OTP, no more, no less. They might need extensions to cope with changes during the development of Erlang, and that's one of the reasons we made them into shell-scripts and not Perl-scripts. We believe they are easier to understand and change that way. In$ERL_TOP, there is a script called otp_build. That script handles the hassle of giving all the right parameters to configure/make and also helps you set up the correct environment variables to work with the Erlang source under Cygwin/MSYS/MSYS2.

• Q: You use and need Cygwin, but then you haven't taken the time to port Erlang to the Cygwin environment but instead focus on your commercial release, is that really ethical?

A: No, not really, but see this as a step in the right direction.

• Q: Can I build something that looks exactly as the commercial release?

A: Yes, we use the exact same build procedure.

• Q: Which version of Cygwin/MSYS/MSYS2 and other tools do you use then?

A: For Cygwin, MSYS and MSYS2 alike, we try to use the latest releases available when building. What versions you use shouldn't really matter. We try to include workarounds for the bugs we've found in different Cygwin/MSYS/MSYS2 releases. Please help us add workarounds for new Cygwin/MSYS/MSYS2-related bugs as soon as you encounter them. Also please do submit bug reports to the appropriate Cygwin, MSYS and/or MSYS2 developers. The GCC we used for 19 was version 4.8.1 (MinGW 32bit) and 4.8.5 (MSYS2 64bit). We used VC++ 12.0 (i.e. Visual studio 2013), Sun's JDK 1.6.0_45 (32bit) and Sun's JDK 1.7.0_1 (64bit), NSIS 2.46, and Win32 OpenSSL 1.0.2d. Please read the next section for details on what you need.

• Q: Can you help me setup X in Cygwin/MSYS/MSYS2?

A: No, unfortunately we haven't got time to help with Cygwin/MSYS/MSYS2 related user problems, please read related websites, newsgroups and mailing lists.

4.4  Tools you Need and Their Environment

You need some tools to be able to build Erlang/OTP on Windows. Most notably you'll need Cygwin, MSYS or MSYS2, Visual Studio and Microsofts Windows SDK, but you might also want a Java compiler, the NSIS install system and OpenSSL. Well, here's some information about the different tools:

• Cygwin, the very latest is usually best. Get all the development tools and of course all the basic ditto. Make sure to get jar and also make sure not to install a Cygwin'ish Java, since the Cygwin jar command is used but Sun's Java compiler and virtual machine.

If you are going to build a 64bit Windows version, you should make sure to get MinGW's 64bit gcc installed with Cygwin. It's in one of the development packages.

Get the installer from the website and use it to install Cygwin. Be sure to have fair privileges. If you're on an NT domain you should consider running mkpasswd -d and mkgroup -d after the installation to get the user databases correct. See their respective manual pages.

When you start your first bash shell, you will get an awful prompt. You might also have a PATH environment variable that contains backslashes and such. Edit $HOME/.profile and$HOME/.bashrc to set fair prompts and a correct PATH. Also do an export SHELL in .profile. For some non-obvious reason the environment variable $SHELL is not exported in bash. Also note that .profile is run at login time and .bashrc when sub shells are created. You'll need to explicitly source .bashrc from .profile if you want the commands there to be run at login time (like setting up aliases, shell functions and the like). You can for example do like this at the end of .profile: ENV=$HOME/.bashrc
export ENV
. $ENV You might also want to setup X-windows (XFree86). That might be as easy as running startx from the command prompt and it might be much harder. Use Google to find help. If you don't use X-windows, you might want to setup the Windows console window by selecting properties in the console system menu (upper left corner of the window, the Cygwin icon in the title bar). Especially setting a larger screen buffer size (lines) is useful as it gets you a scrollbar so you can see whatever error messages that might appear. There are a few other shells available, but in all examples below we assume that you use bash. • Alternatively you download MinGW and MSYS. You'll find the latest installer at: Make sure to install the basic dev tools, but avoid the MinGW autoconf and install the msys one instead. To be able to build the 64bit VM, you will also need the 64bit MinGW compiler from: We've tried up to 1.0, but the latest version should do. Make sure you download the mingw-w64-bin_i686-mingw_<something>.zip, not a linux version. You unzip the package on top of your MinGW installation (c:\MinGW) and that's it. • A third alternative is to download and install MSYS2 from: When you've followed the instructions there, you also need to install these packages: autoconf, make, perl, and tar. You do so by running the following in the msys console: pacman -S msys/autoconf msys/make msys/perl msys/tar You also need a gcc. If you installed the 64 bit MSYS2 you run: mingw64/mingw-w64-x86_64-gcc And for 32 bit MSYS2: pacman -S mingw32/mingw-w64-i686-gcc pacman -S mingw-w64-i686-editrights • Visual Studio 2013 (Visual Studio 12.0). Download and run the web installer from: https://www.visualstudio.com/ • Microsofts Windows SDK version 8.1 (corresponding to VC++ 12.0 and Visual Studio 2013). You'll find it here: • To help setup the environment, there is a bat file, %PROGRAMFILES%\Mirosoft Visual Studio 12.0\VC\vcvarsall.bat, that set's the appropriate environment for a Windows command prompt. This is not appropriate for bash, so you'll need to convert it to bash-style environments by editing your .bash_profile. In my case, where the SDK is installed in the default directory and %PROGRAMFILES% is C:\Program Files, the commands for setting up a 32bit build environment (on a 64bit or 32bit machine) look like this (in Cygwin): # Some common paths C_DRV=/cygdrive/c PRG_FLS=$C_DRV/Program\ Files

# nsis
NSIS_BIN=$PRG_FLS/NSIS # java JAVA_BIN=$PROGRAMFILES/Java/jdk1.7.0_02/bin

##
## MS SDK
##

VISUAL_STUDIO_ROOT=$PRG_FLS/Microsoft\ Visual\ Studio\ 12.0 WIN_VISUAL_STUDIO_ROOT="C:\\Program Files\\Microsoft Visual Studio 12.0" SDK=$PRG_FLS/Windows\ Kits/8.1
WIN_SDK="C:\\Program Files\\Windows Kits\\8.1"

PATH="$NSIS_BIN:\$VISUAL_STUDIO_ROOT/VC/bin:\
$VISUAL_STUDIO_ROOT/VC/vcpackages:\$VISUAL_STUDIO_ROOT/Common7/IDE:\
$VISUAL_STUDIO_ROOT/Common7/Tools:\$SDK/bin/x86
/usr/local/bin:/usr/bin:/bin:\
/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:\
/cygdrive/c/WINDOWS/system32/Wbem:\
$JAVA_BIN" LIBPATH="$WIN_VISUAL_STUDIO_ROOT\\VC\\lib"

LIB="$WIN_VISUAL_STUDIO_ROOT\\VC\\lib\\;$WIN_SDK\\lib\\winv6.3\\um\\x86"

INCLUDE="$WIN_VISUAL_STUDIO_ROOT\\VC\\include\\;$WIN_SDK\\include\\shared\\;\
$WIN_SDK\\include\\um;$WIN_SDK\\include\\winrt\\;$WIN_SDK\\include\\um\\gl" export CYGWIN PATH LIBPATH LIB INCLUDE If you're using MinGW's MSYS instead, you need to change the C_DRV setting, which would read: C_DRV=/c and you also need to change the PATH environment variable to: MINGW_BIN=/c/MinGW/bin PATH="$NSIS_BIN:\
$VISUAL_STUDIO_ROOT/VC/bin:\$VISUAL_STUDIO_ROOT/VC/vcpackages:\
$VISUAL_STUDIO_ROOT/Common7/IDE:\$VISUAL_STUDIO_ROOT/Common7/Tools:\
$SDK/bin/x86:/usr/local/bin:\$MINGW_BIN:\
/bin:/c/Windows/system32:/c/Windows:\
/c/Windows/System32/Wbem:\
$JAVA_BIN" For MSYS2 you use the same C_DRV and PATH as for MSYS, only update the MINGW_BIN: MINGW_BIN=/mingw32/bin If you are building a 64 bit version of Erlang, you should set up PATHs etc a little differently. We have two templates to make things work in both Cygwin and MSYS but needs editing to work with MSYS2 (see the comments in the script). The following one is for 32 bits: make_winpath() { P=$1
if [ "$IN_CYGWIN" = "true" ]; then cygpath -d "$P"
else
(cd "$P" && /bin/cmd //C "for %i in (".") do @echo %~fsi") fi } make_upath() { P=$1
if [ "$IN_CYGWIN" = "true" ]; then cygpath "$P"
else
echo "$P" | /bin/sed 's,^$$[a-zA-Z]$$:\\,/\L\1/,;s,\\,/,g' fi } # Some common paths if [ -x /usr/bin/msys-?.0.dll ]; then # Without this the path conversion won't work COMSPEC='C:\Windows\System32\cmd.exe' MSYSTEM=MINGW32 # Comment out this line if in MSYS2 export MSYSTEM COMSPEC # For MSYS2: Change /mingw/bin to the msys bin dir on the line below PATH=/usr/local/bin:/mingw/bin:/bin:/c/Windows/system32:\ /c/Windows:/c/Windows/System32/Wbem C_DRV=/c IN_CYGWIN=false else PATH=/ldisk/overrides:/usr/local/bin:/usr/bin:/bin:\ /usr/X11R6/bin:/cygdrive/c/windows/system32:\ /cygdrive/c/windows:/cygdrive/c/windows/system32/Wbem C_DRV=/cygdrive/c IN_CYGWIN=true fi obe_otp_gcc_vsn_map=" .*=>default " obe_otp_64_gcc_vsn_map=" .*=>default " # Program Files PRG_FLS=$C_DRV/Program\ Files

# Visual Studio
VISUAL_STUDIO_ROOT=$PRG_FLS/Microsoft\ Visual\ Studio\ 12.0 WIN_VISUAL_STUDIO_ROOT="C:\\Program Files\\Microsoft Visual Studio 12.0" # SDK SDK=$PRG_FLS/Windows\ Kits/8.1
WIN_SDK="C:\\Program Files\\Windows Kits\\8.1"

# NSIS
NSIS_BIN=$PROGRAMFILES/NSIS # Java JAVA_BIN=$PROGRAMFILES/Java/jdk1.7.0_02/bin

## The PATH variable should be Cygwin'ish
VCPATH=
$VISUAL_STUDIO_ROOT/VC/bin:\$VISUAL_STUDIO_ROOT/VC/vcpackages:\
$VISUAL_STUDIO_ROOT/Common7/IDE:\$VISUAL_STUDIO_ROOT/Common7/Tools:\
$SDK/bin/x86 ## Microsoft SDK libs LIBPATH=$WIN_VISUAL_STUDIO_ROOT\\VC\\lib

LIB=$WIN_VISUAL_STUDIO_ROOT\\VC\\lib\\;$WIN_KITS\\lib\\winv6.3\\um\\x86

INCLUDE=$WIN_VISUAL_STUDIO_ROOT\\VC\\include\\;\$WIN_KITS\\include\\shared\\;$WIN_KITS\\include\\um;\$WIN_KITS\\include\\winrt\\;$WIN_KITS\\include\\um\\gl # Put nsis, c compiler and java in path export PATH=$VCPATH:$PATH:$JAVA_BIN:$NSIS_BIN # Make sure LIB and INCLUDE is available for others export LIBPATH LIB INCLUDE The first part of the 64 bit template is identical to the 32 bit one, but there are some environment variable differences: # Program Files PRG_FLS64=$C_DRV/Program\ Files
PRG_FLS32=$C_DRV/Program\ Files\ $$x86$$ # Visual Studio VISUAL_STUDIO_ROOT=$PRG_FLS32/Microsoft\ Visual\ Studio\ 12.0
WIN_VISUAL_STUDIO_ROOT="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0"

# SDK
SDK=$PRG_FLS32/Windows\ Kits/8.1 WIN_SDK="C:\\Program Files (x86)\\Windows Kits\\8.1" # NSIS NSIS_BIN=$PROGRAMFILES/NSIS
# Java
JAVA_BIN=$PROGRAMFILES/Java/jdk1.7.0_02/bin ## The PATH variable should be Cygwin'ish VCPATH=$VISUAL_STUDIO_ROOT/VC/bin/amd64:\
$VISUAL_STUDIO_ROOT/VC/vcpackages:\$VISUAL_STUDIO_ROOT/Common7/IDE:\
$VISUAL_STUDIO_ROOT/Common7/Tools:\$SDK/bin/x86

## Microsoft SDK libs
LIBPATH=$WIN_VISUAL_STUDIO_ROOT\\VC\\lib\\amd64 LIB=$WIN_VISUAL_STUDIO_ROOT\\VC\\lib\\amd64\\;\
$WIN_KITS\\lib\\winv6.3\\um\\x64 INCLUDE=$WIN_VISUAL_STUDIO_ROOT\\VC\\include\\;\
$WIN_KITS\\include\\shared\\;$WIN_KITS\\include\\um;\
$WIN_KITS\\include\\winrt\\;$WIN_KITS\\include\\um\\gl

# Put nsis, c compiler and java in path
export PATH=$VCPATH:$PATH:$JAVA_BIN:$NSIS_BIN

# Make sure LIB and INCLUDE is available for others
export LIBPATH LIB INCLUDE

Make sure to set the PATH so that NSIS and Microsoft SDK is found before the MSYS/Cygwin tools and that Java is last in the PATH.

Make a simple hello world and try to compile it with the cl command from within bash. If that does not work, your environment needs fixing. Remember, there should be no backslashes in your path environment variable in Cygwin bash, but LIB and INCLUDE should contain Windows style paths with semicolon, drive letters and backslashes.

• Sun's Java JDK 1.6.0 or later. Our Java code (jinterface, ic) is written for JDK 1.6.0. Get it for Windows and install it, the JRE is not enough. If you don't care about Java, you can skip this step. The result will be that jinterface is not built.

Add javac LAST to your path environment in bash, in my case this means:

PATH="$PATH:/cygdrive/c/Program Files/Java/jdk1.7.0_02/bin" No CLASSPATH or anything is needed. Type javac in the bash prompt and you should get a list of available Java options. Make sure, e.g by typing type java, that you use the Java you installed. Note however that Cygwin's/MinGW's/MSYS2's jar.exe is used. That's why the JDK bin-directory should be added last in the PATH. • Nullsoft NSIS installer system. You need this to build the self installing package. It's a free open source installer that's much nicer to use than the commercial Wise and Install shield installers. This is the installer we use for commercial releases as well. Install the lot, especially the modern user interface components, as it's definitely needed. Put makensis in your path, in my case: PATH=/cygdrive/c/Program\ Files/NSIS:$PATH

Type makensis at the bash prompt and you should get a list of options if everything is OK.

• OpenSSL. This is if you want the SSL and crypto applications to compile (and run). There are prebuilt binaries, which you can just download and install, available here:

We would recommend using 1.0.2d.

• Building with wxWidgets. Download wxWidgets-3.0.2 or higher.

Install or unpack it to the pgm folder: Cygwin: DRIVE:/PATH/cygwin/opt/local/pgm MSYS: DRIVE:/PATH/MinGW/msys/1.0/opt/local/pgm MSYS2: DRIVE:/PATH/msys<32/64>/opt/local/pgm

If the wxUSE_POSTSCRIPT isn't enabled in <path\to\pgm>\wxMSW-3.0.2\include\wx\msw\setup.h, enable it.

build: From a command prompt with the VC tools available (See the instructions for OpenSSL build above for help on starting the proper command prompt in RELEASE mode):

C:\...\> cd <path\to\pgm>\wxMSW-3.0.2\build\msw
C:\...\> nmake BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc

Or - if building a 64bit version:

C:\...\> cd <path\to\pgm>\wxMSW-3.0.2\build\msw
C:\...\> nmake TARGET_CPU=amd64 BUILD=release SHARED=0 DIR_SUFFIX_CPU= -f makefile.vc

• Get the Erlang source distribution (from http://www.erlang.org/download.html). The same as for Unix platforms. Preferably use tar from within Cygwin, MSYS or MSYS2 to unpack the source tar.gz (tar zxf otp_src_19.tar.gz).

Set the environment ERL_TOP to point to the root directory of the source distribution. Let's say I stood in $HOME/src and unpacked otp_src_19.tar.gz, I then add the following to .profile: ERL_TOP=$HOME/src/otp_src_19
export $ERL_TOP 4.5 The Shell Environment So, if you have followed the instructions above, when you start a bash shell, you should have an INCLUDE environment with a Windows style path, a LIB environment variable also in Windows style, and finally a PATH that let's you reach cl, makensis, javac etc from the command prompt (use which cl etc to verify from bash). You should also have an ERL_TOP environment variable that is Cygwin style, and points to a directory containing, among other files, the script otp_build. A final massage of the environment is needed, and that is done by the script$ERL_TOP/otp_build. Start bash and do the following, note the "back-ticks" (), can be quite hard to get on some keyboards, but pressing the back-tick key followed by the space bar might do it...

$cd$ERL_TOP
$eval ./otp_build env_win32 If you're unable to produce back-ticks on your keyboard, you can use the ksh variant:$ cd $ERL_TOP$ eval $(./otp_build env_win32) If you are building a 64 bit version, you supply otp_build with an architecture parameter:$ cd $ERL_TOP$ eval ./otp_build env_win32 x64

This should do the final touch to the environment and building should be easy after this. You could run ./otp_build env_win32 without eval just to see what it does, and to see that the environment it sets seems OK. The path is cleaned of spaces if possible (using DOS style short names instead), the variables OVERRIDE_TARGET, CC, CXX, AR and RANLIB are set to their respective wrappers and the directories $ERL_TOP/erts/etc/win32/<cygwin/msys>_tools/vc and$ERL_TOP/erts/etc/win32/<cygwin/msys>_tool are added first in the PATH.

Now you can check which erlc you have by writing type erlc in your shell. It should reside in $ERL_TOP/erts/etc/win32/cygwin_tools or$ERL_TOP/erts/etc/win32/msys_tools.

4.6  Building and Installing

Building is easiest using the otp_build script:

$./otp_build autoconf # Ignore the warning blob about versions of autoconf$ ./otp_build configure <optional configure options>
$./otp_build boot -a$ ./otp_build release -a <installation directory>
$./otp_build installer_win32 <installation directory> # optional Now you will have a file called otp_win32_19.exe or otp_win64_19.exe in the <installation directory>, i.e.$ERL_TOP/release/win32.

Lets get into more detail:

• $./otp_build autoconf - This step rebuilds the configure scripts to work correctly in your environment. In an ideal world, this would not be needed, but alas, we have encountered several incompatibilities between our distributed configure scripts (generated on a Linux platform) and the Cygwin/MSYS/MSYS2 environment over the years. Running autoconf in Cygwin/MSYS/MSYS2 ensures that the configure scripts are generated in a compatible way and that they will work well in the next step. •$ ./otp_build configure - This runs the newly generated configure scripts with options making configure behave nicely. The target machine type is plainly win32, so a lot of the configure-scripts recognize this awkward target name and behave accordingly. The CC variable also makes the compiler be cc.sh, which wraps MSVC++, so all configure tests regarding the C compiler gets to run the right compiler. A lot of the tests are not needed on Windows, but we thought it best to run the whole configure anyway.

• $./otp_build boot -a - This uses the bootstrap directory (shipped with the source,$ERL_TOP/bootstrap) to build a complete OTP system. When this is done you can run erl from within the source tree; just type $ERL_TOP/bin/erl and you whould have the prompt. •$ ./otp_build release -a - Builds a commercial release tree from the source tree. The default is to put it in $ERL_TOP/release/win32. You can give any directory as parameter (Cygwin style), but it doesn't really matter if you're going to build a self extracting installer too. •$ ./otp_build installer_win32 - Creates the self extracting installer executable. The executable otp_win32_19.exe or otp_win64_19.exe will be placed in the top directory of the release created in the previous step. If no release directory is specified, the release is expected to have been built to $ERL_TOP/release/win32, which also will be the place where the installer executable will be placed. If you specified some other directory for the release (i.e. ./otp_build release -a /tmp/erl_release), you're expected to give the same parameter here, (i.e. ./otp_build installer_win32 /tmp/erl_release). You need to have a full NSIS installation and makensis.exe in your path for this to work. Once you have created the installer, you can run it to install Erlang/OTP in the regular way, just run the executable and follow the steps in the installation wizard. To get all default settings in the installation without any questions asked, you run the executable with the parameter /S (capital S) like in:$ cd $ERL_TOP$ release/win32/otp_win32_19 /S
...

or

$cd$ERL_TOP
$release/win32/otp_win64_19 /S ... and after a while Erlang/OTP-19 will have been installed in C:\Program Files\erl8.2\, with shortcuts in the menu etc. 4.7 Development Once the system is built, you might want to change it. Having a test release in some nice directory might be useful, but you can also run Erlang from within the source tree. The target local_setup, makes the program$ERL_TOP/bin/erl.exe usable and it also uses all the OTP libraries in the source tree.

If you hack the emulator, you can build the emulator executable by standing in $ERL_TOP/erts/emulator and do a simple$ make opt

Note that you need to have run (cd $ERL_TOP && eval ./otp_build env_win32`) in the particular shell before building anything on Windows. After doing a make opt you can test your result by running$ERL_TOP/bin/erl. If you want to copy the result to a release directory (say /tmp/erl_release), you do this (still in $ERL_TOP/erts/emulator)$ make TESTROOT=/tmp/erl_release release

That will copy the emulator executables.

To make a debug build of the emulator, you need to recompile both beam.dll (the actual runtime system) and erlexec.dll. Do like this

$cd$ERL_TOP
$rm bin/win32/erlexec.dll$ cd erts/emulator
$make debug$ cd ../etc
$make debug and sometimes$ cd $ERL_TOP$ make local_setup

So now when you run $ERL_TOP/erl.exe, you should have a debug compiled emulator, which you will see if you do a: 1> erlang:system_info(system_version). in the erlang shell. If the returned string contains [debug], you got a debug compiled emulator. To hack the erlang libraries, you simply do a make opt in the specific "applications" directory, like:$ cd $ERL_TOP/lib/stdlib$ make opt

or even in the source directory...

$cd$ERL_TOP/lib/stdlib/src
$make opt Note that you're expected to have a fresh Erlang in your path when doing this, preferably the plain 19 you have built in the previous steps. You could also add$ERL_TOP/bootstrap/bin to your PATH before rebuilding specific libraries. That would give you a good enough Erlang system to compile any OTP erlang code. Setting up the path correctly is a little bit tricky. You still need to have $ERL_TOP/erts/etc/win32/cygwin_tools/vc and$ERL_TOP/erts/etc/win32/cygwin_tools before the actual emulator in the path. A typical setting of the path for using the bootstrap compiler would be:

$export PATH=$ERL_TOP/erts/etc/win32/cygwin_tools/vc\
:$ERL_TOP/erts/etc/win32/cygwin_tools:$ERL_TOP/bootstrap/bin:$PATH That should make it possible to rebuild any library without hassle... If you want to copy a library (an application) newly built, to a release area, you do like with the emulator:$ cd $ERL_TOP/lib/stdlib$ make TESTROOT=/tmp/erlang_release release

Remember that:

• Windows specific C-code goes in the $ERL_TOP/erts/emulator/sys/win32,$ERL_TOP/erts/emulator/drivers/win32 or \$ERL_TOP/erts/etc/win32.

• Windows specific erlang code should be used conditionally and the host OS tested in runtime, the exactly same beam files should be distributed for every platform! So write code like:

case os:type() of
{win32,_} ->
do_windows_specific();
Other ->
do_fallback_or_exit()
end,

That's basically all you need to get going.

4.8  Using GIT

You might want to check out versions of the source code from GitHUB. That is possible directly in Cygwin, but not in MSYS. There is a project MsysGIT:

that makes a nice Git port. The msys prompt you get from MsysGIT is however not compatible with the full version from MinGW, so you will need to check out files using MsysGIT's command prompt and then switch to a common MSYS command prompt for building. Also all test suites cannot be built as MsysGIT/MSYS does not handle symbolic links.


text:
International Association for Cryptologic Research

# IACR News Central

You can also access the full news archive.

Further sources to find out about changes are CryptoDB, ePrint RSS, ePrint Web, Event calender (iCal).

2015-05-27
12:17 [Pub][ePrint]

The Norwegian government ran trials of internet remote voting during the 2011 municipal elections and the 2013 parliamentary elections. From a simplified version of the voting protocol used there, the essential cryptographic operations of the voting protocol has been put together into a cryptosystem in which one can build the voting protocol on top of.

This paper proposes a new instantiation of the underlying cryp- tosystem, improving our confidence in the security of the cryptosys- tem. The new instantiation is mostly similar to a previously defined instantiation, but allows parts of the security proof to be significantly improved.

12:17 [Pub][ePrint]

We introduce and study the iterated random permutation problem, which asks how hard it is to distinguish, in a black-box way, the r-th power of a random permutation from a uniformly random permutation of a set of size N. We show that this requires Omega(N) queries (even for a two-sided, adaptive adversary). As a direct application of this result, we show that cascading a block cipher with the same key cannot degrade its security (as a pseudorandom permutation) more than negligibly.

2015-05-26
21:56 [Job][New]

CloudFlare is looking for a cryptography intern!

CloudFlare is expanding its global footprint. In order to keep our network secure we are investing in technologies to improve the security of our key management infrastructure. We are looking for an ambitious intern to help kickstart one of our cryptographic projects.

Requirements:

• Experience in the theory and implementation of standard cryptographic primitives (AES, RSA, ECC)

• Extensive development experience in C and/or Go

• A deep understanding of reverse engineering techniques

• An unquenchable thirst for understanding and mitigating cryptographic attack vectors

• Outside-the-box thinking and self-starter attitude

Bonus requirements:

• Experience with the cryptol programming language

• Experience with LLVM or other compiler technology

• Knowledge of the theory and implementation of white-box cryptography

Internship length: 4-6 months.

Sound like somewhere you’d thrive? If so, then we’d love to hear from you. Send us your resume and a short paragraph introducing yourself. Please include a brief description of how you solved a customer problem or enhanced a customer\'s understanding of a technical service.

CloudFlare is a security company. All prospective employees will be subject to an extensive background check.

CloudFlare is an equal opportunity employer and does not discriminate against any employee or applicant on the basis of age, color, disability, gender, national origin, race, religion, sexual orientation, veteran status, or any classification protected by federal, state, or local law.

• 21:56 [Event][New]

From August 31 to September 3
Location: Irvine, CA, USA

15:17 [Pub][ePrint]

By selecting the largest possible value of k ∈ (n/2,2n/3], we further reduce the AND and XOR gate complexities of the CRT-based hybrid parallel GF(2^n) polynomial pasis multipliers for the irreducible trinomial f = u^n + u^k + 1 over GF(2): they are always less than those of the current fastest parallel multipliers - quadratic multipliers, i.e., n^2 AND gates and n^2−1 XOR gates. Our experimental results show that among the 539 values of n ∈ [5,999] such that f is irreducible for some k ∈ [2,n−2], there are 317 values of n such that k ∈ (n/2,2n/3]. For these irreducible trinomials, the AND and XOR gate complexities of the CRT-based hybrid multipliers are reduced by 15.3% on average. Especially, for the 124 values of such n, the two kinds of multipliers have the same time complexity, but the space complexities are reduced by 15.5% on average. As a comparison, the previous CRT-based multipliers consider the case k ∈ [2,n/2], and the improvement rate is only 8.4% on average.

15:17 [Pub][ePrint]

We describe a new technique for conducting partitioning arguments\'\'. Partitioning arguments are a popular way to prove the security of a cryptographic scheme. For instance, to prove the security of a signature scheme, a partitioning argument could divide the set of messages into signable\'\' messages for which a signature can be simulated during the proof, and unsignable\'\' ones for which any signature would allow to solve a computational problem. During the security proof, we would then hope that an adversary only requests signatures for signable messages, and later forges a signature for an unsignable one.

In this work, we develop a new class of partitioning arguments from simple assumptions. Unlike previous partitioning strategies, ours is based upon an algebraic property of the partitioned elements (e.g., the signed messages), and not on their bit structure. This allows to perform the partitioning efficiently in a hidden\'\' way, such that already a single slot\'\' for a partitioning operation in the scheme can be used to implement many different partitionings sequentially, one after the other. As a consequence, we can construct complex partitionings out of simple basic (but algebraic) partitionings in a very space-efficient way.

As a demonstration of our technique, we provide the first signature and public-key encryption schemes that achieve the following properties simultaneously: they are (almost) tightly secure under a simple assumption, and they are fully compact (in the sense that parameters, keys, and signatures, resp.~ciphertexts only comprise a constant number of group elements).

15:17 [Pub][ePrint]

Fault injection has become over the years one of the most dangerous threats for embedded devices such as smartcards. It is thus mandatory for any embedded system to implement efficient protections against this hazard. Among the various countermeasures suggested so far, the idea of infective computation seems fascinating, probably due to its aggressive strategy. Originally conceived to protect asymmetric cryptosystems, infective computation has been recently adapted to symmetric systems. This paper investigates the security of a new symmetric infective countermeasure suggested at CHES 2014. By noticing that the number of executed rounds is not protected, we develop four different attacks allowing one to efficiently recover the secret key of the underlying cryptosystem by using any of the three most popular fault models used in literature.

15:17 [Pub][ePrint]

We reconsider the concept of two-prover (and more generally: multi-prover) commitments, as introduced in the late eighties in the seminal work by Ben-Or et al. As was recently shown by Cr{\\\'e}peau et al., the security of known two-prover commitment schemes not only relies on the explicit assumption that the two provers cannot communicate, but also depends on what their information processing capabilities are. For instance, there exist schemes that are secure against classical provers but insecure if the provers have quantum information processing capabilities, and there are schemes that resist such quantum attacks but become insecure when considering general so-called non-signaling provers, which are restricted solely by the requirement that no communication takes place.

This poses the natural question whether there exists a two-prover commitment scheme that is secure under the sole assumption that no communication takes place, and that does not rely on any further restriction of the information processing capabilities of the dishonest provers; no such scheme is known.

In this work, we give strong evidence for a negative answer: we show that any single-round two-prover commitment scheme can be broken by a non-signaling attack. Our negative result is as bad as it can get: for any candidate scheme that is (almost) perfectly hiding, there exists a strategy that allows the dishonest provers to open a commitment to an arbitrary bit (almost) as successfully as the honest provers can open an honestly prepared commitment, i.e., with probability (almost) $1$ in case of a perfectly sound scheme. In the case of multi-round schemes, our impossibility result is restricted to perfectly hiding schemes.

On the positive side, we show that the impossibility result can be circumvented by considering {\\em three} provers instead: there exists a three-prover commitment scheme that is secure against arbitrary non-signaling attacks.

15:17 [Pub][ePrint]

Current cryptocurrencies, starting with Bitcoin, build a decentralized blockchain-based transaction ledger, maintained through proofs-of-work that also generate a monetary supply. Such decentralization has benefits, such as independence from national political control, but also significant limitations in terms of scalability and computational cost. We introduce RSCoin, a cryptocurrency framework in which central banks maintain complete control over the monetary supply, but rely on a distributed set of authorities, or mintettes, to prevent double-spending. While monetary policy is centralized, RSCoin still provides strong transparency and auditability guarantees. We demonstrate, both theoretically and experimentally, the benefits of a modest degree of centralization, such as the elimination of wasteful hashing and a scalable system for avoiding double-spending attacks.

09:17 [Pub][ePrint]

Large-scale datasets of consumer behavior might revolutionize the way we gain competitive advantages and increase our knowledge in the respective domains. At the same time, valuable datasets pose potential privacy risks that are difficult to foresee. In this paper we study the impact that the prices from consumers\' purchase histories have on the consumers\' location privacy. We show that using a small set of low-priced product prices from the consumers\' purchase histories, an adversary can determine the country, city, and local retail store where the transaction occurred with high confidence. Our paper demonstrates that even when the product category, precise time of purchase, and currency are removed from the consumers\' purchase history (e.g., for privacy reasons), information about the consumers\' location is leaked. The results are based on three independent datasets containing thousands of low-priced and frequently-bought consumer products. In addition, we show how to identify the local currency, given only the total price of a consumer purchase in a global currency (e.g., in Bitcoin). The results show the existence of location privacy risks when releasing consumer purchase histories. As such, the results highlight the need for systems that hide transaction details in consumer purchase histories.

09:17 [Pub][ePrint]

We describe a zero-knowledge proof system in which a prover holds a large dataset $M$ and can repeatedly prove NP relations about that dataset. That is, for any (public) relation $R$ and $x$, the prover can prove that $\\exists w: R(M,x,w)=1$. After an initial setup phase (which depends only on $M$), each proof requires only a constant number of rounds and has communication/computation cost proportional to that of a {\\em random-access machine (RAM)} implementation of $R$, up to polylogarithmic factors. In particular, the cost per proof in many applications is sublinear in $|M|$. Additionally, the storage requirement between proofs for the verifier is constant.

format: plain


text:
# How to calculate error matrices, K hat and var(K hat)?

I have a very simple data set consisting of three columns: Ground Truth Canopy Class, Method 1 Canopy Class and Method 2 Canopy Class. Each row in the columns represents the canopy class (i.e. 1 through 5). I have produced an error matrix in excel and calculated the overall accuracy and Khat (Figure 1). However, now I need to test whether or not method one is significantly different from method two using the attached equations (Figure 2 and 3). I could use help to calculate the following using R or Excel:

1. Z-score
2. K hat
3. Variance of K hat

Is there a package in R I've overlooked that can aid me these calculations?

Figure 1

Figure 2

Figure 3

Source: Assessing the Accuracy of Remotely Sensed Data (Congalton, 2009)

-
If you predicted canopy class with both methods for each sample, your have a paired design. I.e. your confusion tables are not independent. – cbeleites Nov 22 '12 at 10:56
Your canopy seems to be a continuous outcome (fraction of canopy coverage) which is then cut into ordered classes. In that case, why not do regression, and use regression error measures? – cbeleites Nov 22 '12 at 10:59
@cbeleites I have already done regression based analysis using the equivalence package in R. I believe both of my error matrices are independent--I provided an example of an error matrix between max likelihood classification and reference data. I also have another error matrix that is not displayed which is between random forest classification and reference data. – Aaron Nov 22 '12 at 20:39
wrt independence: you say that you have 3 columns: reference, pred 1, pred 2. So you have predictions from both classifiers for the same sample, right? – cbeleites Nov 22 '12 at 21:10
error matrix 1 is based off pred 1 x reference; error matrix 2 is based off pred 2 x reference. I need the error matrix to describe omission and commission error rates. – Aaron Nov 22 '12 at 21:25

It might not seem that way off the bat, but (assuming, as you said, independence between the two methods) your question fits nicely into the framework of a survey with multiple raters. Check out the survey package, specifically the svydesign, svycontrast, and svykappa functions. HTH,


text:
# ON CHOQUET INTEGRALS OF MEASURABLE FUZZY NUMBER-VALUED FUNCTIONS

• Jung, Lee-Chae (Department Of Mathematics And Computer Science, Konkuk University) ;
• Kim, Tae-Kyun (Institute Of Science Education, Kongju National University) ;
• Jeon, Jong-Duek (Department Of Mathematics, Kyunghee University) ;
• Kim, Won-Ju (Department Of Mathematics, Kyunghee University)
• Published : 2004.02.01
• 85 6

#### Abstract

In this paper, we consider fuzzy number-valued functions and fuzzy number-valued Choquet integrals. And we also discuss positively homogeneous and monotonicity of Choquet integrals of fuzzy number-valued functions(simply, fuzzy number-valued Choquet integrals). Furthermore, we prove convergence theorems for fuzzy number-valued Choquet integrals.

#### Keywords

fuzzy measures;fuzzy number-valued Choquet integrals;Hausdorff metric

#### References

1. J. Mathe. Psych. v.46 On order invariant aggregation functionals S.Ovchinnikov;A.Dukhovny https://doi.org/10.1006/jmps.2001.1365
2. J. Multivariate Anal. v.7 Integrals, conditional expectations, and martingales of multivalued functions F.Hiai;H.Umegaki https://doi.org/10.1016/0047-259X(77)90037-9
3. Fuzzy Sets and Systems v.112 On the representation of Choquet integrals of set-valued functions and null sets L.C.Jang;J.S.Kwon https://doi.org/10.1016/S0165-0114(98)00184-5
4. Fuzzy Sets and Systems v.126 Limit theorems for fuzzy-random variables V.Kratschmer https://doi.org/10.1016/S0165-0114(00)00100-7
5. Fuzzy Sets and Systems v.121 Extension and representation of comonotonically additive functionals https://doi.org/10.1016/S0165-0114(00)00031-2
6. Bull. Korean Math. Soc. v.40 no.1 On set-valued Choquet integrals and convergence theorems (II) L.C.Jang;T.Kim;J.D.Jeon https://doi.org/10.4134/BKMS.2003.40.1.139
7. Fuzzy Sets and Systems v.103 On convex and concave fuzzy mappings Y.Syau https://doi.org/10.1016/S0165-0114(97)00210-8
8. J. of Math. Anal. and Appl. v.114 Fuzzy random variables M.L.Puri;D.A.Ralescu https://doi.org/10.1016/0022-247X(86)90093-4
9. J. Math. Anal. Appl. v.12 Integrals of set-valued functions R.J.Aumann https://doi.org/10.1016/0022-247X(65)90049-1
10. Appl. Math. Lett. v.11 no.2 The compactness of E(X) H. Roman-Flores
11. Set-valued analysis J.Aubin
12. Proc. Amer. Math. Soc. v.97 Integral representation without additivity D.Schmeidler https://doi.org/10.1090/S0002-9939-1986-0835875-8
13. J. Math. Anal. and Appl. v.159 A theory of Fuzzy measures: representations, the Choquet integral, and null sets https://doi.org/10.1016/0022-247X(91)90213-J
14. Fuzzy Sets and Systems v.98 The applications of interval-valued fuzzy number-distribution numbers G.Wang;X.Li https://doi.org/10.1016/S0165-0114(96)00368-5
15. Fuzzy Sets and Systems v.120 On measurability of fuzzy number-valued functions D.Zhang https://doi.org/10.1016/S0165-0114(99)00061-5
16. Fuzzy Sets and Systems v.29 An interpretation of fuzzy measures and the Choquet integral as an integral with respect to a fuzzy measure T.Murofushi;M.Sugeno https://doi.org/10.1016/0165-0114(89)90194-2
17. Fuzzy Sets and Systems v.99 Choquet integral and fuzzy measures on locally compact space M.Sugeno;Y.Narukawa;T.Murofushi https://doi.org/10.1016/S0165-0114(97)00028-6
18. Fuzzy Sets and Systems v.98 Fuzzy number fuzzy measures and fuzzy integrals(I). Fuzzy integrals of functions with respect to fuzzy measures C.Wu;D.Zhang;B.Zhang;C.Guo https://doi.org/10.1016/S0165-0114(96)00394-6
19. Fuzzy Sets and Systems v.91 Some properties of Choquet integrals of set-valued functions L.C.Jang;B.M.Kil;Y.K.Kim;J.S.Kwon https://doi.org/10.1016/S0165-0114(96)00124-8
20. Adv. Stud. Contemp. Math. v.6 no.1 On set-valued Choquet integrals and convergence theorems L.C.Jang;T.Kim
21. Fuzzy Sets and Systems v.52 Characterization and comparision of Sugeno and Choquet integrals L.M.Campos;M.J.Bolauos https://doi.org/10.1016/0165-0114(92)90037-5
22. Fuzzy Sets and Systems v.112 Regular fuzzy measure and representation of comonotonically additive functional Y.Narukawa;T.Murofushi;M.Sugeno https://doi.org/10.1016/S0165-0114(98)00138-9

#### Cited by

1. On Choquet Integrals with Respect to a Fuzzy Complex Valued Fuzzy Measure of Fuzzy Complex Valued Functions vol.10, pp.3, 2010, https://doi.org/10.5391/IJFIS.2010.10.3.224
2. Some Properties of Choquet Integrals with Respect to a Fuzzy Complex Valued Fuzzy Measure vol.11, pp.2, 2011, https://doi.org/10.5391/IJFIS.2011.11.2.113


text:
## Complement of a Set – Venn Diagram and Examples

Here you will learn what is the complement of a set definition with venn diagram and examples. Let’s begin – Complement of a Set Definition : Let U be the universal set and let A be a set such that A $$\subset$$ U. Then, the complement of A with respect to U is denoted by …


text:
Different types of derivatives have different pricing mechanisms. A derivative is simply a financial contract with a value that is based on some underlying asset (e.g. the price of a stock, bond, or commodity). The most common derivative types are futures contracts, forward contracts, options and swaps. More exotic derivatives can be based on factors such as weather or carbon emissions.

### Key Takeaways

• Derivatives are financial contracts used for a variety of purposes, whose prices are derived from some underlying asset or security.
• Depending on the type of derivative, its fair value or price will be calculated in a different manner.
• Futures contracts are based on the spot price along with a basis amount, while options are priced based on time to expiration, volatility, and strike price.
• Swaps are priced based on equating the present value of a fixed and a variable stream of cash flows over the maturity of the contract.

## Futures Pricing Basics

Futures contracts are standardized financial contracts that allow holders to buy or sell an underlying asset or commodity at a certain price in the future, which is locked in today. Therefore, the futures contract's value is based on the commodity's cash price.

Futures prices will often deviate somewhat from the cash, or spot price, of the underlying. The difference between the cash price of the commodity and the futures price is the basis. It is a crucial concept for portfolio managers and traders because this relationship between cash and futures prices affects the value of the contracts used in hedging. As there are gaps between spot and relative price until expiry of the nearest contract, the basis is not necessarily accurate.

In addition to the deviations created because of the time gap between expiry of the futures contract and the spot commodity, product quality, location of delivery and the actuals may also vary. In general, the basis is used by investors to gauge the profitability of delivery of cash or the actual, and is also used to search for arbitrage opportunities.

For example, consider a corn futures contract that represents 5,000 bushels of corn. If corn is trading at $5 per bushel, the value of the contract is$25,000. Futures contracts are standardized to include a certain amount and quality of the underlying commodity, so they can be traded on a centralized exchange. The futures price moves in relation to the spot price for the commodity based on supply and demand for that commodity.

Forwards are priced similarly to futures, but forwards are non-standardized contracts that arranged instead between two counterparties and transacted over-the-counter with more flexibility of terms.

## Options Pricing Basics

Options are also common derivative contracts. Options give the buyer the right, but not the obligation, to buy or sell a set amount of the underlying asset at a pre-determined price, known as the strike price, before the contract expires.

The primary goal of option pricing theory is to calculate the probability that an option will be exercised, or be in-the-money (ITM), at expiration. Underlying asset price (stock price), exercise pricevolatilityinterest rate, and time to expiration, which is the number of days between the calculation date and the option's exercise date, are commonly used variables that are input into mathematical models to derive an option's theoretical fair value.

Aside from a company's stock and strike prices, time, volatility, and interest rates are also quite integral in accurately pricing an option. The longer that an investor has to exercise the option, the greater the likelihood that it will be ITM at expiration. Similarly, the more volatile the underlying asset, the greater the odds that it will expire ITM. Higher interest rates should translate into higher option prices.

The best-known pricing model for options is the Black-Scholes method. This method considers the underlying stock price, option strike price, time until the option expires, underlying stock volatility and risk-free interest rate to provide a value for the option. Other popular models exist such as the binomial tree and trinomial tree pricing models.

## Swaps Pricing Basics

Swaps are derivative instruments that represent an agreement between two parties to exchange a series of cash flows over a specific period of time. Swaps offer great flexibility in designing and structuring contracts based on mutual agreement. This flexibility generates many swap variations, with each serving a specific purpose. For instance, one party may swap a fixed cash flow to receive a variables cash flow that fluctuates as interest rates change. Others may swap cash flows associated with the interest rates in one country for that of another.

The most basic type of swap is a plain vanilla interest rate swap. In this type of swap, parties agree to exchange interest payments. For example, assume Bank A agrees to make payments to Bank B based on a fixed interest rate while Bank B agrees to make payments to Bank A based on a floating interest rate.

The value of the swap at the initiation date will be zero to both parties. For this statement to be true, the values of the cash flow streams that the swap parties are going to exchange should be equal. This concept is illustrated with a hypothetical example in which the value of the fixed leg and floating leg of the swap will be Vfix and Vfl respectively. Thus, at initiation:

$V_{fix} = V_{fl}$

Notional amounts are not exchanged in interest rate swaps because these amounts are equal and it does not make sense to exchange them. If it is assumed that parties also decide to exchange the notional amount at the end of the period, the process will be similar to an exchange of a fixed rate bond to a floating rate bond with the same notional amount. Therefore such swap contracts can be valued in terms of fixed and floating-rate bonds.


text:
# Robust statistics

Techniques to improve the failure modes of your estimates. Surprisingly rarely used despite being fairly straightforward.

This is more-or-less a frequentist project.

Bayesians seem to claim to achieve robustness largely by choosing heavy-tailed priors where they might have chosen light-tailed ones, e.g. Laplacian priors instead of Gaussian ones. Such priors may have arbitrary parameters, but not more arbitrary than usual in Bayesian statistics and therefore do not attract so much need to rationalise away the guilt.

## TODO

• relation to penalized regression.
• connection with Lasso.
• Beran’s Hellinger-ball contamination model, which I also don’t yet understand.
• Breakdown point explanation
• glm connection.

## Corruption models

1. (Adversarial) total variation $\epsilon$-corruption.
2. Random (mixture) corruption
3. other?

## M-estimation with robust loss

The one that I, at least, would think of when considering robust estimation.

In M-estimation, instead of hunting an maximum of the likelihood function as you do in maximum likelihood, or an minimum of the sum of squared residuals, as you do in least-squares estimation, you minimised a specifically choses loss funciton for those residuals. You may select an objective function more robust to deviations between your model and reality. Credited to Huber (Hube64).

See M-estimation for the details

Aside: AFAICT, the definition of M-estimation includes the possibility that you could in principle select a less-robust loss function than least sum-of-squares or negative log likelihood, but I have not seen this in the literature. Generally, some robustified approach is presumed.

For M-estimation as robust estimation, various complications ensue, such as the different between noise in your predictors, noise in your regressors, and whether the “true” model is included in your class, and which of these difficulties you have resolved or not.

Loosely speaking, no, you haven’t solved problems of noise in your predictors, only the problem of noise in your responses.

And the cost is that you now have a loss function with some extra arbitrary parameters in which you have to justify, which is anathema to frequentists, who like to claim to be less arbitrary than Bayesians. You then have to justify why you chose that loss function and its particular parameterisation. There are various procedures to choose these parameters, based on scale estimation.

TBD. Don’t know

## Median-based estimators

Rousseeuw and Yohai’s school. (RoYo84)

Many permutations on the theme here, but it rapidly gets complex. The only one of these families I have looked into are the near trivial cases of the Least Median Of Squares and Least Trimmed Squares estimations. (Rous84)

More broadly we should also consider S-estimators, which do something with… robust estimation of scale and using this to do robust estimation of location? TBD.

Theil-Sen-(Oja) estimators: Something about medians of inferred regression slopes. TBD.

Tukey median, and why no-one uses it what with it being NP-Hard.

## Others

RANSAC - some kind of randomised outlier detection estimator. TBD.

## Refs

Barn83
Barndorff-Nielsen, O. (1983) On a formula for the distribution of the maximum likelihood estimator. Biometrika, 70(2), 343–365. DOI.
Bera81
Beran, R. (1981) Efficient robust estimates in parametric models. Zeitschrift Für Wahrscheinlichkeitstheorie Und Verwandte Gebiete, 55(1), 91–108. DOI.
Bera82
Beran, R. (1982) Robust Estimation in Models for Independent Non-Identically Distributed Data. The Annals of Statistics, 10(2), 415–428. DOI.
Bick75
Bickel, P. J.(1975) One-Step Huber Estimates in the Linear Model. Journal of the American Statistical Association, 70(350), 428–434. DOI.
BoKG10
Bondell, H. D., Krishna, A., & Ghosh, S. K.(2010) Joint Variable Selection for Fixed and Random Effects in Linear Mixed-Effects Models. Biometrics, 66(4), 1069–1077. DOI.
Bühl14
Bühlmann, P. (2014) Robust Statistics. In J. Fan, Y. Ritov, & C. F. J. Wu (Eds.), Selected Works of Peter J. Bickel (pp. 51–98). Springer New York
BBBG14
Buja, A., Berk, R., Brown, L., George, E., Pitkin, E., Traskin, M., … Zhao, L. (2014) Models as Approximations: How Random Predictors and Model Violations Invalidate Classical Inference in Regression. arXiv:1404.1578 [stat].
BuNo95
Burman, P., & Nolan, D. (1995) A general Akaike-type criterion for model selection in robust regression. Biometrika, 82(4), 877–886. DOI.
CaRo01
Cantoni, E., & Ronchetti, E. (2001) Robust Inference for Generalized Linear Models. Journal of the American Statistical Association, 96(455), 1022–1030. DOI.
Cox83
Cox, D. R.(1983) Some remarks on overdispersion. Biometrika, 70(1), 269–274. DOI.
CzRo10
Czellar, V., & Ronchetti, E. (2010) Accurate and robust tests for indirect inference. Biometrika, 97(3), 621–630. DOI.
DPWZ08
Dang, X., Peng, H., Wang, X., & Zhang, H. (2008) Theil-Sen Estimators in a Multiple Linear Regression Model. . Citeseer
DoHu83
Donoho, D. L., & Huber, P. J.(1983) The notion of breakdown point. A Festschrift for Erich L. Lehmann, 157184.
DoLi88
Donoho, D. L., & Liu, R. C.(1988) The “Automatic” Robustness of Minimum Distance Functionals. The Annals of Statistics, 16(2), 552–586. DOI.
DoMo13
Donoho, D., & Montanari, A. (2013) High Dimensional Robust M-Estimation: Asymptotic Variance via Approximate Message Passing. arXiv:1310.7320 [cs, Math, Stat].
GeRo03
Genton, M. G., & Ronchetti, E. (2003) Robust Indirect Inference. Journal of the American Statistical Association, 98(461), 67–76. DOI.
GoNu90
Golubev, G. K., & Nussbaum, M. (1990) A Risk Bound in Sobolev Class Regression. The Annals of Statistics, 18(2), 758–778. DOI.
Hamp74
Hampel, F. R.(1974) The Influence Curve and its Role in Robust Estimation. Journal of the American Statistical Association, 69(346), 383–393. DOI.
HRRS11
Hampel, F. R., Ronchetti, E. M., Rousseeuw, P. J., & Stahel, W. A.(2011) Robust Statistics: The Approach Based on Influence Functions. . John Wiley & Sons
Hoss09
Hosseinian, Sahar. (2009) Robust inference for generalized linear models: binary and poisson regression. . ÉCOLE POLYTECHNIQUE FÉDÉRALE DE LAUSANNE
Hube64
Huber, P. J.(1964) Robust Estimation of a Location Parameter. The Annals of Mathematical Statistics, 35(1), 73–101. DOI.
Hube09
Huber, P. J.(2009) Robust statistics. (2nd ed.). Hoboken, N.J: Wiley
JaGe16
Janková, J., & van de Geer, S. (2016) Confidence regions for high-dimensional generalized linear models under sparsity. arXiv:1610.01353 [math, Stat].
Karo13
Karoui, N. E.(2013) Asymptotic behavior of unregularized and ridge-regularized high-dimensional robust regression estimators : rigorous results. arXiv:1311.2445 [math, Stat].
KoKi96
Konishi, S., & Kitagawa, G. (1996) Generalised information criteria in model selection. Biometrika, 83(4), 875–890. DOI.
KoKi03
Konishi, S., & Kitagawa, G. (2003) Asymptotic theory for information criteria in model selection—functional approach. Journal of Statistical Planning and Inference, 114(1–2), 45–61. DOI.
KoKi08
Konishi, S., & Kitagawa, G. (2008) Information criteria and statistical modeling. . New York: Springer
LuGF12
LU, W., GOLDBERG, Y., & FINE, J. P.(2012) On the robustness of the adaptive lasso to model misspecification. Biometrika, 99(3), 717–731. DOI.
Mach93
Machado, J. A. F.(1993) Robust Model Selection and M-Estimation. Econometric Theory, 9(03), 478–493. DOI.
MaRo97
Markatou, M., & Ronchetti, E. (1997) 3 Robust inference: The approach based on influence functions. In B.-H. of Statistics (Ed.), (Vol. 15, pp. 49–75). Elsevier
Maro76
Maronna, R. A.(1976) Robust M-Estimators of Multivariate Location and Scatter. The Annals of Statistics, 4(1), 51–67.
MaYo95
Maronna, R. A., & Yohai, V. J.(1995) The Behavior of the Stahel-Donoho Robust Multivariate Estimator. Journal of the American Statistical Association, 90(429), 330–341. DOI.
MaYo14
Maronna, R. A., & Yohai, V. J.(2014) Robust Estimation of Multivariate Location and Scatter. In Wiley StatsRef: Statistics Reference Online. John Wiley & Sons, Ltd
MaZa02
Maronna, R. A., & Zamar, R. H.(2002) Robust Estimates of Location and Dispersion for High-Dimensional Datasets. Technometrics, 44(4), 307–317.
MaMY00
Maronna, R., Martin, D., & Yohai, V. (n.d.) Robust statistics.
MKRL86
Massart, D. L., Kaufman, L., Rousseeuw, P. J., & Leroy, A. (1986) Least median of squares: a robust method for outlier and model error detection in regression and calibration. Analytica Chimica Acta, 187, 171–179. DOI.
Oja83
Oja, H. (1983) Descriptive statistics for multivariate distributions. Statistics & Probability Letters, 1(6), 327–332. DOI.
PeDe08
Petersen, M. R., & Deddens, J. A.(2008) A comparison of two methods for estimating prevalence ratios. BMC Medical Research Methodology, 8, 9. DOI.
Qian96
Qian, G. (1996) On model selection in robust linear regression.
QiHa96
Qian, G., & Hans, R. K.(1996) Some notes on Rissanen’s stochastic complexity.
QiKü98
Qian, G., & Künsch, H. R.(1998) On model selection via stochastic complexity in robust linear regression. Journal of Statistical Planning and Inference, 75(1), 91–116. DOI.
Ronc85
Ronchetti, E. (1985) Robust model selection in regression. Statistics & Probability Letters, 3(1), 21–23. DOI.
Ronc97
Ronchetti, E. (1997) Robust inference by influence functions. Journal of Statistical Planning and Inference, 57(1), 59–72. DOI.
Ronc00
Ronchetti, E. (2000) Robust Regression Methods and Model Selection. In A. Bab-Hadiashar & D. Suter (Eds.), Data Segmentation and Model Selection for Computer Vision (pp. 31–40). Springer New York
RoTr01
Ronchetti, E., & Trojani, F. (2001) Robust inference with GMM estimators. Journal of Econometrics, 101(1), 37–69. DOI.
Rous84
Rousseeuw, P. J.(1984) Least Median of Squares Regression. Journal of the American Statistical Association, 79(388), 871–880. DOI.
RoLe87
Rousseeuw, P. J., & Leroy, A. M.(1987) Robust regression and outlier detection. . New York: Wiley
RoYo84
Rousseeuw, P., & Yohai, V. (1984) Robust Regression by Means of S-Estimators. In J. Franke, W. Härdle, & D. Martin (Eds.), Robust and Nonlinear Time Series Analysis (pp. 256–272). Springer US
Roya86
Royall, R. M.(1986) Model Robust Confidence Intervals Using Maximum Likelihood Estimators. International Statistical Review / Revue Internationale de Statistique, 54(2), 221–226. DOI.
Stig10
Stigler, S. M.(2010) The Changing History of Robustness. The American Statistician, 64(4), 277–281. DOI.
ThCl13
Tharmaratnam, K., & Claeskens, G. (2013) A comparison of robust versions of the AIC based on M-, S- and MM-estimators. Statistics, 47(1), 216–235. DOI.
Thei92
Theil, H. (1992) A Rank-Invariant Method of Linear and Polynomial Regression Analysis. In B. Raj & J. Koerts (Eds.), Henri Theil’s Contributions to Economics and Econometrics (pp. 345–381). Springer Netherlands
Tsou06
Tsou, T.-S. (2006) Robust Poisson regression. Journal of Statistical Planning and Inference, 136(9), 3173–3186. DOI.
Wedd74
Wedderburn, R. W. M.(1974) Quasi-likelihood functions, generalized linear models, and the Gauss—Newton method. Biometrika, 61(3), 439–447. DOI.
XuCM10
Xu, H., Caramanis, C., & Mannor, S. (2010) Robust Regression and Lasso. IEEE Transactions on Information Theory, 56(7), 3561–3574. DOI.
YaXu13
Yang, W., & Xu, H. (2013) A Unified Robust Regression Model for Lasso-like Algorithms. In ICML (3) (pp. 585–593).


text:
I would like some feedback on whether this follows MVVM principles well.

The MainPage has a Login button that opens the login modal page. Upon successful login, the LoginPageViewModel will raise an event which is handled in the parent viewmodel.

I use Action objects to do the show/hide modals. The Actions are defined in a page's codebehind and invoked in its viewmodel.

MainPage.xaml

<Button Command="{Binding ShowLoginModalCommand}" Text="Login"/>

MainPage.xaml.cs

public MainPage()
{
var vm = new MainPageViewModel();
BindingContext = vm;
InitializeComponent();
}

MainViewModel.cs

public Action<LoginViewModel> ShowLoginModal;

public ICommand ShowLoginModalCommand => new Command(() =>
{

{
this.Customer = ev.Customer;
};

}

public Customer Customer
{
get => _customer;
set
{
_customer = value;
OnPropertyChanged(nameof(Customer));
}
}

LoginPage.xaml

<Button Command="{Binding LoginCommand}" Text="Login"/>

LoginViewModel.cs

public ICommand LoginCommand => new Command(async () =>
{
}

{
public Customer Customer { get; set; }
public LoginSuccessEventArgs(Customer customer) => Customer = customer;
}

Generally speaking I find a good implementation and like the simplicity of the approach. I would point out some problems I found though.

Inconsistent MVVM style

You are using two different ways to instantiate views and viewmodels and linking them together in both views, an inconsistence that could get bigger the and messier the more complex the program becomes.

In the MainPage you're creating the viewmodel in the view's constructor, and assigning it to the BindingContext right away. But in the LoginPage you create the viewmodel in the handler of the main page and pass it to the constructor of the view (not show here, but I guess it also assigns the BindingContext with it).

Specially for bigger applications, it's important to clearly define one style, either view first or viewmodel first, and live with it (I don't even know if it's called "style", but it sounds like that to me). A more concerning problem is that when VMs begin to take dependencies on services and other stuff, you most likely will want to use an IoC container for injecting them, and then it becomes more important to clearly define who'll create viewmodels and how. Personally, I like viewmodel-first approach, in which viewmodels create other viewmodels and are passed to the views.

MainPage viewmodel

• Why are ShowLoginModal and HideLoginModal plain public fields? In situations like this, I would expect them to be normal events, raised from the viewmodel and handled in the view. This way feels a bit non-standard.
• On the ShowLoginModalCommand method, the viewmodel creates the login viewmodel directly. Maybe its unnecesary now, but consider using an IoC container or other factory to create this, as generally when other viewmodels take extra dependencies it becomes harder to create them all inline.
• The Customer setter doesn't needs to be public, a private one will do. You only want to set the current user from the login and nowhere else, so make that crystal clear.
• The invocations of the ShowLoginModal and HideLoginModal delegates don't contain a null validation, and will result in a NullReferenceException if no one suscribed to them. A nice shortcut to call them safely is to use the ShowLoginModal?(lvm); syntax.

LoginPage viewmodel

• Beware of the async reentrancy in the LoginCommand method. The VerifyLogin call inside it could potentially be a slow one, but since it's an await call, the UI will remain responsive. That means the user could do other things in the meanwhile, including changing the user/password or even click the login button again! That could have many unanticipated effects. I would counter it by disabling the UI while the verification takes place, using something like this in the VM:
public bool EnableForm { get; set; }
public ICommand LoginCommand => new Command(async () =>
{
//Disable UI before doing anything
EnableForm = false;
OnPropertyChanged(nameof(EnableForm));
}

And in the view bind the controls to that property:
<Button Command="{Binding LoginCommand}" Text="Login" IsEnabled="{Binding EnableForm}"/>

• In the LoginSuccessEventArgs the Customer property doesn't needs to be read-write. Once again, since you're just informing a value, there is no benefit in changing it after creation. Also, the constructor should check for null on the customer passed.
• Possibly it's not shown here or just a work-in-progress thing, but there is no handling of the login failure case, that should just reenable the controls (following my above suggestion), show some error message to the user and not raise the LoginSuccess event.
• Like in the main page, the raising of the event is not null checked and will blow up if nobody happens to be suscribed.
• The call to the VerifyLogin method, although maybe simplified here, could imply a lot of work under the cover. That's the kind of thing that's better delegated to a service to do all the heavy work, and just have the presentation layer handle the visual thing. I would inject it in the constructor and call it passing the user/password entered, and it would return success or failure. Something along the lines of this:
private readonly ILoginService _loginService;
{


text:
# number2018

### More from my site

• Inner Product, Norm, and Orthogonal Vectors Let $\mathbf{u}_1, \mathbf{u}_2, \mathbf{u}_3$ are vectors in $\R^n$. Suppose that vectors $\mathbf{u}_1$, $\mathbf{u}_2$ are orthogonal and the norm of $\mathbf{u}_2$ is $4$ and $\mathbf{u}_2^{\trans}\mathbf{u}_3=7$. Find the value of the real number $a$ in […]
• A Group of Linear Functions Define the functions $f_{a,b}(x)=ax+b$, where $a, b \in \R$ and $a>0$. Show that $G:=\{ f_{a,b} \mid a, b \in \R, a>0\}$ is a group . The group operation is function composition. Steps. Check one by one the followings. The group operation on $G$ is […]
• Quiz 8. Determine Subsets are Subspaces: Functions Taking Integer Values / Set of Skew-Symmetric Matrices (a) Let $C[-1,1]$ be the vector space over $\R$ of all real-valued continuous functions defined on the interval $[-1, 1]$. Consider the subset $F$ of $C[-1, 1]$ defined by $F=\{ f(x)\in C[-1, 1] \mid f(0) \text{ is an integer}\}.$ Prove or disprove that $F$ is a subspace of […]
• Find the Nullity of the Matrix $A+I$ if Eigenvalues are $1, 2, 3, 4, 5$ Let $A$ be an $n\times n$ matrix. Its only eigenvalues are $1, 2, 3, 4, 5$, possibly with multiplicities. What is the nullity of the matrix $A+I_n$, where $I_n$ is the $n\times n$ identity matrix? (The Ohio State University, Linear Algebra Final Exam […]
• If the Localization is Noetherian for All Prime Ideals, Is the Ring Noetherian? Let $R$ be a commutative ring with $1$. Suppose that the localization $R_{\mathfrak{p}}$ is a Noetherian ring for every prime ideal $\mathfrak{p}$ of $R$. Is it true that $A$ is also a Noetherian ring?   Proof. The answer is no. We give a counterexample. Let […]
• Calculate Determinants of Matrices Calculate the determinants of the following $n\times n$ matrices. $A=\begin{bmatrix} 1 & 0 & 0 & \dots & 0 & 0 &1 \\ 1 & 1 & 0 & \dots & 0 & 0 & 0 \\ 0 & 1 & 1 & \dots & 0 & 0 & 0 \\ \vdots & \vdots […] • Matrices Satisfying the Relation HE-EH=2E Let H and E be n \times n matrices satisfying the relation \[HE-EH=2E.$ Let $\lambda$ be an eigenvalue of the matrix $H$ such that the real part of $\lambda$ is the largest among the eigenvalues of $H$. Let $\mathbf{x}$ be an eigenvector corresponding to $\lambda$. Then […]
• Determine a 2-Digit Number Satisfying Two Conditions A 2-digit number has two properties: The digits sum to 11, and if the number is written with digits reversed, and subtracted from the original number, the result is 45. Find the number.   Solution. The key to this problem is noticing that our 2-digit number can be […]


text:
Comment
Share
Q)

# Time constant of a $RC$ circuit is $2/ln(2) s$. Capacitor is discharged at time $t = 0$. The ratio of charge on the capacitor at time $t = 2s$ and $t = 6s$ is

$\begin {array} {1 1} (A)\;3 : 1 & \quad (B)\;8:1 \\ (C)\;4:1 & \quad (D)\;2:1 \end {array}$

Time constant $\tau = \frac{2}{In(2)}$
$I = I_o e^{-t/\tau}$
\begin{align*}\frac{I_1}{I_2} = \frac{e^{^{-2/(2/In2)}}}{e^{^{-6/(2/In2) }}} \end{align*}
\begin{align*}= \frac{e^{3In2}}{e^{In2}} = \frac{2^3}{2} = \frac{4}{1} \end{align*}


text:
Why we use #pragma configs in PIC controllers?

Hi all I am new to the programming of PIC MCUs and I have with me PIC32 MCU. I have done a UART program in it and its working fine. I got the code for UART from Microchips website and its easily understandable. But I am confused with #pragma configs, I mean why this config bits are used. I did a little bit of google searching and found that all the #pragma configs can be found in c\program files\microchip\mplabc32\doc but I really don't know why we use it. Now lets say if I have to do a I2C communication then how would I know that which #pragma configs I need to include? I didn't find a good explanation for it on google. Can any PIC experts explain about it. Thanks.

#pragma config FNOSC = PRIPLL       //Primary Osc w/PLL (XT+,HS+,EC+PLL)
#pragma config POSCMOD = HS         //HS osc mode
#pragma config FPLLMUL = MUL_18     //PLL Multiplier 18x Multiplier
#pragma config FPLLIDIV = DIV_2     //PLL Input Divider 2x Divider
#pragma config FPBDIV = DIV_1       //Peripheral Clock Divisor: Pb_Clk is Sys_Clk/2
#pragma config FPLLODIV = DIV_1     //System PLL Output Clock Divider: PLL Divide by 1

These #pragma configs configure settings which live in their own section of flash memory that is outside of your program code. They are available as soon as the PIC gets power, regardless where they are written in your code. This is important because sometimes they are needed before your program is executed.

For example, there are settings to select a clock source and convert it to the actual clock of your PIC. This can't be done in your program code because the clock must correctly configured before your code can run.

Another example is the code protection setting. If this is enabled, it is not possible to read the program memory of the PIC with a programmer. This discourages others from copying program memory and reverse-engineering your code. This can't be done with program code because it's possible put your PIC into programming mode before any of you program code executes, bypassing anything that enables code protection. In this way #pragma configs are essential because they allow configurations to be set before your code executes.

Not all settings set by #pragma configs are needed before your code executes. Some are just conveniences. For example, it is possible to use #pragma configs to set pins as digital I/O or analog input on startup. This could just as easily be done in your program code.

So why are these settings set with #pragma configs? Aren't they still C-code? They are, but they're special. They're a compiler directive. (Compiler directives start with a #.) Compiler directives are some of the first things that your compiler handles. You know #include foo, which instructs the compiler to paste the file foo right here? The compiler interprets all the #pragma configs at the same time - before it even looks at your other C code. This gives the compiler a chance to ensure that your #pragma configs will be written to the appropriate locations, separate from your program code.

About how to know what configs have to be set:

As now you know such configs exist, read through the list of configs, so you you get an idea what they are for. You don't need to know them by hard, you just need to know that a task you're working on may be affected by them.

The configs you list in your question are entirely clock-related. To understand, you have to understand how clock generation and distribution works. Have a look at page 3 of this document which shows a graph about it.

#pragma config FNOSC = PRIPLL       //Primary Osc w/PLL (XT+,HS+,EC+PLL)

This selects the primary oscillator as source of the clock, and the PLL will be used to further convert the clock. You may also have choosen NOT to use the PLL. Or another source like the secondary oscillator, an internal oscillator etc.

#pragma config POSCMOD = HS         //HS osc mode

Here, you select what's connected to the primary oscillator pins. usually, you can connect the clean signal of an oscillator module (EC), or you connect a crystal resonator below 4MHz (XT) or above (HS). Note that resonators need some additional circuit, which is provided (and selected) by this settings.

#pragma config FPLLIDIV = DIV_2     //PLL Input Divider 2x Divider
#pragma config FPLLMUL = MUL_18     //PLL Multiplier 18x Multiplier

Now, you have your initial clock, but usually, you want the PIC to run with a different frequency. The PLL allows to multiply your clock frequency by a certain factor, but it accepts only a limited input frequency (4-5MHz in this document). So, you divide the frequency by 2 before passing it to the PLL (so you have a 8-10MHz crystal?) and let the PLL multiply the frequency by 18 (resulting in 4Mhz*18=72Mhz?).

#pragma config FPLLODIV = DIV_1     //System PLL Output Clock Divider: PLL

Divide by 1

The output frequency of the PLL can be divided again to get lower or intermediate frequencies. But here, you don't divide it (=divide it by 1).

So, you get the final frequency your PIC runs with. This all looks a bit weird, but it allows lots of input options and system frequencies.

The final frequency is used as system clock.

This all looks a bit weird, but it all allows to run the PIC at many different frequencies.

#pragma config FPBDIV = DIV_1       //Peripheral Clock Divisor: Pb_Clk is Sys_Clk/2

The system clock is divided once more to obtain the clock frequency of the peripherals like I²C / UART / ...
I don't know why the comment says division by 2 while the code says division by 1...

My datasheet also shows a reference clock with SPI, but it also notes that not all PICs have this feature.

Finally, have a look into the oscillator section of your actual PIC about which settings are available.

• hey nice explanation, i got the idea of using config bits. I have edited my question and added pragmas used in case of UART. can you expalin these? – Aircraft Aug 20 '15 at 8:23
• I've added a description. – sweber Aug 20 '15 at 10:16


text:
# algebra practice problems

Therefore, Andrew is 8 years old. Learn algebra for free—variables, equations, functions, graphs, and more. To find the value of x, square each part of the inequality. Grade 9 ratio algebra questions with answers are presented. Line through a point and perpendicular to a given line, Line through a point and parallel to a given line, Find the equation of a perpendicular bisector, Distance, midpoint, and slope (gradient) formulas applied to triangles and quadrilaterals, Different forms of the equation of a straight line. 9 < x < 11 C. 9 < x < 121 D. x < 3 or x < 11 E. x < 9 or x < 121. Note that some sections will have more problems than others and some will have more or less of a variety of problems. Click on the "Solution" link for each problem to go to the page containing the solution.Note that some sections will have more problems than others and some will have more or less of a variety of problems. 27 years old C. 30 years old D. 36 years old E. 42 years old. Simplify absolute value expressions. Peter’s salary is twice Ann’s salary and half of David’s salary. Algebra Practice Questions . Kids can use our free, exciting games to play and compete with their friends as they progress in this subject! -8 B. Free math lessons and math homework help from basic math to algebra, geometry and beyond. ... Im in 7th grade and I finished this problem in 20 sec and the answer is x = 2. step by step is 5x+3=7x-1 —> you minus 5x on both sides because it is the smaller variable and you get 3 = 2x-1. 8. Whether you are studying for a school math test or looking to test your math skills, this free practice test will challenge your knowledge of algebra. Click on the "Solution" link for each problem to go to the page containing the solution. What was the value of his sales last year? A cab ride costs $3.25 for the first half-mile and$0.70 for each mile after the first half-mile. C. Let x represent the total value of last year’s sales, Set up an equation and solve it for x. A. In six years, the sum of Andrew’s and Brad’s ages will be the same as Carol’s age. 2. If you log in we can remember which skills you have passed. If you haven't studied this lesson yet, click here. 9. Each question is a chance to learn. C = 3A B = A + 2 (A + 6) + (B + 6) = C + 6. If the positive square root of x is between 3 and 11, then what inequality represents all possible values of x? Now that you've studied the three detailed examples for Simplfying Algebraic Expressions, you are ready to try some on your own! Each question is a chance to learn. $48,000 C.$50,000 D. $52,500 E.$56,000. Grade Answers as You Go . Because the first half-mile is excluded, ½, or 0.5 must be subtracted from the distance when multiplying by 0.70. 3(2y + 4) = 8y, A. Is it a solution of an equation or inequality? $48,000 C.$50,000 D. $52,500 E.$56,000, 2. 1. Most sections should have a range of difficulty levels in the problems although this will vary from section to section. All information on this site is provided as is, without warranty. 3. None of the trademark holders are affiliated with StudyGuideZone.com. x = -2. B. 1. Permission is not required to add a link to this resource. Write each piece of information as an equation using the variables A, B, and C for the current ages of Andrew, Brad, and Carol, respectively. 9 miles B. This year, a salesman sells a total of $60,000 worth of steak knives by going door-to-door. 46 c. 21 d. 14 e. 7. Simplify algebraic expressions. 1. Here are a set of practice problems for the Algebra notes. If you're seeing this message, it means we're having trouble loading external resources on our website. 8. Algebra 1 Math Skills Practice: Grade 1 Grade 2 Grade 3 Grade 4 Grade 5 Grade 6 Grade 7 Grade 8 High School Geometry High School Statistics Algebra 1 Algebra 2. Since the salesman’s sales increased by 20% since last year’s, his current sales 120% of x, or 1.2x. [Understand the difference between an equation and a formula.]. Algebra Problems. If 3x + 8x + 4x = 6x + 63, then what is 5x + 23? Brad is two years older than Andrew. Then, solve for A. To begin, write an equation relating the cost C to the distance D. If one travels more than half a mile, the cost is$3.25 plus the $0.70 times the distance in miles, excluding the first half-mile. Algebra has a reputation for being difficult, but Math Games makes struggling with it a thing of the past. Full curriculum of exercises and videos. So, 1.2x = 60,000. 13 miles C. 14 miles D. 26 miles E. 27 miles, 10. Solve the equation for y. How far can someone travel for$12? 3. The absolute value of a number is its distance from zero on a number line. How old is Carol? Solve the equation for x. Practice Problems. Carol is three times older than Andrew. You appear to be on a device with a "narrow" screen width (, Derivatives of Exponential and Logarithm Functions, L'Hospital's Rule and Indeterminate Forms, Substitution Rule for Indefinite Integrals, Volumes of Solids of Revolution / Method of Rings, Volumes of Solids of Revolution/Method of Cylinders, Parametric Equations and Polar Coordinates, Gradient Vector, Tangent Planes and Normal Lines, Triple Integrals in Cylindrical Coordinates, Triple Integrals in Spherical Coordinates, Linear Homogeneous Differential Equations, Periodic Functions & Orthogonal Functions, Heat Equation with Non-Zero Temperature Boundaries, Absolute Value Equations and Inequalities. Therefore, someone can travel 13 miles on $12. Questions on solving linear and quadratic equations, simplifying expressions including expressions with fractions, finding slopes of lines are included. 6. E. To begin, simplify the right side of the equation by distributing the 3. To find how far someone can travel with$12, substitute 12 for C and solve for D. 12 = 3.25 + 0.70(D – 0.5) 12 = 3.25 + 0.7D – 0.35 9.1 = 0.7D D = 13. 1.-3ab + 4ac - 2ad = -(3ab - 4ac + 2ad) When multiplying polynomials, you should use the F-O-I-L method. Solutions and explanations for each of the answers to the algebra practice problems are provided in this section. Take your time, use a pencil and paper to help. Intermediate Algebra Problems With Answers - sample 2:Find equation of line, domain and range from graph, midpoint and distance of line segments, slopes of perpendicular and parallel lines. 9. B. For a fraction, the reciprocal can be found by inverting (or switching) the numerator and denominator. \$45,000 B. Intermediate Algebra Problems With Answers - sample 3 : equations and system of equations, quadratic equations, function given by a table, intersections of lines, problems. You appear to be on a device with a "narrow" screen width (, Derivatives of Exponential and Logarithm Functions, L'Hospital's Rule and Indeterminate Forms, Substitution Rule for Indefinite Integrals, Volumes of Solids of Revolution / Method of Rings, Volumes of Solids of Revolution/Method of Cylinders, Parametric Equations and Polar Coordinates, Gradient Vector, Tangent Planes and Normal Lines, Triple Integrals in Cylindrical Coordinates, Triple Integrals in Spherical Coordinates, Linear Homogeneous Differential Equations, Periodic Functions & Orthogonal Functions, Heat Equation with Non-Zero Temperature Boundaries, Absolute Value Equations and Inequalities, Add $$4{x^3} - 2{x^2} + 1$$ to $$7{x^2} + 12x$$, Subtract $$4{z^6} - 3{z^2} + 2z$$ from $$- 10{z^6} + 7{z^2} - 8$$, Subtract $$- 3{x^2} + 7x + 8$$ from $${x^4} + 7{x^3} - 12x - 1$$, $$12y\left( {3{y^4} - 7{y^2} + 1} \right)$$, $$\left( {3x + 1} \right)\left( {2 - 9{x^2}} \right)$$, $$\left( {{w^2} + 2} \right)\left( {3{w^2} + w} \right)$$, $$\left( {4{x^6} - 3x} \right)\left( {4{x^6} + 3x} \right)$$, $$\left( {{x^2} + x - 2} \right)\left( {3{x^2} - 8x - 7} \right)$$, Subtract $$3{\left( {{x^2} + 1} \right)^2}$$ from $$6{x^3} - 9{x^2} - 13x - 4$$.