GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Non GSM/Mobile Related Forums > Off Topic Zone


Off Topic Zone Here all other messages...

Reply
 
LinkBack Thread Tools Display Modes
Old 09-29-2022, 14:33   #1 (permalink)
No Life Poster
 
platforms's Avatar
 
Join Date: Sep 2004
Location: London
Age: 43
Posts: 520
Member: 83090
Status: Offline
Sonork: 1626857
Thanks Meter: 52
How is a Lotto Cover design constructed?


Does any one here know ?. Am curious.
  Reply With Quote
Old 11-16-2022, 11:48   #2 (permalink)
No Life Poster
 
platforms's Avatar
 
Join Date: Sep 2004
Location: London
Age: 43
Posts: 520
Member: 83090
Status: Offline
Sonork: 1626857
Thanks Meter: 52
Really? Nobody knows? I guess this is fortunate for me.

Quote:
import numpy as np
import time

n = int(input("How many treatments are in the set (n)? "))
k = int(input("How many treatmewnts are included in each block (k)? "))
_lambda = int(input("How many observations of each pair do you want (lambda)? "))
m = int(input("How many designs do you want the algorithm to generate before picking the best one (m)? "))

t0 = time.time()
with open('ExperimentDesign.csv','w') as outFile:
line = 'Block,'
for stimulus in range(k):
line = line + 'Treat{},'.format(stimulus+1)
line = line[:-1] + '\n'
outFile.write(line)
for i in range(m):
comparisons = np.tril(np.ones((n,n),dtype=int),-1) + np.triu(np.ones((n,n),dtype=int),1)
comparisons = _lambda * comparisons
current_design = np.zeros((1,k),dtype=int)
while comparisons.sum() > 0:
current_block = np.zeros(k,dtype=int)
for stim in range(k):
degree = np.sum(comparisons,axis=0)
links = np.zeros(n, dtype=int)
for s in range(n):
for sl in range(stim):
links[s] += comparisons[s,current_block[sl]]
links[s] += comparisons[current_block[sl],s]
for s in range(stim):
links[current_block[s]] = -1
idx = np.argwhere(links == np.amax(links))
if len(idx) == 1:
current_block[stim] = idx;
else:
idx2 = np.argwhere(degree == np.amax(degree[idx]))
idx3 = np.intersect1d(idx,idx2)
current_block[stim] = idx3[np.random.randint(len(idx3))]
for s in range(stim):
comparisons[current_block[stim],current_block[s]] = np.maximum(comparisons[current_block[stim],current_block[s]]-1,0)
comparisons[current_block[s],current_block[stim]] = np.maximum(comparisons[current_block[s],current_block[stim]]-1,0)
current_design = np.append(current_design, current_block.reshape((1,k)), axis=0)
current_design = current_design[1:]
if i == 0:
best_design = current_design
else:
if current_design.shape[0] < best_design.shape[0]:
best_design = current_design
for trial in range(best_design.shape[0]):
line = '{},'.format(trial+1)
for stimulus in range(k):
line = line + '{},'.format(best_design[trial,stimulus]+1)
line = line[:-1] + '\n'
outFile.write(line)
print('Saved as ExperimentDesign.csv.')
print('Executed in {:.2f} seconds'.format(time.time() - t0))
  Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 19:25.



Powered by Searchlight © 2024 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -
Page generated in 0.14623 seconds with 8 queries

SEO by vBSEO