Ignore:
Timestamp:
05/23/09 11:22:24 (4 years ago)
Author:
Tiago de Paula Peixoto <tiago@…>
Branches:
master, python3
Children:
a8f2c8
Parents:
b334e1
git-author:
Tiago de Paula Peixoto <tiago@…> (05/23/09 06:38:05)
git-committer:
Tiago de Paula Peixoto <tiago@…> (05/23/09 11:22:24)
Message:
Switch from boost::random to tr1::random

The generators from boost::random seem to have a bug which causes them
to be biased. The generators from tr1::random seem to be in better
shape.

See: http://thread.gmane.org/gmane.comp.lib.boost.user/48006
Location:
src/graph/centrality
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/graph/centrality/graph_absolute_trust.cc

    r9c825c r750519  
    2323#include "graph_selectors.hh" 
    2424 
    25 #include <boost/random.hpp> 
    26 typedef boost::mt19937 rng_t; 
     25#include <tr1/random> 
     26typedef std::tr1::mt19937 rng_t; 
    2727 
    2828#include "graph_absolute_trust.hh" 
  • src/graph/centrality/graph_absolute_trust.hh

    rb334e1 r750519  
    2424 
    2525#include <tr1/unordered_set> 
    26 #include <boost/random/uniform_int.hpp> 
     26#include <tr1/random> 
    2727#include <boost/functional/hash.hpp> 
     28 
     29#include <iostream> 
    2830 
    2931namespace graph_tool 
     
    5254        // init inferred trust t 
    5355        int i, N = num_vertices(g); 
    54         #pragma omp parallel for default(shared) private(i)     \ 
    55             schedule(dynamic) 
     56        #pragma omp parallel for default(shared) private(i) schedule(dynamic) 
    5657        for (i = (source == -1) ? 0 : source; 
    5758             i < ((source == -1) ? N : source + 1); ++i) 
     
    7273            // walk hash set 
    7374            tr1::unordered_set<size_t> path_set; 
    74             uniform_int<size_t> random_salt(0, numeric_limits<size_t>::max()); 
     75            tr1::uniform_int<size_t> 
     76                random_salt(0, numeric_limits<size_t>::max()); 
    7577            size_t salt = random_salt(rng); 
    7678 
     
    122124                        // select edge according to its probability 
    123125                        typename graph_traits<Graph>::edge_descriptor e; 
    124                         uniform_real<t_type> random(0,out_prob.back()); 
     126                        typedef tr1::uniform_real<t_type> dist_t; 
     127                        tr1::variate_generator<rng_t, dist_t> 
     128                            random(rng, dist_t(0, out_prob.back())); 
    125129 
    126130                        t_type u; 
    127131                        { 
    128132                            #pragma omp critical 
    129                             u = random(rng); 
     133                            u = random(); 
    130134                        } 
    131135                        e = out_es[lower_bound(out_prob.begin(), 
Note: See TracChangeset for help on using the changeset viewer.